1 | describe('Worker', function () {
|
2 | var workerErrorEventToError = function (errorEvent) {
|
3 | var errorText = 'Error in Worker';
|
4 | if (errorEvent.filename !== undefined) {
|
5 | errorText += ' ' + errorEvent.filename;
|
6 | }
|
7 | if (errorEvent.lineno !== undefined) {
|
8 | errorText += '(' + errorEvent.lineno + ')';
|
9 | }
|
10 | if (errorEvent.message !== undefined) {
|
11 | errorText += ': ' + errorEvent.message;
|
12 | }
|
13 | return new Error(errorText);
|
14 | };
|
15 | var canRunWorkerTestInCurrentContext = function () {
|
16 | var workerConstructorExists = typeof Worker !== 'undefined';
|
17 | var locationPropertyExists = typeof location !== 'undefined';
|
18 | var runningOnFileUriScheme = locationPropertyExists && location.protocol === 'file:';
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | return workerConstructorExists && !runningOnFileUriScheme;
|
25 | };
|
26 |
|
27 | if (canRunWorkerTestInCurrentContext()) {
|
28 | it('can import es6-shim', function (done) {
|
29 | var worker = new Worker('worker-runner.workerjs');
|
30 | worker.addEventListener('error', function (errorEvent) { throw workerErrorEventToError(errorEvent); });
|
31 | worker.addEventListener('message', function (messageEvent) {
|
32 | expect(messageEvent.data).to.eql('ready');
|
33 | done();
|
34 | });
|
35 | });
|
36 | }
|
37 | });
|