Skip to content

Commit

Permalink
[html] Avoid race condition in test
Browse files Browse the repository at this point in the history
  • Loading branch information
jugglinmike authored and zcorpan committed Feb 21, 2017
1 parent fdb80c1 commit 8c1d027
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
9 changes: 8 additions & 1 deletion html/browsers/the-window-object/support/noopener-target.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,12 @@
var channel = new BroadcastChannel(channelName);
channel.postMessage({ name: window.name,
haveOpener: window.opener !== null });
window.close();

// Because messages are not delivered synchronously and because closing a
// browsing context prompts the eventual clearing of all task sources, this
// document should not be closed until the opener document has confirmed
// receipt.
channel.onmessage = function() {
window.close();
};
</script>
5 changes: 4 additions & 1 deletion html/browsers/the-window-object/window-open-noopener.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@
} else {
t.step(function() {
var w1;
this.add_cleanup(function() { w1.close(); });
this.add_cleanup(function() {
w1.close();
channel.postMessage(null);
});

var windowName = this.windowName;
var channel = new BroadcastChannel(windowName);
Expand Down

0 comments on commit 8c1d027

Please sign in to comment.