diff options
Diffstat (limited to 'testing/web-platform/tests/workers/constructors/SharedWorker')
23 files changed, 550 insertions, 0 deletions
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/1 b/testing/web-platform/tests/workers/constructors/SharedWorker/1 new file mode 100644 index 000000000..c3f67beea --- /dev/null +++ b/testing/web-platform/tests/workers/constructors/SharedWorker/1 @@ -0,0 +1,3 @@ +onconnect = function(e) { + e.ports[0].postMessage(['1', self.name]); +}
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/URLMismatchError.htm b/testing/web-platform/tests/workers/constructors/SharedWorker/URLMismatchError.htm new file mode 100644 index 000000000..e74e66072 --- /dev/null +++ b/testing/web-platform/tests/workers/constructors/SharedWorker/URLMismatchError.htm @@ -0,0 +1,19 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>Web Workers: SharedWorker - throw URLMismatchError</title> +<link rel="author" title="Intel" href="http://www.intel.com"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> + + test(function() { + var worker = new SharedWorker('shared-worker.js', 'name'); + + assert_throws("URLMismatchError", function() { + new SharedWorker('some-other-url.js', 'name'); + }); + + }, "Create SharedWorker with different URLs but same name"); + +</script> diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/connect-event.html b/testing/web-platform/tests/workers/constructors/SharedWorker/connect-event.html new file mode 100644 index 000000000..a9719d9de --- /dev/null +++ b/testing/web-platform/tests/workers/constructors/SharedWorker/connect-event.html @@ -0,0 +1,26 @@ +<!-- +onconnect = function(e) { + e.ports[0].postMessage([e.data === '', e instanceof MessageEvent, e.ports.length == 1]); +}; +/* +--> +<!doctype html> +<title>connect event</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 SharedWorker('#'); + worker.port.addEventListener('message', this.step_func(function(e) { + assert_true(e.data[0], "e.data === ''"); + assert_true(e.data[1], "e instanceof MessageEvent"); + assert_true(e.data[2], "e.ports.length == 1"); + this.done(); + }), false); + worker.port.start(); +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/dummy-name.html b/testing/web-platform/tests/workers/constructors/SharedWorker/dummy-name.html new file mode 100644 index 000000000..9e2732923 --- /dev/null +++ b/testing/web-platform/tests/workers/constructors/SharedWorker/dummy-name.html @@ -0,0 +1,17 @@ +<!-- +/* +--> +<!doctype html> +<title>creating a dummy shared worker with name "foo"</title> +<link rel=help href="http://www.whatwg.org/html/#dom-sharedworker"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +test(function() { + var worker = new SharedWorker('#', 'foo'); +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/dummy-shared-worker.html b/testing/web-platform/tests/workers/constructors/SharedWorker/dummy-shared-worker.html new file mode 100644 index 000000000..e9aff9c5b --- /dev/null +++ b/testing/web-platform/tests/workers/constructors/SharedWorker/dummy-shared-worker.html @@ -0,0 +1,17 @@ +<!-- +/* +--> +<!doctype html> +<title>creating a dummy shared worker</title> +<link rel=help href="http://www.whatwg.org/html/#dom-sharedworker"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +test(function() { + var worker = new SharedWorker('#'); +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/empty-name.html b/testing/web-platform/tests/workers/constructors/SharedWorker/empty-name.html new file mode 100644 index 000000000..95ff6d1ad --- /dev/null +++ b/testing/web-platform/tests/workers/constructors/SharedWorker/empty-name.html @@ -0,0 +1,17 @@ +<!-- +/* +--> +<!doctype html> +<title>creating a dummy shared worker with explicit name ""</title> +<link rel=help href="http://www.whatwg.org/html/#dom-sharedworker"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +test(function() { + var worker = new SharedWorker('#', ''); +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/global-members.html b/testing/web-platform/tests/workers/constructors/SharedWorker/global-members.html new file mode 100644 index 000000000..af4eb1d45 --- /dev/null +++ b/testing/web-platform/tests/workers/constructors/SharedWorker/global-members.html @@ -0,0 +1,34 @@ +<!-- +var expected = 'self location close onerror importScripts navigator addEventListener removeEventListener dispatchEvent name applicationCache onconnect setTimeout clearTimeout setInterval clearInterval'.split(' '); +var log = ''; +for (var i = 0; i < expected.length; ++i) { + if (!(expected[i] in self)) + log += expected[i] + ' did not exist\n'; +} +onconnect = function(e) { + e.ports[0].postMessage(log); +}; +/* +--> +<!doctype html> +<title>members of SharedWorkerGlobalScope</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 SharedWorker('#'); + worker.port.addEventListener('message', this.step_func(function(e) { + assert_equals(e.data, ''); + this.done(); + }), false); + worker.port.start(); +}); +</script> +<!-- +*/ +//--> + + + + diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/interface-objects.html b/testing/web-platform/tests/workers/constructors/SharedWorker/interface-objects.html new file mode 100644 index 000000000..e91b2dc6a --- /dev/null +++ b/testing/web-platform/tests/workers/constructors/SharedWorker/interface-objects.html @@ -0,0 +1,41 @@ +<!-- +var prt; +function handleCall(e) { + var log = []; + for (var i = 0; i < e.data.length; ++i) { + if (!(e.data[i] in self)) + log.push(e.data[i]); + } + prt.postMessage('These were missing: '+log.join(', ')); +} +onconnect = function(e) { + prt = e.ports[0]; + prt.onmessage = handleCall; +}; +/* +--> +<!doctype html> +<title>expected interface objects/constructors</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +(async_test()).step(function() { + var expected = 'XMLHttpRequest WebSocket EventSource MessageChannel Worker SharedWorker ApplicationCache'.split(' '); + var supported = []; + for (var i = 0; i < expected.length; ++i) { + if (expected[i] in window) + supported.push(expected[i]); + } + var worker = new SharedWorker('#'); + worker.port.start(); + worker.port.postMessage(supported); + worker.port.addEventListener('message', this.step_func(function(e) { + assert_equals(e.data, ''); + this.done(); + }), false); +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/name.html b/testing/web-platform/tests/workers/constructors/SharedWorker/name.html new file mode 100644 index 000000000..823e16c7c --- /dev/null +++ b/testing/web-platform/tests/workers/constructors/SharedWorker/name.html @@ -0,0 +1,24 @@ +<!-- +onconnect = function(e) { + e.ports[0].postMessage(self.name); +} +/* +--> +<!doctype html> +<title>self.name</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 SharedWorker('#', 'hello'); + worker.port.addEventListener('message', this.step_func(function(e) { + assert_equals(e.data, 'hello'); + this.done(); + }), false); + worker.port.start(); +}); +</script> +<!-- +*/ +//-->
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/no-arguments-ctor.html b/testing/web-platform/tests/workers/constructors/SharedWorker/no-arguments-ctor.html new file mode 100644 index 000000000..eaee870db --- /dev/null +++ b/testing/web-platform/tests/workers/constructors/SharedWorker/no-arguments-ctor.html @@ -0,0 +1,20 @@ +<!-- +/* +--> +<!doctype html> +<title>no arguments</title> +<link rel=help href="http://www.whatwg.org/html/#sharedworker"> +<link rel=help href="http://dev.w3.org/2006/webapi/WebIDL/#es-interface-call"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +test(function() { + assert_throws(new TypeError(), function() { + var worker = new SharedWorker(); + }); +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/null b/testing/web-platform/tests/workers/constructors/SharedWorker/null new file mode 100644 index 000000000..5c38505b6 --- /dev/null +++ b/testing/web-platform/tests/workers/constructors/SharedWorker/null @@ -0,0 +1,3 @@ +onconnect = function(e) { + e.ports[0].postMessage(['null', self.name]); +}
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/null-arguments.html b/testing/web-platform/tests/workers/constructors/SharedWorker/null-arguments.html new file mode 100644 index 000000000..c711b2cb5 --- /dev/null +++ b/testing/web-platform/tests/workers/constructors/SharedWorker/null-arguments.html @@ -0,0 +1,25 @@ +<!-- +onconnect = function(e) { + e.ports[0].postMessage(['FAIL', self.name]); +} +/* +--> +<!doctype html> +<title>null as arguments</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 SharedWorker(null, null); + worker.port.addEventListener('message', this.step_func(function(e) { + assert_equals(e.data[0], 'null', 'first arg'); + assert_equals(e.data[1], 'null', 'second arg'); + this.done(); + }), false); + worker.port.start(); +}); +</script> +<!-- +*/ +//-->
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/number-arguments.html b/testing/web-platform/tests/workers/constructors/SharedWorker/number-arguments.html new file mode 100644 index 000000000..1a4cfb2ea --- /dev/null +++ b/testing/web-platform/tests/workers/constructors/SharedWorker/number-arguments.html @@ -0,0 +1,25 @@ +<!-- +onconnect = function(e) { + e.ports[0].postMessage(['FAIL', self.name]); +} +/* +--> +<!doctype html> +<title>1 as arguments</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 SharedWorker(1, 1); + worker.port.addEventListener('message', this.step_func(function(e) { + assert_equals(e.data[0], '1', 'first arg'); + assert_equals(e.data[1], '1', 'second arg'); + this.done(); + }), false); + worker.port.start(); +}); +</script> +<!-- +*/ +//-->
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/port-onmessage.html b/testing/web-platform/tests/workers/constructors/SharedWorker/port-onmessage.html new file mode 100644 index 000000000..a2f4df0bf --- /dev/null +++ b/testing/web-platform/tests/workers/constructors/SharedWorker/port-onmessage.html @@ -0,0 +1,23 @@ +<!-- +onconnect = function(e) { + e.ports[0].postMessage(true); +} +/* +--> +<!doctype html> +<title>worker.port.onmessage</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 SharedWorker('#', ''); + worker.port.onmessage = this.step_func(function(e) { + assert_true(e.data); + this.done(); + }); +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/port-properties.html b/testing/web-platform/tests/workers/constructors/SharedWorker/port-properties.html new file mode 100644 index 000000000..f8a676dd2 --- /dev/null +++ b/testing/web-platform/tests/workers/constructors/SharedWorker/port-properties.html @@ -0,0 +1,26 @@ +<!-- +/* +--> +<!doctype html> +<title>worker.port</title> +<link rel=help href="http://www.whatwg.org/html/#sharedworker"> +<link rel=help href="http://www.whatwg.org/html/#messageport"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +test(function() { + var worker = new SharedWorker('#', ''); + assert_true('port' in worker, "port"); + assert_true('postMessage' in worker.port, "postMessage"); + assert_true('start' in worker.port, "start"); + assert_true('close' in worker.port, "close"); + assert_true('onmessage' in worker.port, "onmessage"); + assert_true('addEventListener' in worker.port, "addEventListener"); + assert_true('removeEventListener' in worker.port, "removeEventListener"); + assert_true('dispatchEvent' in worker.port, "dispatchEvent"); +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/port-readonly.html b/testing/web-platform/tests/workers/constructors/SharedWorker/port-readonly.html new file mode 100644 index 000000000..f087ab0f6 --- /dev/null +++ b/testing/web-platform/tests/workers/constructors/SharedWorker/port-readonly.html @@ -0,0 +1,21 @@ +<!-- +/* +--> +<!doctype html> +<title>setting worker.port</title> +<link rel=help href="http://www.whatwg.org/html/#sharedworker"> +<link rel=help href="http://dev.w3.org/2006/webapi/WebIDL/#dfn-attribute-setter"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +test(function() { + var worker = new SharedWorker('#', ''); + var x = worker.port; + worker.port = 1; + assert_equals(worker.port, x); +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/same-origin.html b/testing/web-platform/tests/workers/constructors/SharedWorker/same-origin.html new file mode 100644 index 000000000..2e0dd8db3 --- /dev/null +++ b/testing/web-platform/tests/workers/constructors/SharedWorker/same-origin.html @@ -0,0 +1,67 @@ +<!-- +/* +--> +<!doctype html> +<title>same-origin checks</title> +<link rel=help href="http://www.whatwg.org/html/#dom-sharedworker"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +// Needed to prevent a race condition if a worker throws an exception that may or may +// not propogate to the window before the tests finish +setup({allow_uncaught_exception: true}); + +function testSharedWorkerHelper(t, script) { + try { + var worker = new SharedWorker(script, ''); + worker.onerror = t.step_func_done(function(e) { + assert_true(e instanceof ErrorEvent); + }); + } catch (e) { + t.step_func_done(function(e) { assert_true(true); }); + } +} + +test(function() { + assert_throws("SecurityError", function() { new SharedWorker('unsupported:', ''); }); +}, "unsupported_scheme"); + +async_test(function() { + var worker = new SharedWorker('data:,onconnect = function(e) { e.ports[0].postMessage(1); }', ''); + worker.port.onmessage = this.step_func_done(function(e) { + assert_equals(e.data, 1); + }); +}, "data_url"); + +async_test(function(t) { + testSharedWorkerHelper(this, 'javascript:""'); +}, "javascript_url"); + +async_test(function(t) { + testSharedWorkerHelper(this, 'about:blank'); +}, "about_blank"); + +async_test(function(t) { + testSharedWorkerHelper(this, 'http://www.opera.com/'); +}, "opera_com"); + +async_test(function(t) { + testSharedWorkerHelper(this, location.protocol+'//'+location.hostname+':81/'); +}, "port_81"); + +async_test(function(t) { + testSharedWorkerHelper(this, 'https://'+location.hostname+':80/'); +}, "https_port_80"); + +async_test(function(t) { + testSharedWorkerHelper(this, 'https://'+location.hostname+':8000/'); +}, "https_port_8000"); + +async_test(function(t) { + testSharedWorkerHelper(this, 'http://'+location.hostname+':8012/'); +}, "http_port_8012"); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/setting-port-members.html b/testing/web-platform/tests/workers/constructors/SharedWorker/setting-port-members.html new file mode 100644 index 000000000..8c79ff295 --- /dev/null +++ b/testing/web-platform/tests/workers/constructors/SharedWorker/setting-port-members.html @@ -0,0 +1,59 @@ +<!-- +/* +--> +<!doctype html> +<title>setting members of worker.port</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +setup(function() { + window.worker = new SharedWorker('#', ''); +}); +test(function() { + worker.port.postMessage = 1; + assert_equals(worker.port.postMessage, 1); +}, 'postMessage'); +test(function() { + worker.port.start = 1; + assert_equals(worker.port.start, 1); +}, 'start'); +test(function() { + worker.port.close = 1; + assert_equals(worker.port.close, 1); +}, 'close'); +test(function() { + var f = function(){}; + worker.port.onmessage = f; + assert_equals(worker.port.onmessage, f, 'function(){}'); + worker.port.onmessage = 1; + assert_equals(worker.port.onmessage, null, '1'); + worker.port.onmessage = f; + worker.port.onmessage = ';'; + assert_equals(worker.port.onmessage, null, '";"'); + worker.port.onmessage = f; + worker.port.onmessage = {handleEvent:function(){}}; + assert_equals(worker.port.onmessage, null, '{handleEvent:function(){}}'); + worker.port.onmessage = f; + worker.port.onmessage = null; + assert_equals(worker.port.onmessage, null, 'null'); + worker.port.onmessage = f; + worker.port.onmessage = undefined; + assert_equals(worker.port.onmessage, null, 'undefined'); +}, 'onmessage'); +test(function() { + worker.port.addEventListener = 1; + assert_equals(worker.port.addEventListener, 1); +}, 'addEventListener'); +test(function() { + worker.port.removeEventListener = 1; + assert_equals(worker.port.removeEventListener, 1); +}, 'removeEventListener'); +test(function() { + worker.port.despatchEvent = 1; + assert_equals(worker.port.despatchEvent, 1); +}, 'despatchEvent'); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/shared-worker.js b/testing/web-platform/tests/workers/constructors/SharedWorker/shared-worker.js new file mode 100644 index 000000000..babebb1ce --- /dev/null +++ b/testing/web-platform/tests/workers/constructors/SharedWorker/shared-worker.js @@ -0,0 +1,6 @@ +onconnect = function(e) { + var port = e.ports[0]; + port.onmessage = function(e) { + port.postMessage('ping'); + } +} diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/undefined b/testing/web-platform/tests/workers/constructors/SharedWorker/undefined new file mode 100644 index 000000000..3fe840d30 --- /dev/null +++ b/testing/web-platform/tests/workers/constructors/SharedWorker/undefined @@ -0,0 +1,3 @@ +onconnect = function(e) { + e.ports[0].postMessage(['undefined', self.name]); +}
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/undefined-arguments.html b/testing/web-platform/tests/workers/constructors/SharedWorker/undefined-arguments.html new file mode 100644 index 000000000..b9a3b3692 --- /dev/null +++ b/testing/web-platform/tests/workers/constructors/SharedWorker/undefined-arguments.html @@ -0,0 +1,25 @@ +<!-- +onconnect = function(e) { + e.ports[0].postMessage(['FAIL', self.name]); +} +/* +--> +<!doctype html> +<title>undefined as arguments</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 SharedWorker(undefined, undefined); + worker.port.addEventListener('message', this.step_func(function(e) { + assert_equals(e.data[0], 'undefined', 'first arg'); + assert_equals(e.data[1], 'undefined', 'second arg'); + this.done(); + }), false); + worker.port.start(); +}); +</script> +<!-- +*/ +//-->
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/unexpected-global-properties.html b/testing/web-platform/tests/workers/constructors/SharedWorker/unexpected-global-properties.html new file mode 100644 index 000000000..39739022d --- /dev/null +++ b/testing/web-platform/tests/workers/constructors/SharedWorker/unexpected-global-properties.html @@ -0,0 +1,30 @@ +<!-- +var unexpected = 'open print stop getComputedStyle getSelection releaseEvents captureEvents alert confirm prompt addEventStream removeEventStream back forward attachEvent detachEvent navigate DOMParser XMLSerializer XPathEvaluator XSLTProcessor opera Image Option frames Audio SVGUnitTypes SVGZoomAndPan java netscape sun Packages ByteArray closed defaultStatus document event frameElement history innerHeight innerWidth opener outerHeight outerWidth pageXOffset pageYOffset parent screen screenLeft screenTop screenX screenY status top window length'.split(' '); // iterated window in opera and removed expected ones +var log = ''; +for (var i = 0; i < unexpected.length; ++i) { + if (unexpected[i] in self) + log += unexpected[i] + ' '; +} +onconnect = function(e) { + e.ports[0].postMessage(log); +}; +/* +--> +<!doctype html> +<title>unexpected members/interface objects/constructors</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 SharedWorker('#'); + worker.port.addEventListener('message', this.step_func(function(e) { + assert_equals(e.data, ''); + this.done(); + }), false); + worker.port.start(); +}); +</script> +<!-- +*/ +//--> diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/unresolvable-url.html b/testing/web-platform/tests/workers/constructors/SharedWorker/unresolvable-url.html new file mode 100644 index 000000000..2ca3d93d3 --- /dev/null +++ b/testing/web-platform/tests/workers/constructors/SharedWorker/unresolvable-url.html @@ -0,0 +1,19 @@ +<!-- +/* +--> +<!doctype html> +<title>resolving broken url</title> +<link rel=help href="http://www.whatwg.org/html/#dom-sharedworker"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +test(function() { + assert_throws("SyntaxError", function() { + var worker = new SharedWorker('http://foo bar'); + }); +}); +</script> +<!-- +*/ +//--> |