diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/workers/semantics | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/workers/semantics')
63 files changed, 1068 insertions, 0 deletions
diff --git a/testing/web-platform/tests/workers/semantics/encodings/001.html b/testing/web-platform/tests/workers/semantics/encodings/001.html new file mode 100644 index 0000000000..05ee5e006b --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/encodings/001.html @@ -0,0 +1,14 @@ +<!doctype html> +<title>encoding, dedicated worker</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('001.js'); + worker.onmessage = this.step_func(function(e) { + assert_equals(e.data, '\u00e5'); + this.done(); + }); +}); +</script>
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/semantics/encodings/001.js b/testing/web-platform/tests/workers/semantics/encodings/001.js new file mode 100644 index 0000000000..03bc557c33 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/encodings/001.js @@ -0,0 +1 @@ +postMessage('Ã¥');
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/semantics/encodings/001.js.headers b/testing/web-platform/tests/workers/semantics/encodings/001.js.headers new file mode 100644 index 0000000000..5614aaa7f0 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/encodings/001.js.headers @@ -0,0 +1 @@ +Content-Type: text/javascript; charset=windows-1252 diff --git a/testing/web-platform/tests/workers/semantics/encodings/002.html b/testing/web-platform/tests/workers/semantics/encodings/002.html new file mode 100644 index 0000000000..fecbffc18d --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/encodings/002.html @@ -0,0 +1,14 @@ +<!doctype html> +<title>encoding, shared worker</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +async_test(function() { + var worker = new SharedWorker('002.js', ''); + worker.port.onmessage = this.step_func(function(e) { + assert_equals(e.data, '\u00e5'); + this.done(); + }); +}); +</script> diff --git a/testing/web-platform/tests/workers/semantics/encodings/002.js b/testing/web-platform/tests/workers/semantics/encodings/002.js new file mode 100644 index 0000000000..9dde7bbda9 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/encodings/002.js @@ -0,0 +1,3 @@ +onconnect = function(e) { + e.ports[0].postMessage('Ã¥'); +}
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/semantics/encodings/002.js.headers b/testing/web-platform/tests/workers/semantics/encodings/002.js.headers new file mode 100644 index 0000000000..5614aaa7f0 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/encodings/002.js.headers @@ -0,0 +1 @@ +Content-Type: text/javascript; charset=windows-1252 diff --git a/testing/web-platform/tests/workers/semantics/encodings/003-1.py b/testing/web-platform/tests/workers/semantics/encodings/003-1.py new file mode 100644 index 0000000000..4f5df2bb10 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/encodings/003-1.py @@ -0,0 +1,4 @@ + # -*- coding: utf-8 -*- + +def main(request, response): + return u"PASS" if request.GET.first(b'x').decode('utf-8') == u'Ã¥' else u"FAIL" diff --git a/testing/web-platform/tests/workers/semantics/encodings/003.html b/testing/web-platform/tests/workers/semantics/encodings/003.html new file mode 100644 index 0000000000..095320e4d1 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/encodings/003.html @@ -0,0 +1,14 @@ +<!doctype html> +<title>URL encoding, dedicated worker</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('003.js'); + worker.onmessage = this.step_func(function(e) { + assert_true(e.data); + this.done(); + }); +}); +</script>
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/semantics/encodings/003.js b/testing/web-platform/tests/workers/semantics/encodings/003.js new file mode 100644 index 0000000000..35bda8bba8 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/encodings/003.js @@ -0,0 +1,5 @@ +var xhr = new XMLHttpRequest(); +xhr.open('GET', '003-1.py?x=Ã¥', false); +xhr.send(); +var passed = xhr.responseText == 'PASS'; +postMessage(passed);
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/semantics/encodings/004.html b/testing/web-platform/tests/workers/semantics/encodings/004.html new file mode 100644 index 0000000000..cd556b8190 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/encodings/004.html @@ -0,0 +1,14 @@ +<!doctype html> +<title>URL encoding, shared worker</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +async_test(function() { + var worker = new SharedWorker('004.js'); + worker.port.onmessage = this.step_func(function(e) { + assert_true(e.data); + this.done(); + }); +}); +</script>
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/semantics/encodings/004.js b/testing/web-platform/tests/workers/semantics/encodings/004.js new file mode 100644 index 0000000000..5146929a73 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/encodings/004.js @@ -0,0 +1,7 @@ +onconnect = function(e) { + var xhr = new XMLHttpRequest(); + xhr.open('GET', '003-1.py?x=Ã¥', false); + xhr.send(); + var passed = xhr.responseText == 'PASS'; + e.ports[0].postMessage(passed); +}
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/semantics/encodings/004.worker.js b/testing/web-platform/tests/workers/semantics/encodings/004.worker.js new file mode 100644 index 0000000000..28489a572b --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/encodings/004.worker.js @@ -0,0 +1,5 @@ +importScripts("/resources/testharness.js"); +test(function() { + assert_equals("ÿ", "\ufffd"); +}, "Decoding invalid utf-8"); +done(); diff --git a/testing/web-platform/tests/workers/semantics/interface-objects/001.worker.js b/testing/web-platform/tests/workers/semantics/interface-objects/001.worker.js new file mode 100644 index 0000000000..80fc597380 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/interface-objects/001.worker.js @@ -0,0 +1,83 @@ +importScripts("/resources/testharness.js"); +var expected = [ + // https://html.spec.whatwg.org/ + "WorkerGlobalScope", + "DedicatedWorkerGlobalScope", + "Worker", + "SharedWorker", + "MessagePort", + "MessageEvent", + "WorkerNavigator", + "MessageChannel", + "WorkerLocation", + "ImageData", + "ImageBitmap", + "CanvasGradient", + "CanvasPattern", + "CanvasPath", + "TextMetrics", + "Path2D", + "PromiseRejectionEvent", + "EventSource", + "BroadcastChannel", + // https://websockets.spec.whatwg.org/ + "WebSocket", + "CloseEvent", + // https://tc39.github.io/ecma262/ + "ArrayBuffer", + "Int8Array", + "Uint8Array", + "Uint8ClampedArray", + "Int16Array", + "Uint16Array", + "Int32Array", + "Uint32Array", + "Float32Array", + "Float64Array", + "DataView", + // https://xhr.spec.whatwg.org/ + "XMLHttpRequestEventTarget", + "XMLHttpRequestUpload", + "XMLHttpRequest", + "ProgressEvent", + "FormData", + // https://url.spec.whatwg.org/ + "URL", + "URLSearchParams", + // https://w3c.github.io/FileAPI/ + "File", + "Blob", + "FileList", + "FileReader", + "FileReaderSync", + // https://dom.spec.whatwg.org/ + "EventTarget", + "ErrorEvent", + "Event", + "CustomEvent", + // https://webidl.spec.whatwg.org/ + "DOMException", + // https://streams.spec.whatwg.org/ + "ReadableStream", + "WritableStream", + "ByteLengthQueuingStrategy", + "CountQueuingStrategy", + // http://w3c.github.io/IndexedDB/ + "IDBRequest", + "IDBOpenDBRequest", + "IDBVersionChangeEvent", + "IDBFactory", + "IDBDatabase", + "IDBObjectStore", + "IDBIndex", + "IDBKeyRange", + "IDBCursor", + "IDBCursorWithValue", + "IDBTransaction", +]; +for (var i = 0; i < expected.length; ++i) { + test(function () { + assert_own_property(self, expected[i]); + }, "The " + expected[i] + " interface object should be exposed."); +} +done(); diff --git a/testing/web-platform/tests/workers/semantics/interface-objects/002.worker.js b/testing/web-platform/tests/workers/semantics/interface-objects/002.worker.js new file mode 100644 index 0000000000..d4f48354ed --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/interface-objects/002.worker.js @@ -0,0 +1,43 @@ +importScripts("/resources/testharness.js"); +var unexpected = [ + // https://html.spec.whatwg.org/ + "SharedWorkerGlobalScope", + "AbstractView", + "AbstractWorker", + "ApplicationCache", + "Location", + "Navigator", + "Audio", + "HTMLCanvasElement", + "Path", + "CanvasProxy", + "CanvasRenderingContext2D", + "DrawingStyle", + "BeforeUnloadEvent", + "PopStateEvent", + "HashChangeEvent", + "PageTransitionEvent", + // https://dom.spec.whatwg.org/ + "DOMImplementation", + // http://w3c.github.io/IndexedDB/ + "IDBEnvironment", + // https://www.w3.org/TR/2010/NOTE-webdatabase-20101118/ + "Database", + // https://w3c.github.io/uievents/ + "UIEvent", + "FocusEvent", + "MouseEvent", + "WheelEvent", + "InputEvent", + "KeyboardEvent", + "CompositionEvent", + // https://w3c.github.io/webvtt/ + "VTTCue", + "VTTRegion", +]; +for (var i = 0; i < unexpected.length; ++i) { + test(function () { + assert_false(unexpected[i] in self); + }, "The " + unexpected[i] + " interface object should not be exposed."); +} +done(); diff --git a/testing/web-platform/tests/workers/semantics/interface-objects/003.any.js b/testing/web-platform/tests/workers/semantics/interface-objects/003.any.js new file mode 100644 index 0000000000..4d595bccce --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/interface-objects/003.any.js @@ -0,0 +1,84 @@ +// META: global=sharedworker + +var expected = [ + // https://html.spec.whatwg.org/ + "ApplicationCache", + "WorkerGlobalScope", + "SharedWorkerGlobalScope", + "Worker", + "SharedWorker", + "MessagePort", + "MessageEvent", + "WorkerNavigator", + "MessageChannel", + "WorkerLocation", + "ImageData", + "ImageBitmap", + "CanvasGradient", + "CanvasPattern", + "CanvasPath", + "Path2D", + "PromiseRejectionEvent", + "EventSource", + "BroadcastChannel", + // https://websockets.spec.whatwg.org/ + "WebSocket", + "CloseEvent", + // https://tc39.github.io/ecma262/ + "ArrayBuffer", + "Int8Array", + "Uint8Array", + "Uint8ClampedArray", + "Int16Array", + "Uint16Array", + "Int32Array", + "Uint32Array", + "Float32Array", + "Float64Array", + "DataView", + // https://xhr.spec.whatwg.org/ + "XMLHttpRequestEventTarget", + "XMLHttpRequestUpload", + "XMLHttpRequest", + "ProgressEvent", + "FormData", + // https://url.spec.whatwg.org/ + "URL", + "URLSearchParams", + // https://w3c.github.io/FileAPI/ + "File", + "Blob", + "FileList", + "FileReader", + "FileReaderSync", + // https://dom.spec.whatwg.org/ + "EventTarget", + "ErrorEvent", + "Event", + "CustomEvent", + // https://webidl.spec.whatwg.org/ + "DOMException", + // https://streams.spec.whatwg.org/ + "ReadableStream", + "WritableStream", + "ByteLengthQueuingStrategy", + "CountQueuingStrategy", + // http://w3c.github.io/IndexedDB/ + "IDBRequest", + "IDBOpenDBRequest", + "IDBVersionChangeEvent", + "IDBFactory", + "IDBDatabase", + "IDBObjectStore", + "IDBIndex", + "IDBKeyRange", + "IDBCursor", + "IDBCursorWithValue", + "IDBTransaction", +]; + +for (var i = 0; i < expected.length; ++i) { + test(function() { + assert_true(expected[i] in self); + }, "The " + expected[i] + " interface object should be exposed"); +} diff --git a/testing/web-platform/tests/workers/semantics/interface-objects/004.any.js b/testing/web-platform/tests/workers/semantics/interface-objects/004.any.js new file mode 100644 index 0000000000..822379e2c9 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/interface-objects/004.any.js @@ -0,0 +1,38 @@ +// META: global=sharedworker + +var unexpected = [ + // https://html.spec.whatwg.org/ + "DedicatedWorkerGlobalScope", + "AbstractView", + "AbstractWorker", + "Location", + "Navigator", + "DOMImplementation", + "Audio", + "HTMLCanvasElement", + "Path", + "CanvasProxy", + "CanvasRenderingContext2D", + "DrawingStyle", + "PopStateEvent", + "HashChangeEvent", + "PageTransitionEvent", + // http://w3c.github.io/IndexedDB/ + "IDBEnvironment", + // https://www.w3.org/TR/2010/NOTE-webdatabase-20101118/ + "Database", + // https://w3c.github.io/uievents/ + "UIEvent", + "FocusEvent", + "MouseEvent", + "WheelEvent", + "InputEvent", + "KeyboardEvent", + "CompositionEvent", +]; + +for (var i = 0; i < unexpected.length; ++i) { + test(function() { + assert_false(unexpected[i] in self); + }, "The " + unexpected[i] + " interface object should not be exposed"); +} diff --git a/testing/web-platform/tests/workers/semantics/multiple-workers/001.html b/testing/web-platform/tests/workers/semantics/multiple-workers/001.html new file mode 100644 index 0000000000..f9e2bbeaba --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/multiple-workers/001.html @@ -0,0 +1,23 @@ +<!doctype html> +<title>dedicated and shared worker in same page</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('001.js'); + worker.onmessage = this.step_func(function(e) { + assert_equals(e.data, 'dedicated'); + this.done(); + }); + worker.postMessage('dedicated'); +}, 'dedicated'); +async_test(function() { + var shared = new SharedWorker('001.js', ''); + shared.port.onmessage = this.step_func(function(e) { + assert_equals(e.data, 'shared'); + this.done(); + }); + shared.port.postMessage('shared'); +}, 'shared'); +</script>
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/semantics/multiple-workers/001.js b/testing/web-platform/tests/workers/semantics/multiple-workers/001.js new file mode 100644 index 0000000000..6d51169dea --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/multiple-workers/001.js @@ -0,0 +1,11 @@ +if ('onmessage' in self) { // dedicated worker + onmessage = function(e) { + postMessage(e.data); + } +} else { // shared worker + onconnect = function(e) { + e.ports[0].onmessage = function(e) { + this.postMessage(e.data); + } + } +}
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/semantics/multiple-workers/002.html b/testing/web-platform/tests/workers/semantics/multiple-workers/002.html new file mode 100644 index 0000000000..aa01e361d8 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/multiple-workers/002.html @@ -0,0 +1,21 @@ +<!doctype html> +<title>creating 3 sibling dedicated workers</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +async_test(function(t) { + var w1 = new Worker('002.js'); + var w2 = new Worker('002.js'); + var w3 = new Worker('002.js'); + var got = [false, false, false]; + var check_done = t.step_func(function() { + if (got.every(function(x) {return x})) { + t.done(); + } + }); + w1.onmessage = t.step_func(function(e) {got[0] = true; check_done()}); + w2.onmessage = t.step_func(function(e) {got[1] = true; check_done()}); + w3.onmessage = t.step_func(function(e) {got[2] = true; check_done()}); +}); +</script>
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/semantics/multiple-workers/002.js b/testing/web-platform/tests/workers/semantics/multiple-workers/002.js new file mode 100644 index 0000000000..2318c2e267 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/multiple-workers/002.js @@ -0,0 +1 @@ +postMessage(1);
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/semantics/multiple-workers/003.html b/testing/web-platform/tests/workers/semantics/multiple-workers/003.html new file mode 100644 index 0000000000..f6e03c75f7 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/multiple-workers/003.html @@ -0,0 +1,16 @@ +<!doctype html> +<title>creating 3 nested dedicated workers</title> +<meta name="timeout" content="long"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +async_test(function() { + var w1 = new Worker('003.js#1'); + w1.onmessage = this.step_func(function(e) { + assert_equals(e.data, '123'); + this.done(); + }); + w1.onerror = this.unreached_func("error"); +}); +</script> diff --git a/testing/web-platform/tests/workers/semantics/multiple-workers/003.js b/testing/web-platform/tests/workers/semantics/multiple-workers/003.js new file mode 100644 index 0000000000..14a5a614b3 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/multiple-workers/003.js @@ -0,0 +1,13 @@ +if (location.hash == '#1') { + var w2 = new Worker('003.js#2'); + w2.onmessage = function(e) { + postMessage('1'+e.data); + } +} else if (location.hash == '#2') { + var w3 = new Worker('003.js#3'); + w3.onmessage = function(e) { + postMessage('2'+e.data); + } +} else { + postMessage('3'); +} diff --git a/testing/web-platform/tests/workers/semantics/multiple-workers/004-1.html b/testing/web-platform/tests/workers/semantics/multiple-workers/004-1.html new file mode 100644 index 0000000000..eac038c5be --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/multiple-workers/004-1.html @@ -0,0 +1,7 @@ +<!doctype html> +<title></title> +<script> +window.onload = function() { + var w=new SharedWorker('004-2.js', 'x'); +}; +</script> diff --git a/testing/web-platform/tests/workers/semantics/multiple-workers/004-2.js b/testing/web-platform/tests/workers/semantics/multiple-workers/004-2.js new file mode 100644 index 0000000000..e59cd6927e --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/multiple-workers/004-2.js @@ -0,0 +1,6 @@ +var port; +onconnect = function(e) { + if (!port) + port = e.ports[0]; + port.postMessage(1); +}
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/semantics/multiple-workers/004.html b/testing/web-platform/tests/workers/semantics/multiple-workers/004.html new file mode 100644 index 0000000000..552cc8a633 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/multiple-workers/004.html @@ -0,0 +1,37 @@ +<!doctype html> +<title>shared worker with multiple documents</title> +<meta name="timeout" content="long"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +setup({ single_test: true }); + +var i = 0; +var load_count = 0; + +var w1 = new SharedWorker('004-2.js', 'x'); +w1.port.onmessage = function(e) { + i++; + check_result(); +}; + + +function iframe_loaded() { + load_count++; + check_result(); +} + +function check_result() { + //timeout to allow for extra, unexpected, messages to arrive + if (i == 3 && load_count == 2) { + setTimeout(function() { + assert_equals(load_count, 2); + assert_equals(i, 3); + done(); + }, 500); + } +} +</script> +<iframe src=004-1.html onload="iframe_loaded()"></iframe> +<iframe src=004-1.html onload="iframe_loaded()"></iframe> diff --git a/testing/web-platform/tests/workers/semantics/multiple-workers/008-1.html b/testing/web-platform/tests/workers/semantics/multiple-workers/008-1.html new file mode 100644 index 0000000000..d19d7fa336 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/multiple-workers/008-1.html @@ -0,0 +1,8 @@ +<!doctype html> +<title>008-1</title> +<script> +var w1 = new SharedWorker('008.js'); +w1.port.onmessage = function(e) { + e.ports[0].postMessage(2); +} +</script>
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/semantics/multiple-workers/008.html b/testing/web-platform/tests/workers/semantics/multiple-workers/008.html new file mode 100644 index 0000000000..ee38d80866 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/multiple-workers/008.html @@ -0,0 +1,19 @@ +<!doctype html> +<title>messagechannel in shared worker</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<iframe src=008-1.html></iframe> +<script> +var t = async_test(); +onload = t.step_func(function() { + var w1 = new SharedWorker('008.js'); + w1.port.onmessage = this.step_func(function(e) { + e.ports[0].onmessage = this.step_func(function(e) { + assert_equals(e.data, 2); + this.done(); + }); + }); + w1.onerror = this.unreached_func("error"); +}); +</script>
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/semantics/multiple-workers/008.js b/testing/web-platform/tests/workers/semantics/multiple-workers/008.js new file mode 100644 index 0000000000..92593ebb86 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/multiple-workers/008.js @@ -0,0 +1,6 @@ +var channel = new MessageChannel(); +var i = 0; +onconnect = function(e) { + i++; + e.ports[0].postMessage(1, [channel['port' + i]]); +}
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/semantics/multiple-workers/exposure.any.js b/testing/web-platform/tests/workers/semantics/multiple-workers/exposure.any.js new file mode 100644 index 0000000000..7e226a7333 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/multiple-workers/exposure.any.js @@ -0,0 +1,11 @@ +// META: global=window,worker + +test(() => { + const assert = "ServiceWorkerGlobalScope" in globalThis ? assert_equals : assert_not_equals; + assert(globalThis.Worker, undefined); +}, "Worker exposure"); + +test(() => { + const assert = globalThis.GLOBAL.isWindow() ? assert_not_equals : assert_equals; + assert(globalThis.SharedWorker, undefined); +}, "SharedWorker exposure"); diff --git a/testing/web-platform/tests/workers/semantics/navigation/001-1.html b/testing/web-platform/tests/workers/semantics/navigation/001-1.html new file mode 100644 index 0000000000..c259c2c839 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/navigation/001-1.html @@ -0,0 +1,15 @@ +<!doctype html> +<title>001-1</title> +<script> +onload = function() { + var worker = new Worker('001-1.js'); + worker.onmessage = function(e) { + var started = !!parent.date; + parent.date = e.data; + if (!started) { + parent.start_test() + } + } +} +</script> +<a href='data:text/html,<title>foo</title><script>onload=function(){window.parent.postMessage({title: window.document.title}, "*")}</script>'>link</a>
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/semantics/navigation/001-1.js b/testing/web-platform/tests/workers/semantics/navigation/001-1.js new file mode 100644 index 0000000000..f62c365e32 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/navigation/001-1.js @@ -0,0 +1 @@ +setInterval(function() { postMessage(new Date()) }, 10)
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/semantics/navigation/001.html b/testing/web-platform/tests/workers/semantics/navigation/001.html new file mode 100644 index 0000000000..f31c2590e5 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/navigation/001.html @@ -0,0 +1,39 @@ +<!-- + +/* +--> +<!doctype html> +<title>navigating</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +setup({ single_test: true }); +var date; +var newDate; +</script> +<iframe></iframe> +<script> +var iframe = document.querySelector('iframe'); +onload = function() { + iframe.src = "001-1.html?" + Math.random(); +}; +var start_test = function() { + window[0].document.links[0].click(); +}; +var after_load = function(event) { + history.back(); + newDate = new Date(); + setTimeout(function() { + assert_greater_than(Number(date), Number(newDate)); + assert_equals(window[0].document.title, '001-1'); + window.removeEventListener("message", after_load); + done(); + }, 2000); +}; +window.addEventListener("message", after_load); +</script> +<!-- +*/ +//--> + diff --git a/testing/web-platform/tests/workers/semantics/navigation/002.html b/testing/web-platform/tests/workers/semantics/navigation/002.html new file mode 100644 index 0000000000..8ea98ef2d4 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/navigation/002.html @@ -0,0 +1,38 @@ +<!-- + +/* +--> +<!doctype html> +<title>navigating 2</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +var date; +var newDate; +</script> +<iframe></iframe> +<script> +var t = async_test(); +var iframe = document.querySelector('iframe'); +onload = t.step_func(function() { + iframe.src = "001-1.html?" + Math.random(); +}); +var start_test = t.step_func(function() { + window[0].document.links[0].click(); +}); +var after_load = t.step_func(function(event) { + newDate = new Date(); + setTimeout(this.step_func(function() { + assert_less_than(Number(date), Number(newDate)); + assert_equals(event.data.title, 'foo'); + window.removeEventListener("message", after_load); + this.done(); + }), 500); +}); +window.addEventListener("message", after_load); +</script> +<!-- +*/ +//--> + diff --git a/testing/web-platform/tests/workers/semantics/reporting-errors/001.html b/testing/web-platform/tests/workers/semantics/reporting-errors/001.html new file mode 100644 index 0000000000..d8b17289fe --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/reporting-errors/001.html @@ -0,0 +1,17 @@ +<!doctype html> +<title>shared worker, not handled</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() { + window.onerror = this.step_func(function(a) { + assert_unreached('window.onerror invoked: ' + a); + }); + var worker = new SharedWorker('001.js', ''); + worker.port.onmessage = this.step_func_done(function(e) { + assert_equals(e.data, ''); + }); +}); +</script> diff --git a/testing/web-platform/tests/workers/semantics/reporting-errors/001.js b/testing/web-platform/tests/workers/semantics/reporting-errors/001.js new file mode 100644 index 0000000000..5736666cc3 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/reporting-errors/001.js @@ -0,0 +1,28 @@ +var port; +var timeout; +onerror = function(a,b,c,d,e) { + // will return undefined, thus the error is "not handled" + // so error should be reported to the user, but this test doesn't check + // that. + // just make sure that this method is invoked with five arguments + clearTimeout(timeout); + var log = ''; + if (arguments.length != 5) + log += 'got ' + arguments.length + ' arguments, expected 5. '; + if (typeof a != 'string') + log += 'first argument wasn\'t a string. '; + if (b != location.href) + log += 'second argument was ' + b + ', expected ' + location.href + '. '; + if (typeof c != 'number') + log += 'third argument wasn\'t a number. '; + if (typeof d != 'number') + log += 'fourth argument wasn\'t a number. '; + if (e != 42) + log += 'fifth argument wasn\'t the thrown exception. '; + port.postMessage(log); +} +onconnect = function (e) { + port = e.ports[0]; + timeout = setTimeout(function() { port.postMessage('self.onerror was not invoked'); }, 250); + throw 42; // will "report the error" +} diff --git a/testing/web-platform/tests/workers/semantics/reporting-errors/002.html b/testing/web-platform/tests/workers/semantics/reporting-errors/002.html new file mode 100644 index 0000000000..4b322a5f07 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/reporting-errors/002.html @@ -0,0 +1,17 @@ +<!doctype html> +<title>shared worker, addEventListener</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() { + window.onerror = this.step_func(function(a) { + assert_unreached('window.onerror invoked: ' + a); + }); + var worker = new SharedWorker('002.js', ''); + worker.port.onmessage = this.step_func_done(function(e) { + assert_equals(e.data, ''); + }); +}); +</script> diff --git a/testing/web-platform/tests/workers/semantics/reporting-errors/002.js b/testing/web-platform/tests/workers/semantics/reporting-errors/002.js new file mode 100644 index 0000000000..ff96922634 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/reporting-errors/002.js @@ -0,0 +1,34 @@ +var port; +var timeout; +addEventListener('error', function(e) { + // event is not canceled, thus the error is "not handled" + // so error should be reported to the user, but this test doesn't check + // that. + // just make sure that this event has the right properties + clearTimeout(timeout); + var log = ''; + if (!self.ErrorEvent || Object.getPrototypeOf(e) != ErrorEvent.prototype) + log += 'event should be an ErrorEvent. '; + if (e.bubbles) + log += 'event should not bubble. '; + if (!e.cancelable) + log += 'event should be cancelable. '; + if (!e.isTrusted) + log += 'event should be trusted. '; + if (typeof e.message != 'string') + log += 'message wasn\'t a string. '; + if (e.filename != location.href) + log += 'filename was ' + e.filename + ', expected ' + location.href + '. '; + if (typeof e.lineno != 'number') + log += 'lineno wasn\'t a number. '; + if (typeof e.colno != 'number') + log += 'colno argument wasn\'t a number. '; + if (e.error != 42) + log += 'fifth argument wasn\'t the thrown exception. '; + port.postMessage(log); +}, false); +onconnect = function (e) { + port = e.ports[0]; + timeout = setTimeout(function() { port.postMessage('No error event fired'); }, 250); + throw 42; // will "report the error" +} diff --git a/testing/web-platform/tests/workers/semantics/reporting-errors/003.html b/testing/web-platform/tests/workers/semantics/reporting-errors/003.html new file mode 100644 index 0000000000..8ea59b8106 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/reporting-errors/003.html @@ -0,0 +1,23 @@ +<!doctype html> +<title>shared worker, no error event on worker or port</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() { + window.onerror = this.step_func(function(a) { + assert_unreached('window.onerror invoked: ' + a); + }); + var worker = new SharedWorker('003.js', ''); + worker.addEventListener('error', this.step_func(function(e) { + assert_unreached('error on worker'); + }), false); + worker.port.addEventListener('error', this.step_func(function(e) { + assert_unreached('error on port'); + }), false); + worker.port.onmessage = this.step_func_done(function(e) { + assert_equals(e.data, ''); + }); +}); +</script> diff --git a/testing/web-platform/tests/workers/semantics/reporting-errors/003.js b/testing/web-platform/tests/workers/semantics/reporting-errors/003.js new file mode 100644 index 0000000000..8a3390bb24 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/reporting-errors/003.js @@ -0,0 +1,8 @@ +onconnect = function (e) { + setTimeout(function() { e.ports[0].postMessage(''); }, 250); + y(); // will "report the error" + // onerror is null so it'll be "not handled", and the error should be + // reported to the user, although we don't test that here + // make sure we don't fire an error event on the message port or the + // SharedWorker object +} diff --git a/testing/web-platform/tests/workers/semantics/reporting-errors/004-1.html b/testing/web-platform/tests/workers/semantics/reporting-errors/004-1.html new file mode 100644 index 0000000000..326e1399ec --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/reporting-errors/004-1.html @@ -0,0 +1,18 @@ +<!doctype html> +<script> +parent.t.step(function() { + window.onerror = this.step_func(function(a) { + assert_unreached('(inner) window.onerror invoked: ' + a); + }); + var worker = new SharedWorker('004.js', ''); + worker.addEventListener('error', this.step_func(function(e) { + parent.assert_unreached('(inner) error on worker'); + }), false); + worker.port.addEventListener('error', this.step_func(function(e) { + parent.assert_unreached('(inner) error on port'); + }), false); + worker.port.onmessage = this.step_func_done(function(e) { + parent.assert_equals(e.data, 2); + }); +}); +</script> diff --git a/testing/web-platform/tests/workers/semantics/reporting-errors/004.html b/testing/web-platform/tests/workers/semantics/reporting-errors/004.html new file mode 100644 index 0000000000..8516e52c6f --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/reporting-errors/004.html @@ -0,0 +1,26 @@ +<!doctype html> +<title>shared worker in two documents and window.onerror</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +setup({allow_uncaught_exception:true}); +var t = async_test(function() { + window.onerror = this.step_func(function(a) { + assert_unreached('(outer) window.onerror invoked: ' + a); + }); + var worker = new SharedWorker('004.js', ''); + worker.addEventListener('error', this.step_func(function(e) { + assert_unreached('(outer) error on worker'); + }), false); + worker.port.addEventListener('error', this.step_func(function(e) { + assert_unreached('(outer) error on port'); + }), false); + worker.port.onmessage = this.step_func(function(e) { + assert_equals(e.data, 1); + var iframe = document.createElement('iframe'); + iframe.src = '004-1.html'; + document.body.appendChild(iframe); + }); +}); +</script> diff --git a/testing/web-platform/tests/workers/semantics/reporting-errors/004.js b/testing/web-platform/tests/workers/semantics/reporting-errors/004.js new file mode 100644 index 0000000000..a68d2ab01d --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/reporting-errors/004.js @@ -0,0 +1,6 @@ +var i = 0; +onconnect = function (e) { + i++; + setTimeout(function() { e.ports[0].postMessage(i); }, 250); + y(); // will "report the error" +} diff --git a/testing/web-platform/tests/workers/semantics/run-a-worker/001.html b/testing/web-platform/tests/workers/semantics/run-a-worker/001.html new file mode 100644 index 0000000000..71e48c2771 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/run-a-worker/001.html @@ -0,0 +1,14 @@ +<!doctype html> +<title>worker global scope, dedicated worker</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('001.js'); + worker.onmessage = this.step_func(function(e) { + assert_true(e.data); + this.done(); + }); +}); +</script>
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/semantics/run-a-worker/001.js b/testing/web-platform/tests/workers/semantics/run-a-worker/001.js new file mode 100644 index 0000000000..33ed47f1b4 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/run-a-worker/001.js @@ -0,0 +1 @@ +postMessage(this === self);
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/semantics/run-a-worker/002.html b/testing/web-platform/tests/workers/semantics/run-a-worker/002.html new file mode 100644 index 0000000000..9487d886a6 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/run-a-worker/002.html @@ -0,0 +1,14 @@ +<!doctype html> +<title>worker global scope, shared worker</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +async_test(function() { + var worker = new SharedWorker('002.js'); + worker.port.onmessage = this.step_func(function(e) { + assert_true(e.data); + this.done(); + }); +}); +</script>
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/semantics/run-a-worker/002.js b/testing/web-platform/tests/workers/semantics/run-a-worker/002.js new file mode 100644 index 0000000000..627272aaef --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/run-a-worker/002.js @@ -0,0 +1,4 @@ +var passed = this === self; +onconnect = function(e) { + e.ports[0].postMessage(passed); +}
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/semantics/run-a-worker/003.html b/testing/web-platform/tests/workers/semantics/run-a-worker/003.html new file mode 100644 index 0000000000..e96c176f20 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/run-a-worker/003.html @@ -0,0 +1,15 @@ +<!doctype html> +<title>handling for 404 response</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +async_test(t => { + const worker = new Worker('404_worker'); + worker.onerror = e => t.done(); +}, 'worker'); + +async_test(t => { + const shared = new SharedWorker('404_shared'); + shared.onerror = e => t.done(); +}, 'shared'); +</script> diff --git a/testing/web-platform/tests/workers/semantics/structured-clone/dedicated.html b/testing/web-platform/tests/workers/semantics/structured-clone/dedicated.html new file mode 100644 index 0000000000..16b6be56f1 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/structured-clone/dedicated.html @@ -0,0 +1,33 @@ +<!doctype html> +<title>structured clone to dedicated worker</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src=/common/sab.js></script> +<script src=/html/webappapis/structured-clone/structured-clone-battery-of-tests.js></script> +<script src=/html/webappapis/structured-clone/structured-clone-battery-of-tests-with-transferables.js></script> +<script src=/html/webappapis/structured-clone/structured-clone-battery-of-tests-harness.js></script> +<div id=log></div> +<script> + runStructuredCloneBatteryOfTests({ + setup() { + const blob = new Blob([` + onmessage = ev => postMessage(ev.data, ev.data.transfer); + `], {type: 'text/javascript'}); + this.blobURL = URL.createObjectURL(blob); + this.worker = new Worker(this.blobURL); + }, + structuredClone(data, transfer) { + return new Promise(resolve => { + this.worker.addEventListener('message', function f(ev) { + this.worker.removeEventListener('message', f); + resolve(ev.data.data); + }.bind(this)); + this.worker.postMessage({data, transfer}, transfer); + }); + }, + teardown() { + this.worker.terminate(); + URL.revokeObjectURL(this.blobURL); + } + }); +</script> diff --git a/testing/web-platform/tests/workers/semantics/structured-clone/shared.html b/testing/web-platform/tests/workers/semantics/structured-clone/shared.html new file mode 100644 index 0000000000..eb85499fe2 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/structured-clone/shared.html @@ -0,0 +1,37 @@ +<!doctype html> +<title>structured clone to shared worker</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src=/common/sab.js></script> +<script src=/html/webappapis/structured-clone/structured-clone-battery-of-tests.js></script> +<script src=/html/webappapis/structured-clone/structured-clone-battery-of-tests-with-transferables.js></script> +<script src=/html/webappapis/structured-clone/structured-clone-battery-of-tests-harness.js></script> +<div id=log></div> +<script> + runStructuredCloneBatteryOfTests({ + setup() { + const blob = new Blob([` + onconnect = ev => { + const port = ev.ports[0]; + port.onmessage = ev => port.postMessage(ev.data, ev.data.transfer); + }; + `], {type: 'text/javascript'}); + this.blobURL = URL.createObjectURL(blob); + this.worker = new SharedWorker(this.blobURL); + this.port = this.worker.port; + }, + structuredClone(data, transfer) { + return new Promise(resolve => { + this.port.addEventListener('message', function f(ev) { + this.port.removeEventListener('message', f); + resolve(ev.data.data); + }.bind(this)); + this.port.start(); + this.port.postMessage({data, transfer}, transfer); + }); + }, + teardown() { + URL.revokeObjectURL(this.blobURL); + } + }); +</script> diff --git a/testing/web-platform/tests/workers/semantics/xhr/001-1.xml b/testing/web-platform/tests/workers/semantics/xhr/001-1.xml new file mode 100644 index 0000000000..5d735bdf61 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/xhr/001-1.xml @@ -0,0 +1 @@ +<x>foo</x>
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/semantics/xhr/001.html b/testing/web-platform/tests/workers/semantics/xhr/001.html new file mode 100644 index 0000000000..da59f5ac2d --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/xhr/001.html @@ -0,0 +1,16 @@ +<!doctype html> +<title>async XMLHttpRequest in dedicated worker</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +var t = async_test(); +function runtest() { + var worker = new Worker('001.js'); + worker.onmessage = this.step_func(function(e) { + assert_equals(e.data, ''); + this.done(); + }); +} +</script> +<iframe src=001-1.xml onload="t.step(runtest);"></iframe>
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/semantics/xhr/001.js b/testing/web-platform/tests/workers/semantics/xhr/001.js new file mode 100644 index 0000000000..1cbe98ba47 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/xhr/001.js @@ -0,0 +1,13 @@ +var xhr = new XMLHttpRequest(); +var log = ''; +xhr.onreadystatechange = function(e) { + if (this.readyState == 4) { + if (this.responseXML != null) + log += 'responseXML was not null. '; + if (this.responseText != '<x>foo</x>') + log += 'responseText was ' + this.responseText + ', expected <x>foo</x>. '; + postMessage(log); + } +} +xhr.open('GET', '001-1.xml', true); +xhr.send();
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/semantics/xhr/002.html b/testing/web-platform/tests/workers/semantics/xhr/002.html new file mode 100644 index 0000000000..60c0e161cc --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/xhr/002.html @@ -0,0 +1,16 @@ +<!doctype html> +<title>sync XMLHttpRequest in dedicated worker</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +var t = async_test(); +function runtest() { + var worker = new Worker('002.js'); + worker.onmessage = this.step_func(function(e) { + assert_equals(e.data, ''); + this.done(); + }); +} +</script> +<iframe src=001-1.xml onload="t.step(runtest);"></iframe>
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/semantics/xhr/002.js b/testing/web-platform/tests/workers/semantics/xhr/002.js new file mode 100644 index 0000000000..68d7e91d45 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/xhr/002.js @@ -0,0 +1,9 @@ +var xhr = new XMLHttpRequest(); +var log = ''; +xhr.open('GET', '001-1.xml', false); +xhr.send(); +if (xhr.responseXML != null) + log += 'responseXML was not null. '; +if (xhr.responseText != '<x>foo</x>') + log += 'responseText was ' + this.responseText + ', expected <x>foo</x>. '; +postMessage(log);
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/semantics/xhr/003.html b/testing/web-platform/tests/workers/semantics/xhr/003.html new file mode 100644 index 0000000000..e3ce36b82c --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/xhr/003.html @@ -0,0 +1,16 @@ +<!doctype html> +<title>async XMLHttpRequest in shared worker</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +var t = async_test(); +function runtest() { + var worker = new SharedWorker('003.js', ''); + worker.port.onmessage = this.step_func(function(e) { + assert_equals(e.data, ''); + this.done(); + }); +} +</script> +<iframe src=001-1.xml onload="t.step(runtest);"></iframe> diff --git a/testing/web-platform/tests/workers/semantics/xhr/003.js b/testing/web-platform/tests/workers/semantics/xhr/003.js new file mode 100644 index 0000000000..1a9c5a7ee8 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/xhr/003.js @@ -0,0 +1,17 @@ +onconnect = function(e) { + var xhr = new XMLHttpRequest(); + var log = ''; + var port = e.ports[0]; + var postMessage = port.postMessage; + xhr.onreadystatechange = function(e) { + if (this.readyState == 4) { + if (this.responseXML != null) + log += 'responseXML was not null. '; + if (this.responseText && this.responseText != '<x>foo</x>') + log += 'responseText was ' + this.responseText + ', expected <x>foo</x>. '; + postMessage.call(port, log); + } + } + xhr.open('GET', '001-1.xml', true); + xhr.send(); +} diff --git a/testing/web-platform/tests/workers/semantics/xhr/004.html b/testing/web-platform/tests/workers/semantics/xhr/004.html new file mode 100644 index 0000000000..d11e3dbc1b --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/xhr/004.html @@ -0,0 +1,16 @@ +<!doctype html> +<title>sync XMLHttpRequest in shared worker</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +var t = async_test(); +function runtest() { + var worker = new SharedWorker('004.js', ''); + worker.port.onmessage = this.step_func(function(e) { + assert_equals(e.data, ''); + this.done(); + }); +} +</script> +<iframe src=001-1.xml onload="t.step(runtest);"></iframe> diff --git a/testing/web-platform/tests/workers/semantics/xhr/004.js b/testing/web-platform/tests/workers/semantics/xhr/004.js new file mode 100644 index 0000000000..1741c8d36a --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/xhr/004.js @@ -0,0 +1,11 @@ +onconnect = function(e) { + var xhr = new XMLHttpRequest(); + var log = ''; + xhr.open('GET', '001-1.xml', false); + xhr.send(); + if (xhr.responseXML != null) + log += 'responseXML was not null. '; + if (xhr.responseText != '<x>foo</x>') + log += 'responseText was ' + xhr.responseText + ', expected <x>foo</x>. '; + e.ports[0].postMessage(log); +} diff --git a/testing/web-platform/tests/workers/semantics/xhr/005.html b/testing/web-platform/tests/workers/semantics/xhr/005.html new file mode 100644 index 0000000000..84abdb0c42 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/xhr/005.html @@ -0,0 +1,21 @@ +<!doctype html> +<title>base url, dedicated worker</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +var t = async_test(); +var i = 0; +function runtest() { + i++; + if (i != 2) + return; + var worker = new Worker('support/005-1.js'); + worker.onmessage = this.step_func(function(e) { + assert_true(e.data); + this.done(); + }); +} +</script> +<iframe src=001-1.xml onload="t.step(runtest);"></iframe> +<iframe src=support/001-1.xml onload="t.step(runtest);"></iframe> diff --git a/testing/web-platform/tests/workers/semantics/xhr/006.html b/testing/web-platform/tests/workers/semantics/xhr/006.html new file mode 100644 index 0000000000..7411b4baef --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/xhr/006.html @@ -0,0 +1,21 @@ +<!doctype html> +<title>base url, shared worker</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +var t = async_test(); +var i = 0; +function runtest() { + i++; + if (i != 2) + return; + var worker = new SharedWorker('support/006-1.js',''); + worker.port.onmessage = this.step_func(function(e) { + assert_true(e.data); + this.done(); + }); +} +</script> +<iframe src=001-1.xml onload="t.step(runtest);"></iframe> +<iframe src=support/001-1.xml onload="t.step(runtest);"></iframe> diff --git a/testing/web-platform/tests/workers/semantics/xhr/support/001-1.xml b/testing/web-platform/tests/workers/semantics/xhr/support/001-1.xml new file mode 100644 index 0000000000..ecea58a935 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/xhr/support/001-1.xml @@ -0,0 +1 @@ +<x>bar</x>
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/semantics/xhr/support/005-1.js b/testing/web-platform/tests/workers/semantics/xhr/support/005-1.js new file mode 100644 index 0000000000..45f6519a21 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/xhr/support/005-1.js @@ -0,0 +1,5 @@ +var xhr = new XMLHttpRequest(); +xhr.open('GET', '001-1.xml', false); +xhr.send(); +var passed = xhr.responseText == '<x>bar</x>'; +postMessage(passed);
\ No newline at end of file diff --git a/testing/web-platform/tests/workers/semantics/xhr/support/006-1.js b/testing/web-platform/tests/workers/semantics/xhr/support/006-1.js new file mode 100644 index 0000000000..d446781eb7 --- /dev/null +++ b/testing/web-platform/tests/workers/semantics/xhr/support/006-1.js @@ -0,0 +1,7 @@ +onconnect = function(e) { + var xhr = new XMLHttpRequest(); + xhr.open('GET', '001-1.xml', false); + xhr.send(); + var passed = xhr.responseText == '<x>bar</x>'; + e.ports[0].postMessage(passed); +}
\ No newline at end of file |