-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1794378 [wpt PR 36368] - history.state during a bfcache traversal…
…, a=testonly Automatic update from web-platform-tests history.state during a bfcache traversal Per whatwg/html#6652, it must not get serialized and deserialized. -- wpt-commits: 7d60342ce41a95f4db1e57dd324917a9bc8bf730 wpt-pr: 36368
- Loading branch information
1 parent
f02b87c
commit c2be01e
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
...m/tests/html/browsers/history/the-history-interface/history-state-after-bfcache.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,43 @@ | ||
// META: title=Navigating back to a bfcached page does not reset history.state | ||
// 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 | ||
|
||
// See https://github.com/whatwg/html/issues/6652. | ||
|
||
'use strict'; | ||
|
||
promise_test(async t => { | ||
const rcHelper = new RemoteContextHelper(); | ||
|
||
// Open a window with noopener so that BFCache will work. | ||
const rc = await rcHelper.addWindow(null, { features: "noopener" }); | ||
|
||
// Add a pageshow listener to stash the event, and set history.state using replaceState(). | ||
await rc.executeScript(() => { | ||
window.addEventListener('pageshow', (event) => { | ||
window.pageshowEvent = event; | ||
}); | ||
|
||
history.replaceState({ foo: 'bar' }, '', ''); | ||
window.stashedHistoryState = history.state; | ||
}); | ||
|
||
const rc2 = await rc.navigateToNew(); | ||
await rc2.historyBack(); | ||
|
||
assert_implements_optional( | ||
await rc.executeScript(() => window.pageshowEvent.persisted), | ||
'precondition: document was bfcached' | ||
); | ||
|
||
assert_equals( | ||
await rc.executeScript(() => history.state.foo), | ||
'bar', | ||
'history.state was restored correctly' | ||
); | ||
|
||
assert_true( | ||
await rc.executeScript(() => window.stashedHistoryState === history.state), | ||
'history.state did not get serialized and deserialized'); | ||
}); |