-
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.
[WPT] Introduce
RemoteContext.execute_script()
and add basic BFCach…
…e tests + helpers This PR adds `RemoteContext.execute_script()` and its documentation in `/common/dispatcher/`. This is based on with `execute_script()`-related parts of RFCs 88/89/91: - web-platform-tests/rfcs#88 - web-platform-tests/rfcs#89 - web-platform-tests/rfcs#91 and addresses comments: - web-platform-tests/rfcs#86 (comment) - #28950 (comment) plus additional clarifications around navigation, minus `testdriver` integration (so this PR is implemented using `send()`/`receive()` in `/common/dispatcher/`), minus web-platform-tests/rfcs#90 (so this PR leaves `send()`/`receive()` as-is). This PR also adds back-forward cache WPTs (basic event firing tests), as well as BFCache-specific helpers, based on `RemoteContext.execute_script()`. Design doc: https://docs.google.com/document/d/1p3G-qNYMTHf5LU9hykaXcYtJ0k3wYOwcdVKGeps6EkU/edit?usp=sharing Bug: 1107415 Change-Id: I034f9f5376dc3f9f32ca0b936dbd06e458c9160b
- Loading branch information
1 parent
87caf6d
commit b05460d
Showing
7 changed files
with
602 additions
and
12 deletions.
There are no files selected for viewing
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
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
50 changes: 50 additions & 0 deletions
50
html/browsers/browsing-the-web/back-forward-cache/README.md
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,50 @@ | ||
# How to write back-forward cache tests | ||
|
||
In the back-forward cache tests, the main test HTML usually: | ||
|
||
1. Opens new executor Windows using `window.open()` + `noopener` option, | ||
because less isolated Windows (e.g. iframes and `window.open()` without | ||
`noopener` option) are often not eligible for back-forward cache (e.g. | ||
in Chromium). | ||
2. Injects scripts to the executor Windows and receives the results via | ||
`RemoteContext.execute_script()` by | ||
[/common/dispatcher](../../../../common/dispatcher/README.md). | ||
Follow the semantics and guideline described there. | ||
|
||
Back-forward cache specific helpers are in: | ||
|
||
- [resources/executor.html](resources/executor.html): | ||
The BFCache-specific executor and contains helpers for executors. | ||
- [resources/helper.sub.js](resources/helper.sub.js): | ||
Helpers for main test HTMLs. | ||
|
||
We must ensure that injected scripts are evaluated only after page load | ||
(more precisely, the first `pageshow` event) and not during navigation, | ||
to prevent unexpected interference between injected scripts, in-flight fetch | ||
requests behind `RemoteContext.execute_script()`, navigation and back-forward | ||
cache. To ensure this, | ||
|
||
- Call `await remoteContext.execute_script(waitForPageShow)` before any | ||
other scripts are injected to the remote context, and | ||
- Call `prepareNavigation(callback)` synchronously from the script injected | ||
by `RemoteContext.execute_script()`, and trigger navigation on or after the | ||
callback is called. | ||
|
||
In typical A-B-A scenarios (where we navigate from Page A to Page B and then | ||
navigate back to Page A, assuming Page A is (or isn't) in BFCache), | ||
|
||
- Call `prepareNavigation()` on the executor, and then navigate to B, and then | ||
navigate back to Page A. | ||
- Call `assert_bfcached()` or `assert_not_bfcached()` on the main test HTML, to | ||
check the BFCache status. | ||
- Check other test expectations on the main test HTML, | ||
|
||
as in [events.html](./events.html) and `runEventTest()` in | ||
[resources/helper.sub.js](resources/helper.sub.js). | ||
|
||
# Asserting PRECONDITION_FAILED for unexpected BFCache eligibility | ||
|
||
To distinguish failures due to unexpected BFCache eligibility (which might be | ||
acceptable due to different BFCache eligibility criteria across browsers), | ||
`assert_bfcached()` and `assert_not_bfcached()` asserts `PRECONDITION_FAILED` | ||
rather than ordinal failures. |
Oops, something went wrong.