dojo / core

:rocket: Dojo 2 - language helpers and utilities.
http://dojo.io
Other
213 stars 62 forks source link

XHR requests don't work in IE 11 from web worker #324

Closed rorticus closed 7 years ago

rorticus commented 7 years ago

Bug

When writing the test for https://github.com/dojo/core/issues/320, I've run into another issue in IE11. It looks like XHR requests use queue, and that's causing some woe in IE 11 from a webworker.

image

^^ that code: https://github.com/dojo/shim/blob/master/src/support/queue.ts#L65

rorticus commented 7 years ago

This test in dojo/shim will show the problem,

        'queue from webworker': function (this: any) {
            if (global.Worker === undefined) {
                this.skip('does not support web workers');
                return;
            }

            const baseUrl = location.origin;
            const dfd = this.async(10000);
            const blob = new Blob([ `(function() { 
self.addEventListener('message', function (event) {
    if(event.data.baseUrl) {
        var baseUrl = event.data.baseUrl;
        importScripts(baseUrl + '/node_modules/@dojo/loader/loader.js');

        require.config({
            baseUrl: baseUrl,
            packages: [
                { name: '@dojo', location: 'node_modules/@dojo' }
            ]
        });

        require(['_build/src/support/queue'], function (queue) {
            queue.queueTask(function() {
                self.postMessage('success');
            });
        });
    }
});
            })()` ], { type: 'application/javascript' });
            const worker = new Worker(URL.createObjectURL(blob));
            worker.addEventListener('error', (error) => {
                dfd.reject(new Error(error.message));
            });
            worker.addEventListener('message', ({ data: result }) => {
                if (result === 'success') {
                    dfd.resolve();
                }
            });

            worker.postMessage({
                baseUrl
            });
        }
rorticus commented 7 years ago

Issue moved to dojo/shim #107 via ZenHub