From ca5eea1b1cdaaeb1aa4dae2341802b0dc796f504 Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Thu, 13 Oct 2022 16:09:20 +0000 Subject: [PATCH] Bug 1794371 [wpt PR 36366] - Test which document history.go(0) reloads, a=testonly Automatic update from web-platform-tests Test which document history.go(0) reloads See https://github.com/whatwg/html/issues/2436. Specified in https://github.com/whatwg/html/pull/6315. -- wpt-commits: df228765793c58a9a7aa25c8b808df529e049122 wpt-pr: 36366 --- .../history_go_zero_which_document.window.js | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 testing/web-platform/tests/html/browsers/history/the-history-interface/history_go_zero_which_document.window.js diff --git a/testing/web-platform/tests/html/browsers/history/the-history-interface/history_go_zero_which_document.window.js b/testing/web-platform/tests/html/browsers/history/the-history-interface/history_go_zero_which_document.window.js new file mode 100644 index 0000000000000..f697783f3e586 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/history/the-history-interface/history_go_zero_which_document.window.js @@ -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(); + 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)); +});