diff options
Diffstat (limited to 'testing/web-platform/tests/workers/non-automated')
9 files changed, 98 insertions, 0 deletions
diff --git a/testing/web-platform/tests/workers/non-automated/infinite-nested.html b/testing/web-platform/tests/workers/non-automated/infinite-nested.html new file mode 100644 index 0000000000..3ff3edb353 --- /dev/null +++ b/testing/web-platform/tests/workers/non-automated/infinite-nested.html @@ -0,0 +1,12 @@ +<!doctype html> +<title>infinite nested workers</title> +<p>There number below should be increasing (ideally never-ending).</p> +<div>0</div> +<script> +var worker = new Worker('infinite-nested.js'); +var div = document.getElementsByTagName('div')[0]; +var i = 0; +worker.onmessage = function(e) { + div.textContent = i++; +} +</script>
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/non-automated/infinite-nested.js b/testing/web-platform/tests/workers/non-automated/infinite-nested.js new file mode 100644 index 0000000000..137dd0a2e2 --- /dev/null +++ b/testing/web-platform/tests/workers/non-automated/infinite-nested.js @@ -0,0 +1,5 @@ +postMessage(1); +var w = new Worker('infinite-nested.js'); +w.onmessage = function(e) { + postMessage(e.data); +}
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/non-automated/infinite-sibling-and-nested.html b/testing/web-platform/tests/workers/non-automated/infinite-sibling-and-nested.html new file mode 100644 index 0000000000..463546cc96 --- /dev/null +++ b/testing/web-platform/tests/workers/non-automated/infinite-sibling-and-nested.html @@ -0,0 +1,12 @@ +<!doctype html> +<title>infinite sibling and nested workers</title> +<p>The number below should be increasing (ideally never-ending).</p> +<div>0</div> +<script> +var worker = new Worker('infinite-sibling-and-nested.js'); +var div = document.getElementsByTagName('div')[0]; +var i = 0; +worker.onmessage = function(e) { + div.textContent = i + e.data; +} +</script> diff --git a/testing/web-platform/tests/workers/non-automated/infinite-sibling-and-nested.js b/testing/web-platform/tests/workers/non-automated/infinite-sibling-and-nested.js new file mode 100644 index 0000000000..cf7b794a41 --- /dev/null +++ b/testing/web-platform/tests/workers/non-automated/infinite-sibling-and-nested.js @@ -0,0 +1,8 @@ +function createWorker() { + var worker = new Worker('infinite-nested.js?' + Math.random()); + worker.onmessage = function(e) { + postMessage(e.data); + createWorker(); + } +} +createWorker();
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/non-automated/infinite-sibling.html b/testing/web-platform/tests/workers/non-automated/infinite-sibling.html new file mode 100644 index 0000000000..edcb8d7072 --- /dev/null +++ b/testing/web-platform/tests/workers/non-automated/infinite-sibling.html @@ -0,0 +1,12 @@ +<!doctype html> +<title>infinite sibling workers</title> +<p>The number below should be increasing (ideally never-ending).</p> +<div>0</div> +<script> +var worker = new Worker('infinite-sibling.js'); +var div = document.getElementsByTagName('div')[0]; +var i = 0; +worker.onmessage = function(e) { + div.textContent = i + e.data; +} +</script> diff --git a/testing/web-platform/tests/workers/non-automated/infinite-sibling.js b/testing/web-platform/tests/workers/non-automated/infinite-sibling.js new file mode 100644 index 0000000000..6424f70093 --- /dev/null +++ b/testing/web-platform/tests/workers/non-automated/infinite-sibling.js @@ -0,0 +1,8 @@ +function createWorker() { + var worker = new Worker('post-a-1.js?' + Math.random()); + worker.onmessage = function(e) { + postMessage(e.data); + createWorker(); + } +} +createWorker();
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/non-automated/navigator-onLine.html b/testing/web-platform/tests/workers/non-automated/navigator-onLine.html new file mode 100644 index 0000000000..5f2746b546 --- /dev/null +++ b/testing/web-platform/tests/workers/non-automated/navigator-onLine.html @@ -0,0 +1,29 @@ +<!doctype html> +<title>navigator.onLine in dedicated worker</title> +<pre>Log: +</pre> +<script> +var pre = document.querySelector('pre'); +var worker, shared; +try { worker = new Worker('navigator-onLine.js'); } catch(e) { pre.textContent += '\nnew Worker threw: ' + e.message; } +try { shared = new SharedWorker('#', ''); } catch(e) { pre.textContent += '\nnew SharedWorker threw: ' + e.message; } +if (worker) { + worker.onmessage = function(e) { + pre.textContent += '\ndedicated worker: ' + e.data; + } +} +if (shared) { + shared.port.onmessage = function(e) { + pre.textContent += '\nshared worker: ' + e.data; + } +} +function update() { + pre.textContent += '\n\n' + new Date() + '\n<script>: ' + navigator.onLine; + if (worker) worker.postMessage(1); + if (shared) shared.port.postMessage(1); +} +update(); +ononline = onoffline = update; +</script> +<p>As you go online and offline, the log should be filled with the correct status of navigator.onLine.</p> +<p><button onclick="update()">Check navigator.onLine status</button></p>
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/non-automated/navigator-onLine.js b/testing/web-platform/tests/workers/non-automated/navigator-onLine.js new file mode 100644 index 0000000000..592b286bb3 --- /dev/null +++ b/testing/web-platform/tests/workers/non-automated/navigator-onLine.js @@ -0,0 +1,11 @@ +if ('onmessage' in self) { // dedicated worker + onmessage = function(e) { + postMessage(navigator.onLine); + } +} else { // shared worker + onconnect = function(e) { + e.ports[0].onmessage = function(e) { + this.postMessage(navigator.onLine); + } + } +}
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/non-automated/post-a-1.js b/testing/web-platform/tests/workers/non-automated/post-a-1.js new file mode 100644 index 0000000000..2318c2e267 --- /dev/null +++ b/testing/web-platform/tests/workers/non-automated/post-a-1.js @@ -0,0 +1 @@ +postMessage(1);
\ No newline at end of file |