mirror of
https://github.com/servo/servo.git
synced 2025-09-04 12:08:21 +01:00
Update web-platform-tests to revision 3137d1d2d7757366a69f8a449b458b5057e0e81e
This commit is contained in:
parent
81ca858678
commit
d6ba94ca28
2339 changed files with 89274 additions and 9328 deletions
|
@ -1,5 +1,5 @@
|
|||
@zqzhang
|
||||
@plehegar
|
||||
@aogilvie
|
||||
@Ms2ger
|
||||
@jdm
|
||||
@mkruisselbrink
|
||||
|
|
|
@ -0,0 +1,120 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
|
||||
async_test(t => {
|
||||
let c1 = new BroadcastChannel('eventType');
|
||||
let c2 = new BroadcastChannel('eventType');
|
||||
|
||||
c2.onmessage = t.step_func(e => {
|
||||
assert_true(e instanceof MessageEvent);
|
||||
assert_equals(e.target, c2);
|
||||
assert_equals(e.type, 'message');
|
||||
assert_equals(e.origin, location.origin, 'origin');
|
||||
assert_equals(e.data, 'hello world');
|
||||
assert_equals(e.source, null, 'source');
|
||||
t.done();
|
||||
});
|
||||
c1.postMessage('hello world');
|
||||
}, 'postMessage results in correct event');
|
||||
|
||||
async_test(t => {
|
||||
let c1 = new BroadcastChannel('order');
|
||||
let c2 = new BroadcastChannel('order');
|
||||
let c3 = new BroadcastChannel('order');
|
||||
|
||||
let events = [];
|
||||
let doneCount = 0;
|
||||
let handler = t.step_func(e => {
|
||||
events.push(e);
|
||||
if (e.data == 'done') {
|
||||
doneCount++;
|
||||
if (doneCount == 2) {
|
||||
assert_equals(events.length, 6);
|
||||
assert_equals(events[0].target, c2, 'target for event 0');
|
||||
assert_equals(events[0].data, 'from c1');
|
||||
assert_equals(events[1].target, c3, 'target for event 1');
|
||||
assert_equals(events[1].data, 'from c1');
|
||||
assert_equals(events[2].target, c1, 'target for event 2');
|
||||
assert_equals(events[2].data, 'from c3');
|
||||
assert_equals(events[3].target, c2, 'target for event 3');
|
||||
assert_equals(events[3].data, 'from c3');
|
||||
assert_equals(events[4].target, c1, 'target for event 4');
|
||||
assert_equals(events[4].data, 'done');
|
||||
assert_equals(events[5].target, c3, 'target for event 5');
|
||||
assert_equals(events[5].data, 'done');
|
||||
t.done();
|
||||
}
|
||||
}
|
||||
});
|
||||
c1.onmessage = handler;
|
||||
c2.onmessage = handler;
|
||||
c3.onmessage = handler;
|
||||
|
||||
c1.postMessage('from c1');
|
||||
c3.postMessage('from c3');
|
||||
c2.postMessage('done');
|
||||
}, 'messages are delivered in port creation order');
|
||||
|
||||
async_test(t => {
|
||||
let c1 = new BroadcastChannel('closed');
|
||||
let c2 = new BroadcastChannel('closed');
|
||||
let c3 = new BroadcastChannel('closed');
|
||||
|
||||
c2.onmessage = t.unreached_func();
|
||||
c2.close();
|
||||
c3.onmessage = t.step_func(() => t.done());
|
||||
c1.postMessage('test');
|
||||
}, 'messages aren\'t delivered to a closed port');
|
||||
|
||||
async_test(t => {
|
||||
let c1 = new BroadcastChannel('create-in-onmessage');
|
||||
let c2 = new BroadcastChannel('create-in-onmessage');
|
||||
|
||||
c2.onmessage = t.step_func(e => {
|
||||
assert_equals(e.data, 'first');
|
||||
c2.close();
|
||||
let c3 = new BroadcastChannel('create-in-onmessage');
|
||||
c3.onmessage = t.step_func(event => {
|
||||
assert_equals(event.data, 'done');
|
||||
t.done();
|
||||
});
|
||||
c1.postMessage('done');
|
||||
});
|
||||
c1.postMessage('first');
|
||||
c2.postMessage('second');
|
||||
}, 'closing and creating channels during message delivery works correctly');
|
||||
|
||||
// TODO(mek): Depending on https://github.com/whatwg/html/issues/1371 adjust
|
||||
// this test to match the correct behavior.
|
||||
async_test(t => {
|
||||
let c1 = new BroadcastChannel('close-in-onmessage');
|
||||
let c2 = new BroadcastChannel('close-in-onmessage');
|
||||
let c3 = new BroadcastChannel('close-in-onmessage');
|
||||
let events = [];
|
||||
c1.onmessage = e => events.push('c1: ' + e.data);
|
||||
c2.onmessage = e => events.push('c2: ' + e.data);
|
||||
c3.onmessage = e => events.push('c3: ' + e.data);
|
||||
|
||||
// c2 closes itself when it receives the first message
|
||||
c2.addEventListener('message', e => {
|
||||
c2.close();
|
||||
});
|
||||
|
||||
c3.addEventListener('message', t.step_func(e => {
|
||||
if (e.data == 'done') {
|
||||
assert_array_equals(events, [
|
||||
'c2: first',
|
||||
'c3: first',
|
||||
'c2: done',
|
||||
'c3: done']);
|
||||
t.done();
|
||||
}
|
||||
}));
|
||||
c1.postMessage('first');
|
||||
c1.postMessage('done');
|
||||
}, 'Closing a channel in onmessage doesn\'t cancel already queued events');
|
||||
|
||||
</script>
|
|
@ -0,0 +1,79 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
|
||||
async_test(t => {
|
||||
const c1 = new BroadcastChannel('blob');
|
||||
const c2 = new BroadcastChannel('blob');
|
||||
const c3 = new BroadcastChannel('blob');
|
||||
|
||||
let readCount = 0;
|
||||
c2.onmessage = t.step_func(e => {
|
||||
// check blob
|
||||
assert_true('blob' in e.data);
|
||||
assert_true(e.data.blob instanceof Blob);
|
||||
assert_equals(e.data.blob.size, 6);
|
||||
const reader = new FileReader();
|
||||
reader.onerror = t.unreached_func();
|
||||
reader.onload = t.step_func(() => {
|
||||
assert_equals(reader.result, 'foobar');
|
||||
if (++readCount == 2)
|
||||
t.done();
|
||||
});
|
||||
reader.readAsText(e.data.blob);
|
||||
});
|
||||
c3.onmessage = c2.onmessage;
|
||||
c1.postMessage({blob: new Blob(['foo', 'bar'])});
|
||||
}, 'Blobs work on BroadcastChannel');
|
||||
|
||||
async_test(t => {
|
||||
const c1 = new BroadcastChannel('blobworker');
|
||||
const c2 = new BroadcastChannel('blobworker');
|
||||
const events = [];
|
||||
|
||||
const verifyEvents = function() {
|
||||
assert_equals(events.length, 5);
|
||||
assert_equals(events[0], 'from worker');
|
||||
assert_equals(events[1], 'from worker');
|
||||
assert_true(events[2].blob instanceof Blob);
|
||||
assert_equals(events[2].blob.size, 11);
|
||||
assert_true(events[3].blob instanceof Blob);
|
||||
assert_equals(events[3].blob.size, 11);
|
||||
assert_equals(events[4], 'done');
|
||||
const reader = new FileReader();
|
||||
reader.onerror = t.unreached_func();
|
||||
reader.onload = t.step_func(() => {
|
||||
assert_equals(reader.result, 'hello-world');
|
||||
t.done();
|
||||
});
|
||||
reader.readAsText(events[3].blob);
|
||||
};
|
||||
|
||||
let receivedDone = false;
|
||||
let receivedWorkerDone = false;
|
||||
|
||||
c1.onmessage = e => events.push(e.data);
|
||||
c2.onmessage = e => events.push(e.data);
|
||||
c2.addEventListener('message', t.step_func(e => {
|
||||
if (e.data.blob)
|
||||
c1.postMessage('done');
|
||||
if (e.data === 'done')
|
||||
receivedDone = true;
|
||||
if (receivedDone && receivedWorkerDone)
|
||||
verifyEvents();
|
||||
}));
|
||||
|
||||
const worker = new Worker('resources/worker.js');
|
||||
worker.onmessage = t.step_func(e => {
|
||||
receivedWorkerDone = true;
|
||||
if (receivedDone && receivedWorkerDone)
|
||||
verifyEvents();
|
||||
});
|
||||
worker.postMessage({channel: 'blobworker'});
|
||||
worker.postMessage({blob: ['hello-world']});
|
||||
|
||||
}, 'Blobs work with workers on BroadcastChannel');
|
||||
|
||||
</script>
|
|
@ -0,0 +1,73 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
|
||||
test(() => assert_throws(new TypeError(), () => new BroadcastChannel()),
|
||||
'Should throw if no name is provided');
|
||||
|
||||
test(() => {
|
||||
let c = new BroadcastChannel(null);
|
||||
assert_equals(c.name, 'null');
|
||||
}, 'Null name should not throw');
|
||||
|
||||
test(() => {
|
||||
let c = new BroadcastChannel(undefined);
|
||||
assert_equals(c.name, 'undefined');
|
||||
}, 'Undefined name should not throw');
|
||||
|
||||
test(() => {
|
||||
let c = new BroadcastChannel('fooBar');
|
||||
assert_equals(c.name, 'fooBar');
|
||||
}, 'Non-empty name should not throw');
|
||||
|
||||
test(() => {
|
||||
let c = new BroadcastChannel(123);
|
||||
assert_equals(c.name, '123');
|
||||
}, 'Non-string name should not throw');
|
||||
|
||||
test(() => {
|
||||
let c = new BroadcastChannel('');
|
||||
assert_throws(new TypeError(), () => c.postMessage());
|
||||
}, 'postMessage without parameters should throw');
|
||||
|
||||
test(() => {
|
||||
let c = new BroadcastChannel('');
|
||||
c.postMessage(null);
|
||||
}, 'postMessage with null should not throw');
|
||||
|
||||
test(() => {
|
||||
let c = new BroadcastChannel('');
|
||||
c.close();
|
||||
}, 'close should not throw');
|
||||
|
||||
test(() => {
|
||||
let c = new BroadcastChannel('');
|
||||
c.close();
|
||||
c.close();
|
||||
}, 'close should not throw when called multiple times');
|
||||
|
||||
test(() => {
|
||||
let c = new BroadcastChannel('');
|
||||
c.close();
|
||||
assert_throws('InvalidStateError', () => c.postMessage(''));
|
||||
}, 'postMessage after close should throw');
|
||||
|
||||
test(() => {
|
||||
let c = new BroadcastChannel('');
|
||||
assert_not_equals(c.onmessage, undefined);
|
||||
}, 'BroadcastChannel should have an onmessage event');
|
||||
|
||||
test(() => {
|
||||
let c = new BroadcastChannel('');
|
||||
assert_throws('DataCloneError', () => c.postMessage(Symbol()));
|
||||
}, 'postMessage should throw with uncloneable data');
|
||||
|
||||
test(() => {
|
||||
let c = new BroadcastChannel('');
|
||||
c.close();
|
||||
assert_throws('InvalidStateError', () => c.postMessage(Symbol()));
|
||||
}, 'postMessage should throw InvalidStateError after close, even with uncloneable data');
|
||||
|
||||
</script>
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<script>
|
||||
try {
|
||||
let c = new BroadcastChannel('foo');
|
||||
parent.postMessage('Created', '*');
|
||||
} catch (e) {
|
||||
parent.postMessage('Exception: ' + e.name, '*');
|
||||
}
|
||||
</script>
|
|
@ -0,0 +1,26 @@
|
|||
var c;
|
||||
|
||||
function handler(e, reply) {
|
||||
if (e.data.ping) {
|
||||
c.postMessage(e.data.ping);
|
||||
return;
|
||||
}
|
||||
if (e.data.blob) {
|
||||
c.postMessage({blob: new Blob(e.data.blob)});
|
||||
}
|
||||
c = new BroadcastChannel(e.data.channel);
|
||||
let messages = [];
|
||||
c.onmessage = e => {
|
||||
messages.push(e.data);
|
||||
if (e.data == 'done')
|
||||
reply(messages);
|
||||
};
|
||||
c.postMessage('from worker');
|
||||
}
|
||||
|
||||
onmessage = e => handler(e, postMessage);
|
||||
|
||||
onconnect = e => {
|
||||
let port = e.ports[0];
|
||||
port.onmessage = e => handler(e, msg => port.postMessage(msg));
|
||||
};
|
|
@ -0,0 +1,16 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>Creating BroadcastChannel in an opaque origin</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<body>
|
||||
<script>
|
||||
async_test(t => {
|
||||
self.onmessage = t.step_func(e => {
|
||||
assert_equals(e.data, 'Created');
|
||||
t.done();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<iframe sandbox="allow-scripts" src="resources/sandboxed.html"></iframe>
|
||||
</body>
|
|
@ -0,0 +1,108 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
|
||||
async_test(t => {
|
||||
let c1 = new BroadcastChannel('worker');
|
||||
let c2 = new BroadcastChannel('worker');
|
||||
let events = [];
|
||||
|
||||
c1.onmessage = e => events.push(e);
|
||||
c2.onmessage = e => events.push(e);
|
||||
|
||||
let doneCount = 0;
|
||||
c2.addEventListener('message', t.step_func(e => {
|
||||
if (e.data == 'from worker') {
|
||||
c2.postMessage('from c2');
|
||||
c1.postMessage('done');
|
||||
} else if (e.data == 'done') {
|
||||
assert_equals(events.length, 4);
|
||||
assert_equals(events[0].data, 'from worker');
|
||||
assert_equals(events[0].target, c1);
|
||||
assert_equals(events[1].data, 'from worker');
|
||||
assert_equals(events[1].target, c2);
|
||||
assert_equals(events[2].data, 'from c2');
|
||||
assert_equals(events[3].data, 'done');
|
||||
if (++doneCount == 2) t.done();
|
||||
}
|
||||
}));
|
||||
|
||||
let worker = new Worker('resources/worker.js');
|
||||
worker.onmessage = t.step_func(e => {
|
||||
assert_array_equals(e.data, ['from c2', 'done']);
|
||||
if (++doneCount == 2) t.done();
|
||||
});
|
||||
worker.postMessage({channel: 'worker'});
|
||||
|
||||
}, 'BroadcastChannel works in workers');
|
||||
|
||||
async_test(t => {
|
||||
let c1 = new BroadcastChannel('shared worker');
|
||||
let c2 = new BroadcastChannel('shared worker');
|
||||
let events = [];
|
||||
|
||||
c1.onmessage = e => events.push(e);
|
||||
c2.onmessage = e => events.push(e);
|
||||
|
||||
let doneCount = 0;
|
||||
c2.addEventListener('message', t.step_func(e => {
|
||||
if (e.data == 'from worker') {
|
||||
c2.postMessage('from c2');
|
||||
c1.postMessage('done');
|
||||
} else if (e.data == 'done') {
|
||||
assert_equals(events.length, 4);
|
||||
assert_equals(events[0].data, 'from worker');
|
||||
assert_equals(events[0].target, c1);
|
||||
assert_equals(events[1].data, 'from worker');
|
||||
assert_equals(events[1].target, c2);
|
||||
assert_equals(events[2].data, 'from c2');
|
||||
assert_equals(events[3].data, 'done');
|
||||
if (++doneCount == 2) t.done();
|
||||
}
|
||||
}));
|
||||
|
||||
let worker = new SharedWorker('resources/worker.js');
|
||||
worker.port.onmessage = t.step_func(e => {
|
||||
assert_array_equals(e.data, ['from c2', 'done']);
|
||||
if (++doneCount == 2) t.done();
|
||||
});
|
||||
worker.port.postMessage({channel: 'shared worker'});
|
||||
|
||||
}, 'BroadcastChannel works in shared workers');
|
||||
|
||||
async_test(t => {
|
||||
let c = new BroadcastChannel('worker-close');
|
||||
let events = [];
|
||||
|
||||
c.onmessage = e => events.push('c1: ' + e.data);
|
||||
|
||||
let worker = new Worker('resources/worker.js');
|
||||
worker.onmessage = t.step_func(e => {
|
||||
assert_array_equals(events, ['c1: from worker', 'c2: echo'],
|
||||
'messages in document');
|
||||
assert_array_equals(e.data, ['done'], 'messages in worker');
|
||||
t.done();
|
||||
});
|
||||
|
||||
c.addEventListener('message', e => {
|
||||
if (e.data == 'from worker') {
|
||||
c.close();
|
||||
if (self.gc) self.gc();
|
||||
window.setTimeout(() => {
|
||||
let c2 = new BroadcastChannel('worker-close');
|
||||
c2.onmessage = e => {
|
||||
events.push('c2: ' + e.data);
|
||||
c2.postMessage('done');
|
||||
};
|
||||
worker.postMessage({ping: 'echo'});
|
||||
}, 1);
|
||||
}
|
||||
});
|
||||
|
||||
worker.postMessage({channel: 'worker-close'});
|
||||
|
||||
}, 'Closing and re-opening a channel works.');
|
||||
|
||||
</script>
|
|
@ -0,0 +1,74 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/comms.html#dom-messageport-close">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
// How long (in ms) these tests should wait before deciding no further messages
|
||||
// will be received.
|
||||
const time_to_wait_for_messages = 100;
|
||||
|
||||
async_test(t => {
|
||||
const c = new MessageChannel();
|
||||
c.port1.onmessage = t.unreached_func('Should not have delivered message');
|
||||
c.port1.close();
|
||||
c.port2.postMessage('TEST');
|
||||
setTimeout(t.step_func_done(), time_to_wait_for_messages);
|
||||
}, 'Message sent to closed port should not arrive.');
|
||||
|
||||
async_test(t => {
|
||||
const c = new MessageChannel();
|
||||
c.port1.onmessage = t.unreached_func('Should not have delivered message');
|
||||
c.port2.close();
|
||||
c.port2.postMessage('TEST');
|
||||
setTimeout(t.step_func_done(), time_to_wait_for_messages);
|
||||
}, 'Message sent from closed port should not arrive.');
|
||||
|
||||
async_test(t => {
|
||||
const c = new MessageChannel();
|
||||
c.port1.onmessage = t.unreached_func('Should not have delivered message');
|
||||
c.port1.close();
|
||||
const c2 = new MessageChannel();
|
||||
c2.port1.onmessage = t.step_func(e => {
|
||||
e.ports[0].postMessage('TESTMSG');
|
||||
setTimeout(t.step_func_done(), time_to_wait_for_messages);
|
||||
});
|
||||
c2.port2.postMessage('TEST', [c.port2]);
|
||||
}, 'Message sent to closed port from transferred port should not arrive.');
|
||||
|
||||
async_test(t => {
|
||||
const c = new MessageChannel();
|
||||
c.port1.onmessage = t.unreached_func('Should not have delivered message');
|
||||
c.port2.close();
|
||||
const c2 = new MessageChannel();
|
||||
c2.port1.onmessage = t.step_func(e => {
|
||||
e.ports[0].postMessage('TESTMSG');
|
||||
setTimeout(t.step_func_done(), time_to_wait_for_messages);
|
||||
});
|
||||
c2.port2.postMessage('TEST', [c.port2]);
|
||||
}, 'Message sent from transferred closed port should not arrive.');
|
||||
|
||||
async_test(t => {
|
||||
const c = new MessageChannel();
|
||||
let isClosed = false;
|
||||
c.port1.onmessage = t.step_func_done(e => {
|
||||
assert_true(isClosed);
|
||||
assert_equals(e.data, 'TEST');
|
||||
});
|
||||
c.port2.postMessage('TEST');
|
||||
c.port2.close();
|
||||
isClosed = true;
|
||||
}, 'Inflight messages should be delivered even when sending port is closed afterwards.');
|
||||
|
||||
async_test(t => {
|
||||
const c = new MessageChannel();
|
||||
c.port1.onmessage = t.step_func_done(e => {
|
||||
if (e.data == 'DONE') t.done();
|
||||
assert_equals(e.data, 'TEST');
|
||||
c.port1.close();
|
||||
});
|
||||
c.port2.postMessage('TEST');
|
||||
c.port2.postMessage('DONE');
|
||||
}, 'Close in onmessage should not cancel inflight messages.');
|
||||
|
||||
</script>
|
|
@ -2,13 +2,18 @@
|
|||
<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>
|
||||
<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() {
|
||||
window[0].postMessage('', '*', []);
|
||||
window[0].onmessage = this.step_func(function(e) {
|
||||
assert_equals(e.origin, location.protocol + '//' + location.host);
|
||||
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();
|
||||
});
|
||||
|
|
|
@ -5,12 +5,14 @@
|
|||
<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();
|
||||
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>
|
||||
|
|
|
@ -4,12 +4,8 @@
|
|||
<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();
|
||||
});
|
||||
test(function(t) {
|
||||
assert_throws(new TypeError, () => postMessage('', '*', null));
|
||||
});
|
||||
</script>
|
||||
|
||||
|
|
|
@ -2,13 +2,18 @@
|
|||
<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>
|
||||
<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() {
|
||||
window[0].postMessage('', '*');
|
||||
window[0].onmessage = this.step_func(function(e) {
|
||||
assert_equals(e.origin, location.protocol + '//' + location.host);
|
||||
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();
|
||||
});
|
||||
|
|
|
@ -5,12 +5,14 @@
|
|||
<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();
|
||||
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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue