summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webmessaging/with-ports
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/webmessaging/with-ports')
-rw-r--r--testing/web-platform/tests/webmessaging/with-ports/001.html12
-rw-r--r--testing/web-platform/tests/webmessaging/with-ports/002.html14
-rw-r--r--testing/web-platform/tests/webmessaging/with-ports/003.html12
-rw-r--r--testing/web-platform/tests/webmessaging/with-ports/004.html14
-rw-r--r--testing/web-platform/tests/webmessaging/with-ports/005.html14
-rw-r--r--testing/web-platform/tests/webmessaging/with-ports/006.html14
-rw-r--r--testing/web-platform/tests/webmessaging/with-ports/007.html14
-rw-r--r--testing/web-platform/tests/webmessaging/with-ports/010.html113
-rw-r--r--testing/web-platform/tests/webmessaging/with-ports/011.html29
-rw-r--r--testing/web-platform/tests/webmessaging/with-ports/012.html16
-rw-r--r--testing/web-platform/tests/webmessaging/with-ports/013.html17
-rw-r--r--testing/web-platform/tests/webmessaging/with-ports/014.html17
-rw-r--r--testing/web-platform/tests/webmessaging/with-ports/015.html15
-rw-r--r--testing/web-platform/tests/webmessaging/with-ports/016.html23
-rw-r--r--testing/web-platform/tests/webmessaging/with-ports/017.html18
-rw-r--r--testing/web-platform/tests/webmessaging/with-ports/018.html18
-rw-r--r--testing/web-platform/tests/webmessaging/with-ports/019.html20
-rw-r--r--testing/web-platform/tests/webmessaging/with-ports/020.html32
-rw-r--r--testing/web-platform/tests/webmessaging/with-ports/021.html32
-rw-r--r--testing/web-platform/tests/webmessaging/with-ports/023.html11
-rw-r--r--testing/web-platform/tests/webmessaging/with-ports/024.html15
-rw-r--r--testing/web-platform/tests/webmessaging/with-ports/025.html13
-rw-r--r--testing/web-platform/tests/webmessaging/with-ports/026.html13
-rw-r--r--testing/web-platform/tests/webmessaging/with-ports/027.html26
24 files changed, 522 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 0000000000..62dcf5e9bf
--- /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_dom('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 0000000000..f7d085937c
--- /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 0000000000..47ddfbe81a
--- /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_dom('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 0000000000..d129ad119a
--- /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 0000000000..e803968919
--- /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 0000000000..4e3f1ede84
--- /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 0000000000..c049a1337d
--- /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 0000000000..05080e3f7a
--- /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 0000000000..782b3208ba
--- /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 0000000000..6efe4c114a
--- /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 0000000000..248958ea10
--- /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 0000000000..3c970c42ad
--- /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 0000000000..a17c97be19
--- /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 0000000000..51cadec7c1
--- /dev/null
+++ b/testing/web-platform/tests/webmessaging/with-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/with-ports/017.html b/testing/web-platform/tests/webmessaging/with-ports/017.html
new file mode 100644
index 0000000000..94cd3e6ae2
--- /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 0000000000..5525206e44
--- /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 0000000000..e9de6c36e1
--- /dev/null
+++ b/testing/web-platform/tests/webmessaging/with-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/with-ports/020.html b/testing/web-platform/tests/webmessaging/with-ports/020.html
new file mode 100644
index 0000000000..426a3d2700
--- /dev/null
+++ b/testing/web-platform/tests/webmessaging/with-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/with-ports/021.html b/testing/web-platform/tests/webmessaging/with-ports/021.html
new file mode 100644
index 0000000000..2801d45a44
--- /dev/null
+++ b/testing/web-platform/tests/webmessaging/with-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/with-ports/023.html b/testing/web-platform/tests/webmessaging/with-ports/023.html
new file mode 100644
index 0000000000..e2569a8463
--- /dev/null
+++ b/testing/web-platform/tests/webmessaging/with-ports/023.html
@@ -0,0 +1,11 @@
+<!doctype html>
+<title>null ports</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+test(function(t) {
+ assert_throws_js(TypeError, () => postMessage('', '*', null));
+});
+</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 0000000000..e6c0dcba08
--- /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 0000000000..7af2a852ed
--- /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_js(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 0000000000..2af90e6be3
--- /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_js(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 0000000000..7158351258
--- /dev/null
+++ b/testing/web-platform/tests/webmessaging/with-ports/027.html
@@ -0,0 +1,26 @@
+<!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();
+ postMessage('', '*', [channel.port1, channel.port2]);
+ onmessage = t.step_func(function(e) {
+ assert_equals(e.ports.length, 2);
+ t.done();
+ });
+}, "MessageChannel's ports as MessagePort objects");
+
+test(() => {
+ var channel = new MessageChannel();
+ channel[0] = channel.port1;
+ channel[1] = channel.port2;
+ channel.length = 2;
+ assert_throws_js(TypeError,
+ () => { postMessage('', '*', channel) },
+ 'Old-style WebIDL arrays must throw a type error');
+}, "Old-style array objects");
+</script>
+