diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/webmessaging/with-ports | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/webmessaging/with-ports')
24 files changed, 508 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webmessaging/with-ports/001.html b/testing/web-platform/tests/webmessaging/with-ports/001.html new file mode 100644 index 000000000..e3687f162 --- /dev/null +++ b/testing/web-platform/tests/webmessaging/with-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('SYNTAX_ERR', function() { + postMessage('', 'http://foo bar', []); + }, 'should have failed to resolve'); +}); +</script> diff --git a/testing/web-platform/tests/webmessaging/with-ports/002.html b/testing/web-platform/tests/webmessaging/with-ports/002.html new file mode 100644 index 000000000..f7d085937 --- /dev/null +++ b/testing/web-platform/tests/webmessaging/with-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/with-ports/003.html b/testing/web-platform/tests/webmessaging/with-ports/003.html new file mode 100644 index 000000000..3c0d4296b --- /dev/null +++ b/testing/web-platform/tests/webmessaging/with-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('SYNTAX_ERR', function() { + postMessage('', 'example.org', []); + }, 'targetOrigin is not an absolute url'); +}); +</script> diff --git a/testing/web-platform/tests/webmessaging/with-ports/004.html b/testing/web-platform/tests/webmessaging/with-ports/004.html new file mode 100644 index 000000000..d129ad119 --- /dev/null +++ b/testing/web-platform/tests/webmessaging/with-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/with-ports/005.html b/testing/web-platform/tests/webmessaging/with-ports/005.html new file mode 100644 index 000000000..e80396891 --- /dev/null +++ b/testing/web-platform/tests/webmessaging/with-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/with-ports/006.html b/testing/web-platform/tests/webmessaging/with-ports/006.html new file mode 100644 index 000000000..4e3f1ede8 --- /dev/null +++ b/testing/web-platform/tests/webmessaging/with-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/with-ports/007.html b/testing/web-platform/tests/webmessaging/with-ports/007.html new file mode 100644 index 000000000..c049a1337 --- /dev/null +++ b/testing/web-platform/tests/webmessaging/with-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/with-ports/010.html b/testing/web-platform/tests/webmessaging/with-ports/010.html new file mode 100644 index 000000000..05080e3f7 --- /dev/null +++ b/testing/web-platform/tests/webmessaging/with-ports/010.html @@ -0,0 +1,113 @@ +<!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/with-ports/011.html b/testing/web-platform/tests/webmessaging/with-ports/011.html new file mode 100644 index 000000000..782b3208b --- /dev/null +++ b/testing/web-platform/tests/webmessaging/with-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/with-ports/012.html b/testing/web-platform/tests/webmessaging/with-ports/012.html new file mode 100644 index 000000000..6efe4c114 --- /dev/null +++ b/testing/web-platform/tests/webmessaging/with-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/with-ports/013.html b/testing/web-platform/tests/webmessaging/with-ports/013.html new file mode 100644 index 000000000..248958ea1 --- /dev/null +++ b/testing/web-platform/tests/webmessaging/with-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/with-ports/014.html b/testing/web-platform/tests/webmessaging/with-ports/014.html new file mode 100644 index 000000000..3c970c42a --- /dev/null +++ b/testing/web-platform/tests/webmessaging/with-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/with-ports/015.html b/testing/web-platform/tests/webmessaging/with-ports/015.html new file mode 100644 index 000000000..a17c97be1 --- /dev/null +++ b/testing/web-platform/tests/webmessaging/with-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/with-ports/016.html b/testing/web-platform/tests/webmessaging/with-ports/016.html new file mode 100644 index 000000000..7257c95d0 --- /dev/null +++ b/testing/web-platform/tests/webmessaging/with-ports/016.html @@ -0,0 +1,18 @@ +<!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,"></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/with-ports/017.html b/testing/web-platform/tests/webmessaging/with-ports/017.html new file mode 100644 index 000000000..94cd3e6ae --- /dev/null +++ b/testing/web-platform/tests/webmessaging/with-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/with-ports/018.html b/testing/web-platform/tests/webmessaging/with-ports/018.html new file mode 100644 index 000000000..5525206e4 --- /dev/null +++ b/testing/web-platform/tests/webmessaging/with-ports/018.html @@ -0,0 +1,18 @@ +<!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); + assert_array_equals(e.ports, []); + this.done(); + }); +}); +</script> + + diff --git a/testing/web-platform/tests/webmessaging/with-ports/019.html b/testing/web-platform/tests/webmessaging/with-ports/019.html new file mode 100644 index 000000000..2c65d5816 --- /dev/null +++ b/testing/web-platform/tests/webmessaging/with-ports/019.html @@ -0,0 +1,18 @@ +<!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() { + window[0].postMessage('', location.protocol.toUpperCase() + '//' + location.host.toUpperCase() + '/', []); + 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/with-ports/020.html b/testing/web-platform/tests/webmessaging/with-ports/020.html new file mode 100644 index 000000000..4fc2c4e2d --- /dev/null +++ b/testing/web-platform/tests/webmessaging/with-ports/020.html @@ -0,0 +1,30 @@ +<!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> +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/with-ports/021.html b/testing/web-platform/tests/webmessaging/with-ports/021.html new file mode 100644 index 000000000..37a0767fe --- /dev/null +++ b/testing/web-platform/tests/webmessaging/with-ports/021.html @@ -0,0 +1,30 @@ +<!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> +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/with-ports/023.html b/testing/web-platform/tests/webmessaging/with-ports/023.html new file mode 100644 index 000000000..664289585 --- /dev/null +++ b/testing/web-platform/tests/webmessaging/with-ports/023.html @@ -0,0 +1,15 @@ +<!doctype html> +<title>null ports</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +async_test(function(t) { + postMessage('', '*', null); + onmessage = t.step_func(function(e) { + assert_array_equals(e.ports, []); + this.done(); + }); +}); +</script> + diff --git a/testing/web-platform/tests/webmessaging/with-ports/024.html b/testing/web-platform/tests/webmessaging/with-ports/024.html new file mode 100644 index 000000000..e6c0dcba0 --- /dev/null +++ b/testing/web-platform/tests/webmessaging/with-ports/024.html @@ -0,0 +1,15 @@ +<!doctype html> +<title>undefined as ports</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +async_test(function() { + postMessage('', '*', undefined); + onmessage = this.step_func(function(e) { + assert_array_equals(e.ports, []); + this.done(); + }); +}); +</script> + diff --git a/testing/web-platform/tests/webmessaging/with-ports/025.html b/testing/web-platform/tests/webmessaging/with-ports/025.html new file mode 100644 index 000000000..9a0e5cf6f --- /dev/null +++ b/testing/web-platform/tests/webmessaging/with-ports/025.html @@ -0,0 +1,13 @@ +<!doctype html> +<title>1 as ports</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +test(function() { + assert_throws(new TypeError(), function() { + postMessage('', '*', 1); + }); +}); +</script> + diff --git a/testing/web-platform/tests/webmessaging/with-ports/026.html b/testing/web-platform/tests/webmessaging/with-ports/026.html new file mode 100644 index 000000000..cf5c5e18a --- /dev/null +++ b/testing/web-platform/tests/webmessaging/with-ports/026.html @@ -0,0 +1,13 @@ +<!doctype html> +<title>object with length as transferable</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +test(function() { + assert_throws(new TypeError(), function() { + postMessage('', '*', {length:1}); + }); +}); +</script> + diff --git a/testing/web-platform/tests/webmessaging/with-ports/027.html b/testing/web-platform/tests/webmessaging/with-ports/027.html new file mode 100644 index 000000000..c85e02dc7 --- /dev/null +++ b/testing/web-platform/tests/webmessaging/with-ports/027.html @@ -0,0 +1,19 @@ +<!doctype html> +<title>message channel as ports</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +async_test(function(t) { + var channel = new MessageChannel(); + channel[0] = channel.port1; + channel[1] = channel.port2; + channel.length = 2; + postMessage('', '*', channel); + onmessage = t.step_func(function(e) { + assert_equals(e.ports.length, 2); + t.done(); + }); +}); +</script> + |