diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
commit | 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch) | |
tree | a31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /testing/web-platform/tests/webmessaging/without-ports | |
parent | Initial commit. (diff) | |
download | firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip |
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/webmessaging/without-ports')
30 files changed, 606 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webmessaging/without-ports/001.html b/testing/web-platform/tests/webmessaging/without-ports/001.html new file mode 100644 index 0000000000..09c28c5a5c --- /dev/null +++ b/testing/web-platform/tests/webmessaging/without-ports/001.html @@ -0,0 +1,12 @@ +<!doctype html> +<title>resolving broken url</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +test(function() { + assert_throws_dom('SYNTAX_ERR', function() { + postMessage('', 'http://foo bar'); + }, 'should have failed to resolve'); +}); +</script> diff --git a/testing/web-platform/tests/webmessaging/without-ports/002.html b/testing/web-platform/tests/webmessaging/without-ports/002.html new file mode 100644 index 0000000000..ef3eceb2a0 --- /dev/null +++ b/testing/web-platform/tests/webmessaging/without-ports/002.html @@ -0,0 +1,14 @@ +<!doctype html> +<title>resolving url with stuff in host-specific</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +async_test(function() { + postMessage('', location.protocol + '//' + location.host + '//'); + onmessage = this.step_func(function(e) { + assert_equals(e.origin, location.protocol + '//' + location.host); + this.done(); + }); +}); +</script> diff --git a/testing/web-platform/tests/webmessaging/without-ports/003.html b/testing/web-platform/tests/webmessaging/without-ports/003.html new file mode 100644 index 0000000000..6dc1e55777 --- /dev/null +++ b/testing/web-platform/tests/webmessaging/without-ports/003.html @@ -0,0 +1,12 @@ +<!doctype html> +<title>resolving 'example.org'</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +test(function() { + assert_throws_dom('SYNTAX_ERR', function() { + postMessage('', 'example.org'); + }, 'targetOrigin is not an absolute url'); +}); +</script> diff --git a/testing/web-platform/tests/webmessaging/without-ports/004.html b/testing/web-platform/tests/webmessaging/without-ports/004.html new file mode 100644 index 0000000000..9a9eb81a5d --- /dev/null +++ b/testing/web-platform/tests/webmessaging/without-ports/004.html @@ -0,0 +1,14 @@ +<!doctype html> +<title>special value '/'</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +async_test(function() { + postMessage('', '/'); + onmessage = this.step_func(function(e) { + assert_equals(e.data, ''); + this.done(); + }); +}); +</script> diff --git a/testing/web-platform/tests/webmessaging/without-ports/005.html b/testing/web-platform/tests/webmessaging/without-ports/005.html new file mode 100644 index 0000000000..ed05a476bc --- /dev/null +++ b/testing/web-platform/tests/webmessaging/without-ports/005.html @@ -0,0 +1,14 @@ +<!doctype html> +<title>resolving a same origin targetOrigin</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +async_test(function() { + postMessage('', location.protocol + '//' + location.host); + onmessage = this.step_func(function(e) { + assert_equals(e.data, ''); + this.done(); + }); +}); +</script> diff --git a/testing/web-platform/tests/webmessaging/without-ports/006.html b/testing/web-platform/tests/webmessaging/without-ports/006.html new file mode 100644 index 0000000000..47479ea011 --- /dev/null +++ b/testing/web-platform/tests/webmessaging/without-ports/006.html @@ -0,0 +1,14 @@ +<!doctype html> +<title>resolving a same origin targetOrigin with trailing slash</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +async_test(function() { + postMessage('', location.protocol + '//' + location.host + '/'); + onmessage = this.step_func(function(e) { + assert_equals(e.data, ''); + this.done(); + }); +}); +</script> diff --git a/testing/web-platform/tests/webmessaging/without-ports/007.html b/testing/web-platform/tests/webmessaging/without-ports/007.html new file mode 100644 index 0000000000..eb2b5c52e5 --- /dev/null +++ b/testing/web-platform/tests/webmessaging/without-ports/007.html @@ -0,0 +1,14 @@ +<!doctype html> +<title>targetOrigin '*'</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +async_test(function() { + postMessage('', '*'); + onmessage = this.step_func(function(e) { + assert_equals(e.data, ''); + this.done(); + }); +}); +</script> diff --git a/testing/web-platform/tests/webmessaging/without-ports/009.html b/testing/web-platform/tests/webmessaging/without-ports/009.html new file mode 100644 index 0000000000..d613b4a073 --- /dev/null +++ b/testing/web-platform/tests/webmessaging/without-ports/009.html @@ -0,0 +1,12 @@ +<!doctype html> +<title>zero arguments</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +test(function() { + assert_throws_js(TypeError, function() { + postMessage(); + }); +}); +</script> diff --git a/testing/web-platform/tests/webmessaging/without-ports/010.html b/testing/web-platform/tests/webmessaging/without-ports/010.html new file mode 100644 index 0000000000..062316f680 --- /dev/null +++ b/testing/web-platform/tests/webmessaging/without-ports/010.html @@ -0,0 +1,112 @@ +<!doctype html> +<title>message clone</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="../support/compare.js"></script> +<div id=log></div> +<script> + var err = new Error('foo'); + var date = new Date(); + + var test_array = [ undefined, + null, + false, + true, + 1, + NaN, + Infinity, + 'foo', + date, + /foo/, + null/*self*/, + null/*err*/]; + + var cloned_array = [ undefined, + null, + false, + true, + 1, + NaN, + Infinity, + 'foo', + date, + /foo/, + null/*self*/, + null/*err*/]; + + var test_object = {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*/}; + + var cloned_object = {a:undefined, b:null, c:false, d:true, e:1, f:NaN, g:Infinity, h:'foo', i: date, j: /foo/, k:null, l: [], m: {}, n:null}; + + var tests = [undefined, null, + false, true, + 1, NaN, Infinity, + 'foo', + date, + /foo/, + /* ImageData, File, FileData, FileList, */ + null /*self*/, + test_array, + test_object, + null /*err*/]; + + for (var i = 0; i < tests.length; ++i) { + postMessage(tests[i], '*'); + } + + var test_undefined = async_test('undefined'); + var test_null = async_test('null'); + var test_false = async_test('false'); + var test_true = async_test('true'); + var test_1 = async_test('1'); + var test_NaN = async_test('NaN'); + var test_Infinity = async_test('Infinity'); + var test_string = async_test('string'); + var test_date = async_test('date'); + var test_regex = async_test('regex'); + var test_self = async_test('self'); + var test_array = async_test('array'); + var test_object = async_test('object'); + var test_error = async_test('error'); + var test_unreached = async_test('unreached'); + + var j = 0; + onmessage = function(e) { + switch (j) { + case 0: test_undefined.step(function() { assert_equals(e.data, undefined); this.done(); }); break; + case 1: test_null.step(function() { assert_equals(e.data, null); this.done(); }); break; + case 2: test_false.step(function() { assert_false(e.data); this.done(); }); break; + case 3: test_true.step(function() { assert_true(e.data); this.done(); }); break; + case 4: test_1.step(function() { assert_equals(e.data, 1); this.done(); }); break; + case 5: test_NaN.step(function() { assert_equals(e.data, NaN); this.done(); }); break; + case 6: test_Infinity.step(function() { assert_equals(e.data, Infinity); this.done(); }); break; + case 7: test_string.step(function() { assert_equals(e.data, 'foo'); this.done(); }); break; + case 8: test_date.step(function() { assert_true(sameDate(e.data, date)); this.done(); }); break; + case 9: test_regex.step(function() { assert_equals('' + e.data, '/foo/'); assert_equals(e.data instanceof RegExp, true, 'e.data instanceof RegExp'); this.done(); }); break; + // not testing it any more, as cloning host objects will now raise exceptions. TODO: add (exceptional) tests for these. + case 10: test_self.step(function() { assert_equals(e.data, null); this.done(); }); break; + case 11: test_array.step(function() { assert_array_equals_(e.data, cloned_array, 'array'); this.done(); }); break; + case 12: test_object.step(function() { assert_object_equals_(e.data, cloned_object, 'object'); this.done(); }); break; + case 13: + test_error.step(function() { assert_equals(e.data, null, 'new Error()'); this.done(); }); + setTimeout(test_unreached.step_func(function() { assert_equals(j, 14); this.done(); }), 50); + break; + default: test_unreached.step(function() { assert_unreached('got an unexpected message event ('+j+')'); }); + }; + j++; + } + +</script> diff --git a/testing/web-platform/tests/webmessaging/without-ports/011.html b/testing/web-platform/tests/webmessaging/without-ports/011.html new file mode 100644 index 0000000000..cac2990c49 --- /dev/null +++ b/testing/web-platform/tests/webmessaging/without-ports/011.html @@ -0,0 +1,29 @@ +<!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(function() { + + var canvas = document.createElement('canvas'); + var clone = canvas.cloneNode(true); + var ctx = clone.getContext('2d'); + var imagedata = ctx.getImageData(0, 0, 300, 150); + postMessage([imagedata], '*'); + + onmessage = this.step_func(function(e) { + function processPixels(imagedata) { + var pixeldata = imagedata.data; + for (var i = 0; i < pixeldata.length; i = i+4) { + pixeldata[i] = 128; + assert_equals(pixeldata[i], 128); + } + } + processPixels(e.data[0]); + this.done(); + }); + +}); +</script> + diff --git a/testing/web-platform/tests/webmessaging/without-ports/012.html b/testing/web-platform/tests/webmessaging/without-ports/012.html new file mode 100644 index 0000000000..8eb46539b7 --- /dev/null +++ b/testing/web-platform/tests/webmessaging/without-ports/012.html @@ -0,0 +1,16 @@ +<!doctype html> +<title>loop in array in structured clone</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +async_test(function() { + var x = []; + x[0] = x; + postMessage(x, '*'); + onmessage = this.step_func(function(e) { + assert_equals(e.data, e.data[0]); + this.done(); + }); +}); +</script> diff --git a/testing/web-platform/tests/webmessaging/without-ports/013.html b/testing/web-platform/tests/webmessaging/without-ports/013.html new file mode 100644 index 0000000000..34ba76221a --- /dev/null +++ b/testing/web-platform/tests/webmessaging/without-ports/013.html @@ -0,0 +1,17 @@ +<!doctype html> +<title>loop in object in structured clone</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +async_test(function() { + var x = {}; + x.foo = x; + postMessage(x, '*'); + onmessage = this.step_func(function(e) { + assert_equals(e.data, e.data.foo); + this.done(); + }); +}); +</script> + diff --git a/testing/web-platform/tests/webmessaging/without-ports/014.html b/testing/web-platform/tests/webmessaging/without-ports/014.html new file mode 100644 index 0000000000..f200aa4673 --- /dev/null +++ b/testing/web-platform/tests/webmessaging/without-ports/014.html @@ -0,0 +1,17 @@ +<!doctype html> +<title>structured clone vs reference</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +async_test(function(t) { + var x = []; + y = [x,x]; + postMessage(y, '*'); + onmessage = t.step_func(function(e) { + assert_equals(e.data[0], e.data[1], 'e.data[0] === e.data[1]'); + assert_not_equals(e.data[0], x, 'e.data[0] !== x'); + t.done(); + }); +}); +</script> diff --git a/testing/web-platform/tests/webmessaging/without-ports/015.html b/testing/web-platform/tests/webmessaging/without-ports/015.html new file mode 100644 index 0000000000..a17c97be19 --- /dev/null +++ b/testing/web-platform/tests/webmessaging/without-ports/015.html @@ -0,0 +1,15 @@ +<!doctype html> +<title>different origin</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +async_test(function() { + postMessage('', 'http://example.org', []); + onmessage = this.step_func(function(e) { + assert_unreached(); + }); + setTimeout(this.step_func(function(){ this.done(); }), 50); +}); +</script> + diff --git a/testing/web-platform/tests/webmessaging/without-ports/016.html b/testing/web-platform/tests/webmessaging/without-ports/016.html new file mode 100644 index 0000000000..51cadec7c1 --- /dev/null +++ b/testing/web-platform/tests/webmessaging/without-ports/016.html @@ -0,0 +1,23 @@ +<!doctype html> +<title>origin of the script that invoked the method, data:</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<iframe src="data:text/html,<script>onmessage = function(e) { parent.postMessage(e.origin, '*'); }; parent.postMessage('loaded', '*');</script>"></iframe> +<div id=log></div> +<script> +async_test(function() { + onmessage = this.step_func(function(e) { + if (e.data === 'loaded') { + window[0].postMessage('', '*'); + return; + } + + assert_equals(e.data, location.protocol + '//' + location.host); + assert_equals(e.origin, 'null'); + assert_array_equals(e.ports, []); + this.done(); + }); +}); +</script> + + diff --git a/testing/web-platform/tests/webmessaging/without-ports/017.html b/testing/web-platform/tests/webmessaging/without-ports/017.html new file mode 100644 index 0000000000..a4a0483624 --- /dev/null +++ b/testing/web-platform/tests/webmessaging/without-ports/017.html @@ -0,0 +1,18 @@ +<!doctype html> +<title>origin of the script that invoked the method, about:blank</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<iframe src="about:blank"></iframe> +<div id=log></div> +<script> +async_test(function() { + window[0].postMessage('', '*'); + window[0].onmessage = this.step_func(function(e) { + assert_equals(e.origin, location.protocol + '//' + location.host); + assert_array_equals(e.ports, []); + this.done(); + }); +}); +</script> + + diff --git a/testing/web-platform/tests/webmessaging/without-ports/018.html b/testing/web-platform/tests/webmessaging/without-ports/018.html new file mode 100644 index 0000000000..207ae36ed8 --- /dev/null +++ b/testing/web-platform/tests/webmessaging/without-ports/018.html @@ -0,0 +1,17 @@ +<!doctype html> +<title>origin of the script that invoked the method, javascript:</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<iframe src="javascript:''"></iframe> +<div id=log></div> +<script> +async_test(function() { + window[0].postMessage('', '*'); + window[0].onmessage = this.step_func(function(e) { + assert_equals(e.origin, location.protocol + '//' + location.host); + this.done(); + }); +}); +</script> + + diff --git a/testing/web-platform/tests/webmessaging/without-ports/019-1.html b/testing/web-platform/tests/webmessaging/without-ports/019-1.html new file mode 100644 index 0000000000..513123ee6d --- /dev/null +++ b/testing/web-platform/tests/webmessaging/without-ports/019-1.html @@ -0,0 +1 @@ +<!-- blank -->
\ No newline at end of file diff --git a/testing/web-platform/tests/webmessaging/without-ports/019.html b/testing/web-platform/tests/webmessaging/without-ports/019.html new file mode 100644 index 0000000000..38e7ca230e --- /dev/null +++ b/testing/web-platform/tests/webmessaging/without-ports/019.html @@ -0,0 +1,20 @@ +<!doctype html> +<title>origin of the script that invoked the method, scheme/host/port</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<iframe src="../without-ports/019-1.html"></iframe> +<div id=log></div> +<script> +async_test(function(test) { + onload = test.step_func(function() { + window[0].postMessage('', location.protocol.toUpperCase() + '//' + location.host.toUpperCase() + '/'); + window[0].onmessage = test.step_func(function(e) { + assert_equals(e.origin, location.protocol + '//' + location.host); + assert_array_equals(e.ports, []); + test.done(); + }); + }); +}); +</script> + + diff --git a/testing/web-platform/tests/webmessaging/without-ports/020-1.html b/testing/web-platform/tests/webmessaging/without-ports/020-1.html new file mode 100644 index 0000000000..225bd7a41e --- /dev/null +++ b/testing/web-platform/tests/webmessaging/without-ports/020-1.html @@ -0,0 +1,5 @@ +<script> +onmessage = function(e) { + parent.postMessage([e.data, e.origin], '*'); +} +</script>
\ No newline at end of file diff --git a/testing/web-platform/tests/webmessaging/without-ports/020.html b/testing/web-platform/tests/webmessaging/without-ports/020.html new file mode 100644 index 0000000000..61bfddb901 --- /dev/null +++ b/testing/web-platform/tests/webmessaging/without-ports/020.html @@ -0,0 +1,32 @@ +<!doctype html> +<title>cross-origin test</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<iframe src="../without-ports/020-1.html"></iframe> +<div id="log"></div> +<script> +setup({ single_test: true }); + +var iframe = document.createElement('iframe'); +var url_prefix = location.href.replace('://', '://www1.').replace(/\/with(out)?-ports\/[^\/]+$/, ''); +var url = url_prefix + '/without-ports/020-1.html'; +iframe.src = url; +document.body.appendChild(iframe); +</script> +<div id=log></div> +<script> +onload = function() { + window[0].postMessage(1, location.href); + window[1].postMessage(2, url); + var i = 0; + onmessage = function(e) { + i++; + assert_equals(e.data[0], i); + assert_equals(e.data[1], location.protocol + '//' + location.host); + if (i == 2) { + done(); + } + }; +}; +</script> + diff --git a/testing/web-platform/tests/webmessaging/without-ports/021.html b/testing/web-platform/tests/webmessaging/without-ports/021.html new file mode 100644 index 0000000000..5072508d9c --- /dev/null +++ b/testing/web-platform/tests/webmessaging/without-ports/021.html @@ -0,0 +1,32 @@ +<!doctype html> +<title>cross-origin test</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<iframe src="../without-ports/020-1.html"></iframe> +<div id="log"></div> +<script> +setup({ single_test: true }); + +var iframe = document.createElement('iframe'); +var url_prefix = location.href.replace('://', '://www1.').replace(/\/with(out)?-ports\/[^\/]+$/, ''); +var url = url_prefix + '/without-ports/020-1.html'; +iframe.src = url; +document.body.appendChild(iframe); +</script> +<div id=log></div> +<script> +onload = function() { + window[0].postMessage(1, '*'); + window[1].postMessage(2, '*'); + var i = 0; + onmessage = function(e) { + i++; + assert_equals(e.data[0], i); + assert_equals(e.data[1], location.protocol + '//' + location.host); + if (i === 2) { + done(); + } + }; +}; +</script> + diff --git a/testing/web-platform/tests/webmessaging/without-ports/023.html b/testing/web-platform/tests/webmessaging/without-ports/023.html new file mode 100644 index 0000000000..1e12ac4a55 --- /dev/null +++ b/testing/web-platform/tests/webmessaging/without-ports/023.html @@ -0,0 +1,29 @@ +<!doctype html> +<title>Object cloning: own properties only, don't follow prototype</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +var Parent = function(){ + this.c = "xyz"; +}; + +var Child = function(a, b) { + this.a = a; + this.b = b; +}; +Child.prototype = new Parent; + +async_test(function() { + var obj = new Child(1, 2); + var ch = new MessageChannel(); + ch.port1.onmessage = this.step_func(function(e) { + for (var i in e.data.obj) + assert_not_equals(i, 'c'); + this.done(); + }); + ch.port2.start(); + ch.port2.postMessage({obj: obj}); +}); + +</script> diff --git a/testing/web-platform/tests/webmessaging/without-ports/024.html b/testing/web-platform/tests/webmessaging/without-ports/024.html new file mode 100644 index 0000000000..0e4651593a --- /dev/null +++ b/testing/web-platform/tests/webmessaging/without-ports/024.html @@ -0,0 +1,14 @@ +<!doctype html> +<title>Object cloning: throw an exception if function values encountered</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +test(function() { + var obj = { f : function(){}}; + var ch = new MessageChannel(); + ch.port1.onmessage = function(){}; + ch.port2.start(); + assert_throws_dom('DATA_CLONE_ERR', function() { ch.port2.postMessage({obj: obj}); }); +}); +</script> diff --git a/testing/web-platform/tests/webmessaging/without-ports/025-1.js b/testing/web-platform/tests/webmessaging/without-ports/025-1.js new file mode 100644 index 0000000000..bd1d778d9b --- /dev/null +++ b/testing/web-platform/tests/webmessaging/without-ports/025-1.js @@ -0,0 +1,15 @@ +importScripts("/resources/testharness.js"); + +test(function() { + var ch = new MessageChannel(); + assert_true(ch.port1 instanceof MessagePort, + "Worker MessageChannel's port not an instance of MessagePort"); +}, "Worker MessageChannel's port should be an instance of MessagePort"); + +test(function() { + assert_throws_js(TypeError, function() { + new MessagePort() + }, "MessagePort is [[Callable]]"); +}, "Worker MessagePort should not be [[Callable]]"); + +done(); diff --git a/testing/web-platform/tests/webmessaging/without-ports/025.html b/testing/web-platform/tests/webmessaging/without-ports/025.html new file mode 100644 index 0000000000..4686febe94 --- /dev/null +++ b/testing/web-platform/tests/webmessaging/without-ports/025.html @@ -0,0 +1,13 @@ +<!doctype html> +<title>MessagePort constructor properties</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +test(function() { + var ch = new MessageChannel(); + assert_true(ch.port1 instanceof MessagePort, "MessageChannel's port not an instance of MessagePort"); + assert_throws_js(TypeError, function () { var p = new MessagePort();}, "MessagePort is [[Callable]]"); +}); +fetch_tests_from_worker(new Worker("025-1.js")); +</script> diff --git a/testing/web-platform/tests/webmessaging/without-ports/026.html b/testing/web-platform/tests/webmessaging/without-ports/026.html new file mode 100644 index 0000000000..546da8a91b --- /dev/null +++ b/testing/web-platform/tests/webmessaging/without-ports/026.html @@ -0,0 +1,17 @@ +<!doctype html> +<title>Cloning objects with getter properties</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +async_test(function() { + var obj = {}; + var err = new Error("getter_should_propagate_exceptions"); + obj.__defineGetter__( "field", function(){ throw err }); + + assert_throws_exactly(err, function() { + postMessage(obj, '*'); + }); + this.done(); +}); +</script> diff --git a/testing/web-platform/tests/webmessaging/without-ports/027.html b/testing/web-platform/tests/webmessaging/without-ports/027.html new file mode 100644 index 0000000000..36aa9446a5 --- /dev/null +++ b/testing/web-platform/tests/webmessaging/without-ports/027.html @@ -0,0 +1,19 @@ +<!doctype html> +<title>Cloning objects, preserving sharing</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +async_test(function() { + var obj1 = {o: 1}; + var obj2 = {d: obj1}; + var obj3 = {d: obj1}; + var obj_dag = {b: obj2, c: obj3}; + + postMessage(obj_dag, '*'); + onmessage = this.step_func(function(e) { + assert_equals(e.data.b.d, e.data.c.d); + this.done(); + }); +}); +</script> diff --git a/testing/web-platform/tests/webmessaging/without-ports/028.html b/testing/web-platform/tests/webmessaging/without-ports/028.html new file mode 100644 index 0000000000..d51ad7d3b6 --- /dev/null +++ b/testing/web-platform/tests/webmessaging/without-ports/028.html @@ -0,0 +1,19 @@ +<!doctype html> +<title>Cloning objects, preserving sharing #2</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<canvas id="a" width=30 height=30></canvas> +<div id=log></div> +<script> +async_test(function() { + var canvas = document.getElementsByTagName("canvas")[0]; + var context = canvas.getContext("2d"); + var img_data = context.getImageData(0, 0, 30, 30); + var obj = {a: img_data, b: {c: img_data, d: 3}}; + postMessage(obj, '*'); + onmessage = this.step_func(function(e) { + assert_equals(e.data.a, e.data.b.c); + this.done(); + }); +}); +</script> diff --git a/testing/web-platform/tests/webmessaging/without-ports/029.html b/testing/web-platform/tests/webmessaging/without-ports/029.html new file mode 100644 index 0000000000..4b1b38f741 --- /dev/null +++ b/testing/web-platform/tests/webmessaging/without-ports/029.html @@ -0,0 +1,20 @@ +<!doctype html> +<title>Check that getters don't linger after deletion wrt cloning</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +async_test(function() { + var obj = {}; + obj.__defineGetter__( "a", function(){ return 2; } ); + obj.__defineSetter__( "a", function(v){ return; } ); + delete obj.a; + obj.a = 2; + + postMessage(obj, '*'); + onmessage = this.step_func(function(e) { + assert_equals(e.data.a, 2); + this.done(); + }); +}); +</script> |