-
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.
Test which document history.go(0) reloads
See whatwg/html#2436. Specified in whatwg/html#6315.
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
html/browsers/history/the-history-interface/history_go_zero_which_document.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,27 @@ | ||
// META: title=history.go(0) on an iframe must reload the iframe's document, not the parent document | ||
// META: script=/common/dispatcher/dispatcher.js | ||
// META: script=/common/utils.js | ||
// META: script=/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js | ||
|
||
promise_test(async () => { | ||
const rcHelper = new RemoteContextHelper(); | ||
const main = await rcHelper.addWindow(); | ||
const iframe = await main.addIframe(); | ||
|
||
await main.executeScript(() => { | ||
window.didNotGetReloaded = true; | ||
|
||
const iframe = document.querySelector("iframe"); | ||
|
||
// This goes beyond the original test case in https://github.com/whatwg/html/issues/2436, and | ||
// tests where current realm != relevant realm. The spec says to use relevant realm so the | ||
// result is still, iframe must reload, not parent. | ||
History.prototype.go.call(iframe.contentWindow.history, 0); | ||
|
||
return new Promise(resolve => { | ||
iframe.addEventListener("load", resolve); | ||
}); | ||
}); | ||
|
||
assert_true(await main.executeScript(() => window.didNotGetReloaded)); | ||
}); |