update broadcastchannel test to reflect closed check move into queued task.

This commit is contained in:
Gregory Terzian 2020-02-20 16:37:22 +08:00
parent eb21d5f738
commit 99e4d740e4
3 changed files with 16 additions and 8 deletions

View file

@ -550029,7 +550029,7 @@
],
"broadcastchannel": {
"basics.html": [
"ed16e32f5437dc430b5cc11b967e6538ef6cf393",
"3d8ba76fb1ba35658c44702059925fe53e3fb6f6",
[
null,
{}

View file

@ -10971,7 +10971,7 @@
[]
],
"interfaces.js": [
"c46c336f8a8a2db777f75d6236b1241c717a02dd",
"689016240d603459ee1b633a5e80009291376396",
[]
],
"nested_asap_script.js": [
@ -13863,14 +13863,14 @@
]
],
"interfaces.html": [
"163ab416b1627e07347b83aa210712364182343a",
"12f1d0b7f17be6575d4527423aed0ec845c4c2d5",
[
null,
{}
]
],
"interfaces.worker.js": [
"3f77783a6cc31e7803dd61873ba17c92ce12eccc",
"c1223084790b2980c8184e3cd9ab5ae17bc8b303",
[
"mozilla/interfaces.worker.html",
{}

View file

@ -69,6 +69,17 @@ async_test(t => {
c1.postMessage('test');
}, 'messages aren\'t delivered to a closed port');
async_test(t => {
let c1 = new BroadcastChannel('closed');
let c2 = new BroadcastChannel('closed');
let c3 = new BroadcastChannel('closed');
c2.onmessage = t.unreached_func();
c3.onmessage = t.step_func(() => t.done());
c1.postMessage('test');
c2.close();
}, 'messages aren\'t delivered to a port closed after calling postMessage.');
async_test(t => {
let c1 = new BroadcastChannel('create-in-onmessage');
let c2 = new BroadcastChannel('create-in-onmessage');
@ -87,8 +98,6 @@ async_test(t => {
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');
@ -108,13 +117,12 @@ async_test(t => {
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');
}, 'Closing a channel in onmessage prevents already queued tasks from firing onmessage events');
</script>