-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HTML: compare window sizing for noopener/noreferrer
For whatwg/html#3297.
- Loading branch information
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
html/browsers/the-window-object/noopener-noreferrer-sizing.window.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const windowProps = ["innerWidth", "innerHeight"]; | ||
|
||
["noopener", "noreferrer"].forEach(openerStyle => { | ||
async_test(t => { | ||
const channelName = "34342" + openerStyle + "8907"; | ||
const channel = new BroadcastChannel(channelName); | ||
window.open("support/sizing-target.html?" + channelName, "", openerStyle); | ||
channel.onmessage = t.step_func_done(e => { | ||
// Send message first so if asserts throw the popup is still closed | ||
channel.postMessage(null); | ||
|
||
for(const prop of windowProps) { | ||
assert_equals(window[prop], e.data[prop]); | ||
} | ||
}); | ||
}, `window.open() with ${openerStyle} should have equal viewport width and height`); | ||
}); |
17 changes: 17 additions & 0 deletions
17
html/browsers/the-window-object/support/sizing-target.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!DOCTYPE html> | ||
<script> | ||
const windowProps = ["innerWidth", "innerHeight"]; | ||
const windowPropsObj = {}; | ||
const channelName = location.search.substr(1); | ||
const channel = new BroadcastChannel(channelName); | ||
for (const prop of windowProps) { | ||
windowPropsObj[prop] = window[prop]; | ||
} | ||
channel.postMessage(windowPropsObj); | ||
|
||
// 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 = () => { window.close() }; | ||
</script> |