diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/workers/interfaces | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/workers/interfaces')
59 files changed, 1487 insertions, 0 deletions
diff --git a/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/EventTarget.worker.js b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/EventTarget.worker.js new file mode 100644 index 000000000..954c46c07 --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/EventTarget.worker.js @@ -0,0 +1,23 @@ +importScripts("/resources/testharness.js"); + +test(function(t) { + var i = 0; + addEventListener("message", function listener(evt) { + t.step(function() { + ++i; + removeEventListener("message", listener, true); + }); + }, true); + self.dispatchEvent(new Event("message")); + self.dispatchEvent(new Event("message")); + assert_equals(i, 1); +}, "removeEventListener"); + +test(function() { + addEventListener("message", this.step_func(function(evt) { + assert_equals(evt.target, self); + }), true); + self.dispatchEvent(new Event("message")); +}, "target"); + +done(); diff --git a/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/onmessage.worker.js b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/onmessage.worker.js new file mode 100644 index 000000000..6f285caac --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/onmessage.worker.js @@ -0,0 +1,40 @@ +importScripts("/resources/testharness.js"); + +test(function() { + self.onmessage = 1; + assert_equals(self.onmessage, null, + "attribute should return null after being set to a primitive"); +}, "Setting onmessage to 1"); + +test(function() { + var object = { + handleEvent: this.unreached_func() + }; + self.onmessage = object; + assert_equals(self.onmessage, object, + "attribute should return the object it was set to."); + + self.dispatchEvent(new Event("message")); +}, "Setting onmessage to an object"); + +test(function() { + var triggered = false; + var f = function(e) { triggered = true; }; + self.onmessage = f; + assert_equals(self.onmessage, f, + "attribute should return the function it was set to."); + + self.dispatchEvent(new Event("message")); + assert_true(triggered, "event handler should have been triggered"); +}, "Setting onmessage to a function"); + + +test(function() { + assert_not_equals(self.onmessage, null, + "attribute should not return null after being set to a function"); + self.onmessage = 1; + assert_equals(self.onmessage, null, + "attribute should return null after being set to a primitive"); +}, "Setting onmessage to 1 (again)"); + +done(); diff --git a/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/event-ports-dedicated.html b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/event-ports-dedicated.html new file mode 100644 index 000000000..7ae4b0704 --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/event-ports-dedicated.html @@ -0,0 +1,25 @@ +<!-- +onmessage = function(e) { + postMessage(e.ports instanceof Array && e.ports.length === 0); +} +/* +--> +<!doctype html> +<title>e.ports in dedicated worker</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +(async_test()).step(function() { + var worker = new Worker('#'); + worker.postMessage(1); + worker.onmessage = this.step_func(function(e) { + assert_true(e.data); + this.done(); + }); +}); +</script> +<!-- +*/ +//--> + diff --git a/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/imagedata-cloned-canvas-in-array.html b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/imagedata-cloned-canvas-in-array.html new file mode 100644 index 000000000..204130154 --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/imagedata-cloned-canvas-in-array.html @@ -0,0 +1,39 @@ +<!-- +onmessage = function(e) { + function processPixels(imagedata) { + var pixeldata = imagedata.data; + for (var i = 0; i < pixeldata.length; i = i+4) { + pixeldata[i] = 128; + } + postMessage(imagedata); + } + processPixels(e.data[0]); +} + +/* +--> +<!doctype html> +<title>posting an imagedata (from a cloned canvas) in an array</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +(async_test()).step(function() { + var worker = new Worker('#'); + var canvas = document.createElement('canvas'); + var clone = canvas.cloneNode(true); + var ctx = clone.getContext('2d'); + var imagedata = ctx.getImageData(0, 0, 300, 150); + worker.postMessage([imagedata]); + worker.onmessage = this.step_func(function(e) { + var pixeldata = e.data.data; + for (var i = 0; i < pixeldata.length; i++) { + assert_equals(pixeldata[i], (i % 4 == 0) ? 128 : 0); + } + this.done(); + }); +}); +</script> +<!-- +*/ +//-->
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/message-event.html b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/message-event.html new file mode 100644 index 000000000..91ec63268 --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/message-event.html @@ -0,0 +1,23 @@ +<!DOCTYPE html> +<meta charset=utf-8> +<title>'message' event properties</title> +<link rel=help href="http://www.whatwg.org/html/#dom-dedicatedworkerglobalscope-postmessage"> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +async_test("Properties of the 'message' event").step(function() { + var worker = new Worker("message-event.js"); + worker.onmessage = this.step_func_done(function (evt) { + assert_class_string(evt, "MessageEvent"); + assert_equals(evt.type, "message"); + assert_false(evt.bubbles, "bubbles should be false"); + assert_false(evt.cancelable, "cancelable should be false"); + assert_equals(evt.data, "test"); + assert_equals(evt.origin, "", "origin"); + assert_equals(evt.lastEventId, "", "lastEventId"); + assert_equals(evt.source, null, "source"); + assert_array_equals(evt.ports, [], "ports"); + }); +}); +</script> diff --git a/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/message-event.js b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/message-event.js new file mode 100644 index 000000000..54a250005 --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/message-event.js @@ -0,0 +1 @@ +postMessage("test"); diff --git a/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/return-value.worker.js b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/return-value.worker.js new file mode 100644 index 000000000..521251699 --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/return-value.worker.js @@ -0,0 +1,8 @@ +importScripts("/resources/testharness.js"); + +test(function() { + var rv = postMessage(1); + assert_equals(rv, undefined); +}, "return value of postMessage"); + +done(); diff --git a/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/second-argument-null-in-array.html b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/second-argument-null-in-array.html new file mode 100644 index 000000000..df4c9f83e --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/second-argument-null-in-array.html @@ -0,0 +1,26 @@ +<!-- +try { + postMessage(false, [null]); +} catch(e) { + postMessage(e instanceof TypeError); +} +/* +--> +<!doctype html> +<title>Using [null] in postMessage's second argument</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +(async_test()).step(function() { + var worker = new Worker('#'); + worker.onmessage = this.step_func(function(e) { + assert_true(e.data); + this.done(); + }); +}); +</script> +<!-- +*/ +//--> + diff --git a/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/second-argument-null.html b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/second-argument-null.html new file mode 100644 index 000000000..e81a56bad --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/second-argument-null.html @@ -0,0 +1,25 @@ +<!-- +try { + postMessage(1, null); +} catch(e) { + postMessage(e instanceof TypeError); +} +/* +--> +<!doctype html> +<title>Using null in postMessage's second argument</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +(async_test()).step(function() { + var worker = new Worker('#'); + worker.onmessage = this.step_func(function(e) { + assert_true(e.data); + this.done(); + }); +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/second-argument-undefined.html b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/second-argument-undefined.html new file mode 100644 index 000000000..7d01eba7a --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/second-argument-undefined.html @@ -0,0 +1,25 @@ +<!-- +try { + postMessage(1, undefined); +} catch(e) { + postMessage(''+e); +} +/* +--> +<!doctype html> +<title>Using undefined in postMessage's second argument</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +(async_test()).step(function() { + var worker = new Worker('#'); + worker.onmessage = this.step_func(function(e) { + assert_equals(e.data, 1); + this.done(); + }); +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/setting-postMessage.html b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/setting-postMessage.html new file mode 100644 index 000000000..d1a3f0f5c --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/setting-postMessage.html @@ -0,0 +1,24 @@ +<!-- +var x = postMessage; +postMessage = 1; +x(postMessage == 1); + +/* +--> +<!doctype html> +<title>setting postMessage</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +(async_test()).step(function() { + var worker = new Worker('#'); + worker.onmessage = this.step_func(function(e) { + assert_true(e.data); + this.done(); + }); +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/structured-clone-imagedata.html b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/structured-clone-imagedata.html new file mode 100644 index 000000000..c0ded6a28 --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/structured-clone-imagedata.html @@ -0,0 +1,30 @@ +<!-- +onmessage = function(e) { + var imagedata = e.data; + imagedata.data[0] = 128; + postMessage(imagedata); +} + +/* +--> +<!doctype html> +<title>structured clone of ImageData</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +(async_test()).step(function() { + var worker = new Worker('#'); + var ctx = document.createElement('canvas').getContext('2d'); + var imagedata = ctx.getImageData(0, 0, 300, 150); + worker.postMessage(imagedata); + worker.onmessage = this.step_func(function(e) { + assert_equals(''+e.data, '[object ImageData]'); + assert_equals(e.data.data[0], 128); + this.done(); + }); +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/structured-clone-message.html b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/structured-clone-message.html new file mode 100644 index 000000000..ba357421f --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/structured-clone-message.html @@ -0,0 +1,58 @@ +<!-- +var err = new Error('foo'); +var date = new Date(); +// commented out bits are either tested elsewhere or not supported yet. or uncloneable. +var tests = [undefined, null, false, true, 1, NaN, Infinity, 'foo', date, /foo/, /* ImageData, File, FileData, FileList,*/ null/*self*/, + [undefined, null, false, true, 1, NaN, Infinity, 'foo', /*date, /foo/,*/ null/*self*/, /*[], {},*/ null/*err*/], + {a:undefined, b:null, c:false, d:true, e:1, f:NaN, g:Infinity, h:'foo', /*i:date, j:/foo/,*/ k:null/*self*/, /*l:[], m:{},*/ n:null/*err*/}, + null/*err*/]; +for (var i = 0; i < tests.length; ++i) { + try { + postMessage(tests[i]); + } catch(e) { + postMessage(''+e); + } +} +/* +--> +<!doctype html> +<title>structured clone of message</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +var wrapper_test = async_test(); +var tests = [ + {test:async_test('undefined'), check:function(e) { assert_equals(e.data, undefined); }}, + {test:async_test('null'), check:function(e) { assert_equals(e.data, null); }}, + {test:async_test('false'), check:function(e) { assert_false(e.data); }}, + {test:async_test('true'), check:function(e) { assert_true(e.data); }}, + {test:async_test('1'), check:function(e) { assert_equals(e.data, 1); }}, + {test:async_test('NaN'), check:function(e) { assert_equals(e.data, NaN); }}, + {test:async_test('Infinity'), check:function(e) { assert_equals(e.data, Infinity); }}, + {test:async_test('string'), check:function(e) { assert_equals(e.data, 'foo'); }}, + {test:async_test('date'), check:function(e) { assert_equals(e.data instanceof Date, true); }}, + {test:async_test('regexp'), check:function(e) { assert_equals('' + e.data, '/foo/'); assert_equals(e.data instanceof RegExp, true, 'e.data instanceof RegExp'); }}, + {test:async_test('self'), check:function(e) { assert_equals(e.data, null); }}, + {test:async_test('array'), check:function(e) { assert_array_equals(e.data, [undefined, null, false, true, 1, NaN, Infinity, 'foo', null, null]); }}, + {test:async_test('object'), check:function(e) { assert_object_equals(e.data, {a:undefined, b:null, c:false, d:true, e:1, f:NaN, g:Infinity, h:'foo', k:null, n:null}); }}, + {test:async_test('error'), check:function(e) { assert_equals(e.data, null, 'new Error()'); }}, + {test:wrapper_test, check:function(e) { assert_unreached(); }} +]; +// make wrapper_test pass after 500ms +setTimeout(tests[tests.length-1].test.step_func(function() { + this.done(); +}), 500); + +wrapper_test.step(function() { + var worker = new Worker('#'); + var i = 0; + worker.onmessage = function(e) { + tests[i].test.step(function() { tests[i].check(e); this.done(); }); + i++; + }; +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/interfaces/SharedWorkerGlobalScope/name/getting.html b/testing/web-platform/tests/workers/interfaces/SharedWorkerGlobalScope/name/getting.html new file mode 100644 index 000000000..bfe81a8a9 --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/SharedWorkerGlobalScope/name/getting.html @@ -0,0 +1,34 @@ +<!-- +addEventListener('connect', function(e) { + var passed; + switch (location.hash) { + case '#1': passed = name == ''; break; + case '#2': passed = name == 'a'; break; + case '#3': passed = name == '0'; break; + } + e.ports[0].postMessage(passed); +}, false); +/* +--> +<!doctype html> +<title>getting name</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +var tests = [['#1', ''], ['#2', 'a'], ['#3', -0]]; +tests.forEach(function(t) { + async_test(function() { + var w = new SharedWorker(t[0], t[1]); + w.port.onmessage = this.step_func(function(e) { + assert_true(e.data); + this.done(); + }); + }); +}); +</script> +<!-- +*/ +//--> + + diff --git a/testing/web-platform/tests/workers/interfaces/SharedWorkerGlobalScope/name/setting.html b/testing/web-platform/tests/workers/interfaces/SharedWorkerGlobalScope/name/setting.html new file mode 100644 index 000000000..39cdf7b67 --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/SharedWorkerGlobalScope/name/setting.html @@ -0,0 +1,25 @@ +<!-- +addEventListener('connect', function(e) { + name = 1; + e.ports[0].postMessage(name); +}, false); +/* +--> +<!doctype html> +<title>setting name</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +async_test(function() { + var w1 = new SharedWorker('#1', 'x'); + w1.port.addEventListener('message', this.step_func(function(e) { + assert_equals(e.data, 'x'); + this.done(); + }), false); + w1.port.start(); +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/interfaces/SharedWorkerGlobalScope/onconnect.html b/testing/web-platform/tests/workers/interfaces/SharedWorkerGlobalScope/onconnect.html new file mode 100644 index 000000000..2ad155bf7 --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/SharedWorkerGlobalScope/onconnect.html @@ -0,0 +1,39 @@ +<!-- +var results = []; +try { + self.onconnect = 1; + results.push(String(onconnect)); +} catch(e) { + results.push(''+e); +} +try { + self.onconnect = {handleEvent:function(){}}; + results.push(String(onconnect)); +} catch(e) { + results.push(''+e); +} +var f = function(e) { + results.push(e.data); + e.ports[0].postMessage(results); +}; +onconnect = f; +results.push(typeof onconnect); +/* +--> +<!doctype html> +<title>onconnect</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +async_test(function() { + var w1 = new SharedWorker('#', ''); + w1.port.addEventListener('message', this.step_func(function(e) { + assert_array_equals(e.data, ['null', 'null', 'function', '']); + }), false); + w1.port.start(); +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/close/incoming-message.html b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/close/incoming-message.html new file mode 100644 index 000000000..d65695632 --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/close/incoming-message.html @@ -0,0 +1,29 @@ +<!-- +onmessage = function(e) { + postMessage(1); + throw new Error(); +} +close(); +/* +--> +<!doctype html> +<title>close() and incoming message</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +var worker = new Worker('#'); +worker.onmessage = function(e) { + assert_unreached("Got message"); +}; +worker.onerror = function(e) { + assert_unreached("Got error"); +}; +worker.postMessage(1); +setTimeout(done, 2000); +</script> +<!-- +*/ +//--> + + diff --git a/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/close/sending-messages.html b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/close/sending-messages.html new file mode 100644 index 000000000..983c422cc --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/close/sending-messages.html @@ -0,0 +1,27 @@ +<!-- +postMessage(1); +close(); +postMessage(2); +/* +--> +<!doctype html> +<title>close() and sending messages</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +async_test(function() { + var worker = new Worker('#'); + var i = 0; + worker.onmessage = this.step_func(function(e) { + i++; + assert_equals(e.data, i); + if (i == 2) { + this.done(); + } + }); +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/close/setInterval.html b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/close/setInterval.html new file mode 100644 index 000000000..1d7d178d2 --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/close/setInterval.html @@ -0,0 +1,34 @@ +<!-- +var interval1 = setInterval(function() { + clearInterval(interval1); + postMessage(1); + throw new Error(); +}, 10); +close(); +var interval2 = setInterval(function() { + clearInterval(interval2); + postMessage(1); + throw new Error(); +}, 10); +/* +--> +<!doctype html> +<title>close() and setInterval</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +var worker = new Worker('#'); +worker.onmessage = function(e) { + assert_unreached("Got message"); +}; +worker.onerror = function(e) { + assert_unreached("Got error"); +}; +setTimeout(done, 2000); +</script> +<!-- +*/ +//--> + + diff --git a/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/close/setTimeout.html b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/close/setTimeout.html new file mode 100644 index 000000000..c2fa10dfc --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/close/setTimeout.html @@ -0,0 +1,28 @@ +<!-- +function x() { + postMessage(1); + throw new Error(); +} +setTimeout(x, 0); +close(); +setTimeout(x, 0); +/* +--> +<!doctype html> +<title>close() and setTimeout</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +var worker = new Worker('#'); +worker.onmessage = function(e) { + assert_unreached("Got message"); +}; +worker.onerror = function(e) { + assert_unreached("Got error"); +}; +setTimeout(done, 2000); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/helper-redirect.py b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/helper-redirect.py new file mode 100644 index 000000000..eb1599a57 --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/helper-redirect.py @@ -0,0 +1,3 @@ +def main(request, response): + response.status = 302 + response.headers.append("Location", "post-location-members.js?a") diff --git a/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/members.html b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/members.html new file mode 100644 index 000000000..31ddf37a1 --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/members.html @@ -0,0 +1,31 @@ +<!-- +postMessage([null, location.href, location.protocol, location.host, + location.hostname, location.port, location.pathname, + location.search, location.hash]); +/* +--> +<!doctype html> +<title>members of WorkerLocation</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +async_test(function() { + var worker = new Worker('#'); + worker.onmessage = this.step_func(function(e) { + assert_equals(e.data[0], null); + assert_equals(e.data[1], location.href + '#', 'href'); + assert_equals(e.data[2], location.protocol, 'protocol'); + assert_equals(e.data[3], location.host, 'host'); + assert_equals(e.data[4], location.hostname, 'hostname'); + assert_equals(e.data[5], location.port, 'port'); + assert_equals(e.data[6], location.pathname, 'pathname'); + assert_equals(e.data[7], location.search, 'search'); + assert_equals(e.data[8], '', 'hash'); + this.done(); + }); +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/post-location-members.js b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/post-location-members.js new file mode 100644 index 000000000..e850b76b6 --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/post-location-members.js @@ -0,0 +1,8 @@ +postMessage([location.href, + location.protocol, + location.host, + location.hostname, + location.port, + location.pathname, + location.search, + location.hash]);
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/redirect.html b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/redirect.html new file mode 100644 index 000000000..2fd16a4c1 --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/redirect.html @@ -0,0 +1,28 @@ +<!-- +/* +--> +<!doctype html> +<title>location with a worker in separate file that redirects</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +async_test(function() { + var worker = new Worker('helper-redirect.py?fail'); + worker.onmessage = this.step_func_done(function(e) { + assert_equals(e.data[0], location.href.replace(/\/[^\/]+$/, '/post-location-members.js?a')); + assert_equals(e.data[1], location.protocol); + assert_equals(e.data[2], location.host); + assert_equals(e.data[3], location.hostname); + assert_equals(e.data[4], location.port); + assert_equals(e.data[5], location.pathname.replace(/\/[^\/]+$/, '/post-location-members.js')); + assert_equals(e.data[6], '?a'); + assert_equals(e.data[7], ''); + }); +}); +</script> +<!-- +*/ +//--> + + diff --git a/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/returns-same-object.html b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/returns-same-object.html new file mode 100644 index 000000000..40559c166 --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/returns-same-object.html @@ -0,0 +1,21 @@ +<!-- +postMessage(location === location); +/* +--> +<!doctype html> +<title>location === location</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +async_test(function() { + var worker = new Worker('#'); + worker.onmessage = this.step_func(function(e) { + assert_true(e.data); + this.done(); + }); +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/setting-members.html b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/setting-members.html new file mode 100644 index 000000000..d2f470ffc --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/setting-members.html @@ -0,0 +1,43 @@ +<!-- +var exceptions = []; +try { location.href = 1; } catch(e) { exceptions.push('href'); } +try { location.protocol = 1; } catch(e) { exceptions.push('protocol'); } +try { location.host = 1; } catch(e) { exceptions.push('host'); } +try { location.hostname = 1; } catch(e) { exceptions.push('hostname');} +try { location.port = 1; } catch(e) { exceptions.push('port'); } +try { location.pathname = 1; } catch(e) { exceptions.push('pathname'); } +try { location.search = 1; } catch(e) { exceptions.push('search'); } +try { location.hash = 1; } catch(e) { exceptions.push('hash'); } + +postMessage([null, location.href, location.protocol, location.host, + location.hostname, location.port, location.pathname, + location.search, location.hash, exceptions]); +/* +--> +<!doctype html> +<title>setting members of WorkerLocation</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +async_test(function() { + var worker = new Worker('#'); + worker.onmessage = this.step_func(function(e) { + assert_equals(e.data[0], null); + assert_equals(e.data[1], location.href + '#', 'href'); + assert_equals(e.data[2], location.protocol, 'protocol'); + assert_equals(e.data[3], location.host, 'host'); + assert_equals(e.data[4], location.hostname, 'hostname'); + assert_equals(e.data[5], location.port, 'port'); + assert_equals(e.data[6], location.pathname, 'pathname'); + assert_equals(e.data[7], location.search, 'search'); + assert_equals(e.data[8], '', 'hash'); + assert_array_equals(e.data[9], [], 'number of exceptions'); + this.done(); + }); +}); +</script> +<!-- +*/ +//--> + diff --git a/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/worker-separate-file.html b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/worker-separate-file.html new file mode 100644 index 000000000..ac8e64dcc --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/worker-separate-file.html @@ -0,0 +1,28 @@ +<!-- +/* +--> +<!doctype html> +<title>location with a worker in separate file</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +async_test(function() { + var worker = new Worker('post-location-members.js?a#b?c'); + worker.onmessage = this.step_func(function(e) { + assert_equals(e.data[0], location.href.replace(/\/[^\/]+$/, '/post-location-members.js?a#b?c')); + assert_equals(e.data[1], location.protocol); + assert_equals(e.data[2], location.host); + assert_equals(e.data[3], location.hostname); + assert_equals(e.data[4], location.port); + assert_equals(e.data[5], location.pathname.replace(/\/[^\/]+$/, '/post-location-members.js')); + assert_equals(e.data[6], '?a'); + assert_equals(e.data[7], '#b?c'); + this.done(); + }); +}); +</script> +<!-- +*/ +//--> + diff --git a/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/onerror/exception-in-onerror.html b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/onerror/exception-in-onerror.html new file mode 100644 index 000000000..4b5af71d5 --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/onerror/exception-in-onerror.html @@ -0,0 +1,32 @@ +<!-- +onerror = function(a, b, c, d) { + y(); // the error is "not handled" +} +function x() { + y(); +} +x(); +/* +--> +<!doctype html> +<title>onerror, "not handled" with an error in the onerror function</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +async_test(function() { + var worker = new Worker('#'); + worker.onerror = this.step_func(function(e) { + assert_true(e instanceof ErrorEvent, 'e instanceof ErrorEvent'); + assert_equals(typeof e.message, 'string', 'typeof e.message'); + assert_equals(e.filename, document.URL+'#', 'e.filename'); + assert_equals(typeof e.lineno, 'number', 'typeof e.lineno'); + assert_equals(typeof e.colno, 'number', 'typeof e.column'); + e.preventDefault(); // "handled" + this.done(); + }); +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/onerror/handled.html b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/onerror/handled.html new file mode 100644 index 000000000..56fee8e06 --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/onerror/handled.html @@ -0,0 +1,36 @@ +<!-- +onerror = function(a, b, c, d) { + postMessage([a, b, c, d]); + return true; // the error is "handled" +} +function x() { + y(); +} +x(); +/* +--> +<!doctype html> +<title>onerror, "handled"</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +async_test(function() { + var worker = new Worker('#'); + worker.onmessage = this.step_func(function(e) { + assert_equals(typeof e.data[0], 'string', 'first argument'); + assert_equals(e.data[1], document.URL+'#', 'second argument'); + assert_equals(typeof e.data[2], 'number', 'third argument'); + assert_equals(typeof e.data[3], 'number', 'fourth argument'); + setTimeout(this.step_func(function() { + this.done(); + }), 100); + }); + worker.onerror = this.step_func(function(e) { + assert_unreached(); + }); +}); +</script> +<!-- +*/ +//-->
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/onerror/not-handled.html b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/onerror/not-handled.html new file mode 100644 index 000000000..f6107ada4 --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/onerror/not-handled.html @@ -0,0 +1,32 @@ +<!-- +onerror = function(a, b, c, d) { + return false; // the error is "not handled" +} +function x() { + y(); +} +x(); +/* +--> +<!doctype html> +<title>onerror, "not handled"</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +async_test(function() { + var worker = new Worker('#'); + worker.onerror = this.step_func(function(e) { + assert_true(e instanceof ErrorEvent, 'e instanceof ErrorEvent'); + assert_equals(typeof e.message, 'string', 'typeof e.message'); + assert_equals(e.filename, document.URL+'#', 'e.filename'); + assert_equals(typeof e.lineno, 'number', 'typeof e.lineno'); + assert_equals(typeof e.colno, 'number', 'typeof e.column'); + e.preventDefault(); // "handled" + this.done(); + }); +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/onerror/propagate-to-window-onerror.html b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/onerror/propagate-to-window-onerror.html new file mode 100644 index 000000000..b6a61e235 --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/onerror/propagate-to-window-onerror.html @@ -0,0 +1,31 @@ +<!-- +function x() { + y(); +} +x(); +/* +--> +<!doctype html> +<title>onerror, "not handled" with only window.onerror defined</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +setup({ + allow_uncaught_exception: true, +}); +async_test(function() { + var worker = new Worker('#'); + window.onerror = this.step_func(function(a, b, c, d) { + assert_equals(typeof a, 'string', 'first argument'); + assert_equals(b, document.URL+'#', 'second argument'); + assert_equals(typeof c, 'number', 'third argument'); + assert_equals(typeof d, 'number', 'fourth argument'); + this.done(); + return true; // "handled" + }); +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/self.html b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/self.html new file mode 100644 index 000000000..39c2c36c0 --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/self.html @@ -0,0 +1,39 @@ +<!-- +var results = []; +function check(func, msg) { + try { + results.push([func(), msg]); + } catch(ex) { + results.push([String(ex), msg]); + } +} +check(function() { return self === self; }, 'self === self'); +check(function() { return self instanceof WorkerGlobalScope; }, 'self instanceof WorkerGlobalScope'); +check(function() { return 'self' in self; }, '\'self\' in self'); +check(function() { + var x = self; + self = 1; + return x === self; +}, 'self = 1'); +postMessage(results); +/* +--> +<!doctype html> +<title>self</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +async_test(function() { + var worker = new Worker('#'); + worker.onmessage = this.step_func(function(e) { + for (var i = 0; i < e.data.length; ++i) { + assert_true(e.data[i][0], e.data[i][1]); + } + this.done(); + }); +}); +</script> +<!-- +*/ +//-->
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/WindowTimers/001.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/WindowTimers/001.html new file mode 100644 index 000000000..a80897518 --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/WindowTimers/001.html @@ -0,0 +1,23 @@ +<!-- +setTimeout(function() { postMessage(1) }, 10); +/* +--> +<!doctype html> +<title>setTimeout</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +async_test(function() { + var worker = new Worker('#'); + worker.onmessage = this.step_func(function(e) { + assert_equals(e.data, 1); + this.done(); + }); +}); +</script> +<!-- +*/ +//--> + + diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/WindowTimers/002.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/WindowTimers/002.html new file mode 100644 index 000000000..06685a905 --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/WindowTimers/002.html @@ -0,0 +1,21 @@ +<!-- +var t = setTimeout(function() { postMessage(1); }, 10); +clearTimeout(t); +/* +--> +<!doctype html> +<title>clearTimeout</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +async_test(function() { + var worker = new Worker('#'); + var gotMessage = false; + worker.onmessage = function() { gotMessage = true; }; + setTimeout(this.step_func(function() { assert_false(gotMessage); this.done(); }), 100); +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/WindowTimers/003.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/WindowTimers/003.html new file mode 100644 index 000000000..942f139fa --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/WindowTimers/003.html @@ -0,0 +1,22 @@ +<!-- +setInterval(function() { postMessage(1); }, 10); +/* +--> +<!doctype html> +<title>setInterval</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +async_test(function() { + var worker = new Worker('#'); + worker.onmessage = this.step_func(function(e) { + assert_equals(e.data, 1); + this.done(); + }); +}); +</script> +<!-- +*/ +//--> + diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/WindowTimers/004.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/WindowTimers/004.html new file mode 100644 index 000000000..5548eec4a --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/WindowTimers/004.html @@ -0,0 +1,23 @@ +<!-- +var t = setInterval(function() { + postMessage(1); +}, 10); +clearInterval(t); +/* +--> +<!doctype html> +<title>clearInterval</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +async_test(function() { + var worker = new Worker('#'); + var i = 0; + worker.onmessage = function() { i++; } + setTimeout(this.step_func(function() { assert_equals(i, 0); this.done(); }), 100); +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/001.worker.js b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/001.worker.js new file mode 100644 index 000000000..aa86c8ef1 --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/001.worker.js @@ -0,0 +1,7 @@ +importScripts("/resources/testharness.js"); + +test(function() { + importScripts(); +}); + +done(); diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/002.worker.js b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/002.worker.js new file mode 100644 index 000000000..2cecbcb53 --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/002.worker.js @@ -0,0 +1,11 @@ +importScripts("/resources/testharness.js"); + +test(function() { + var ran = false; + assert_throws("SyntaxError", function() { + importScripts('data:text/javascript,ran=true','http://foo bar'); + }); + assert_false(ran, 'first argument to importScripts ran'); +}); + +done(); diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/003.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/003.html new file mode 100644 index 000000000..7ff30ae2a --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/003.html @@ -0,0 +1,28 @@ +<!-- +var x = 'a'; +try { + importScripts('data:text/javascript,x+="b"', + 'data:text/javascript,x+="c"'); +} catch(e) { + x += "d" +} +postMessage(x); +/* +--> +<!doctype html> +<title>importScripts running scripts</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +async_test(function() { + var worker = new Worker('#'); + worker.onmessage = this.step_func(function(e) { + assert_equals(e.data, "abc"); + this.done(); + }); +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/004.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/004.html new file mode 100644 index 000000000..2d39d3ce7 --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/004.html @@ -0,0 +1,34 @@ +<!-- +var x = ''; +var exception; +try { + importScripts('data:text/javascript,x+="first script successful. "', + 'data:text/javascript,x+="FAIL (second script). "; for(;) break;', // doesn't compile + 'data:text/javascript,x+="FAIL (third script)"'); +} catch(ex) { + if (ex instanceof SyntaxError) + exception = true; + else + exception = String(ex); +} +postMessage([x, exception]); +/* +--> +<!doctype html> +<title>importScripts broken script</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +async_test(function() { + var worker = new Worker('#'); + worker.onmessage = this.step_func(function(e) { + assert_equals(e.data[0], "first script successful. "); + assert_true(e.data[1], 'expected SyntaxError'); + this.done(); + }); +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/005.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/005.html new file mode 100644 index 000000000..f8abe14c2 --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/005.html @@ -0,0 +1,30 @@ +<!-- +var x; +var y; +try { + importScripts('data:text/javascript,x={', + 'data:text/javascript,}'); +} catch(e) { + y = true; +} +postMessage([x, y]); +/* +--> +<!doctype html> +<title>importScripts separate scripts</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +async_test(function() { + var worker = new Worker('#'); + worker.onmessage = this.step_func(function(e) { + assert_equals(e.data[0], undefined); + assert_true(e.data[1]); + this.done(); + }); +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/006.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/006.html new file mode 100644 index 000000000..06aea9696 --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/006.html @@ -0,0 +1,33 @@ +<!-- +var x; +var y; +var z; +try { + importScripts('data:text/javascript,x=1', + 'data:text/javascript,throw 2', + 'data:text/javascript,z=3'); +} catch(e) { + y = e; +} +postMessage([x, y, z]); +/* +--> +<!doctype html> +<title>importScripts uncaught exception</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +async_test(function() { + var worker = new Worker('#'); + worker.onmessage = this.step_func(function(e) { + assert_equals(e.data[0], 1); + assert_equals(e.data[1], 2); + assert_equals(e.data[2], undefined); + this.done(); + }); +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/007.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/007.html new file mode 100644 index 000000000..128fb1b64 --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/007.html @@ -0,0 +1,25 @@ +<!-- +importScripts('data:text/javascript,postMessage(1)'); +postMessage(2); +/* +--> +<!doctype html> +<title>postMessage in importScripts</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +async_test(function() { + var worker = new Worker('#'); + var i = 0; + worker.onmessage = this.step_func(function(e) { + i++; + assert_equals(e.data, i); + if (i == 2) + this.done(); + }); +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/008.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/008.html new file mode 100644 index 000000000..07b800ebb --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/008.html @@ -0,0 +1,23 @@ +<!-- +var log = postMessage; +importScripts('data:text/javascript,function run() { log(true) }'); +run(); +/* +--> +<!doctype html> +<title>variables and functions crossing importScripts boundary</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +async_test(function() { + var worker = new Worker('#'); + worker.onmessage = this.step_func(function(e) { + assert_true(e.data); + this.done(); + }); +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/009.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/009.html new file mode 100644 index 000000000..95d3839dc --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/009.html @@ -0,0 +1,29 @@ +<!-- +var log = postMessage; +importScripts('data:text/javascript,function run() { for(var i = 0; i < 1000; ++i) { if (i == 500) log(true); } return 1; }'); +postMessage(run()); +/* +--> +<!doctype html> +<title>variables and functions crossing importScripts boundary, take 2</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +async_test(function() { + var worker = new Worker('#'); + var i = 0; + worker.onmessage = this.step_func(function(e) { + i++; + if (i == 1) { + assert_true(e.data); + } else { + assert_equals(e.data, 1); + this.done(); + } + }); +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/010.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/010.html new file mode 100644 index 000000000..9c76e7d4d --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/010.html @@ -0,0 +1,34 @@ +<!-- +// prevent recursion +if ('beenThere' in self) { + throw 'undefined stringified to the empty string'; +} +beenThere = true; +try { + importScripts(undefined); + postMessage(got); +} catch(ex) { + postMessage(String(ex)); +} +/* +--> +<!doctype html> +<title>importScripts(undefined)</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +async_test(function() { + var worker = new Worker('#'); + worker.onmessage = this.step_func(function(e) { + assert_equals(e.data, 'undefined'); + this.done(); + }) + worker.onerror = this.step_func(function(e) { + assert_unreached(e.message); + }); +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/011.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/011.html new file mode 100644 index 000000000..46499318f --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/011.html @@ -0,0 +1,34 @@ +<!-- +// prevent recursion +if ('beenThere' in self) { + throw 'null stringified to the empty string'; +} +beenThere = true; +try { + importScripts(null); + postMessage(got); +} catch(ex) { + postMessage(String(ex)); +} +/* +--> +<!doctype html> +<title>importScripts(null)</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +async_test(function() { + var worker = new Worker('#'); + worker.onmessage = this.step_func(function(e) { + assert_equals(e.data, 'null'); + this.done(); + }); + worker.onerror = this.step_func(function(e) { + assert_unreached(e.message); + }); +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/012.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/012.html new file mode 100644 index 000000000..f7622bdc9 --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/012.html @@ -0,0 +1,34 @@ +<!-- +// prevent recursion +if ('beenThere' in self) { + throw '1 stringified to the empty string'; +} +beenThere = true; +try { + importScripts(1); + postMessage(got); +} catch(ex) { + postMessage(String(ex)); +} +/* +--> +<!doctype html> +<title>importScripts(1)</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +async_test(function() { + var worker = new Worker('#'); + worker.onmessage = this.step_func(function(e) { + assert_equals(e.data, '1'); + this.done(); + }); + worker.onerror = this.step_func(function(e) { + assert_unreached(e.message); + }); +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/1 b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/1 new file mode 100644 index 000000000..18cea4ff0 --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/1 @@ -0,0 +1 @@ +var got = '1';
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/null b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/null new file mode 100644 index 000000000..8e54b66c5 --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/null @@ -0,0 +1 @@ +var got = 'null';
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/undefined b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/undefined new file mode 100644 index 000000000..f99ba4be7 --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/undefined @@ -0,0 +1 @@ +var got = 'undefined';
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/002.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/002.html new file mode 100644 index 000000000..d3aa2ec65 --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/002.html @@ -0,0 +1,21 @@ +<!-- +postMessage(navigator.appName); +/* +--> +<!doctype html> +<title>navigator.appName</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +async_test(function() { + var worker = new Worker('#'); + worker.onmessage = this.step_func(function(e) { + assert_equals(e.data, navigator.appName); + this.done(); + }); +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/003.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/003.html new file mode 100644 index 000000000..a2e5c9487 --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/003.html @@ -0,0 +1,21 @@ +<!-- +postMessage(navigator.appVersion); +/* +--> +<!doctype html> +<title>navigator.appVersion</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +async_test(function() { + var worker = new Worker('#'); + worker.onmessage = this.step_func(function(e) { + assert_equals(e.data, navigator.appVersion); + this.done(); + }); +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/004.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/004.html new file mode 100644 index 000000000..2231c4ab8 --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/004.html @@ -0,0 +1,21 @@ +<!-- +postMessage(navigator.platform); +/* +--> +<!doctype html> +<title>navigator.platform</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +async_test(function() { + var worker = new Worker('#'); + worker.onmessage = this.step_func(function(e) { + assert_equals(e.data, navigator.platform); + this.done(); + }); +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/005.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/005.html new file mode 100644 index 000000000..b3d99588f --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/005.html @@ -0,0 +1,21 @@ +<!-- +postMessage(navigator.userAgent); +/* +--> +<!doctype html> +<title>navigator.userAgent</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +async_test(function() { + var worker = new Worker('#'); + worker.onmessage = this.step_func(function(e) { + assert_equals(e.data, navigator.userAgent); + this.done(); + }); +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/006.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/006.html new file mode 100644 index 000000000..c027d630d --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/006.html @@ -0,0 +1,21 @@ +<!-- +postMessage(navigator.onLine); +/* +--> +<!doctype html> +<title>navigator.onLine</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +async_test(function() { + var worker = new Worker('#'); + worker.onmessage = this.step_func(function(e) { + assert_equals(e.data, navigator.onLine); + this.done(); + }); +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/007.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/007.html new file mode 100644 index 000000000..a6afc5637 --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/007.html @@ -0,0 +1,30 @@ +<!-- +var log = []; +var neverEncounteredValue = "This is not the value you are looking for."; +for (x in navigator) { + // this should silently fail and not throw per webidl + navigator[x] = neverEncounteredValue; + if (navigator[x] === neverEncounteredValue) + log.push(x); +} +postMessage(log.join(', ')); +/* +--> +<!doctype html> +<title>readonlyness of members of Navigator</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +async_test(function() { + var worker = new Worker('#'); + worker.onmessage = this.step_func(function(e) { + assert_equals(e.data, ''); + this.done(); + }); +}); +</script> +<!-- +*/ +//--> + diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/language.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/language.html new file mode 100644 index 000000000..f1aa446cb --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/language.html @@ -0,0 +1,21 @@ +<!-- +postMessage(navigator.language); +/* +--> +<!doctype html> +<title>navigator.language</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +async_test(function() { + var worker = new Worker('#'); + worker.onmessage = this.step_func(function(e) { + assert_equals(e.data, navigator.language); + this.done(); + }); +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/window-only.worker.js b/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/window-only.worker.js new file mode 100644 index 000000000..7095281ec --- /dev/null +++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/window-only.worker.js @@ -0,0 +1,22 @@ +importScripts("/resources/testharness.js"); + +var properties = [ + "appCodeName", + "product", + "productSub", + "vendor", + "vendorSub", + + // Only exist in Window scopes if navigator compatibility mode is Gecko; + // never exist in workers. + "taintEnabled", + "oscpu", +]; + +properties.forEach(function(property) { + test(function() { + assert_false(property in navigator); + }, "NavigatorID properties exposed only for Window: " + property); +}); + +done(); |