forked from chromium/chromium
-
-
Notifications
You must be signed in to change notification settings - Fork 17
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) - web-platform-tests/wpt#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 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2885636 Reviewed-by: Rakina Zata Amni <[email protected]> Reviewed-by: Arthur Sonzogni <[email protected]> Commit-Queue: Hiroshige Hayashizaki <[email protected]> Cr-Commit-Position: refs/heads/main@{#927566}
- Loading branch information
1 parent
b37e479
commit 66dbd4c
Showing
8 changed files
with
631 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
52 changes: 52 additions & 0 deletions
52
..._tests/external/wpt/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,52 @@ | ||
# 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. This is important to do to ensure the test would | ||
not fail normally and instead result in `PRECONDITION_FAILED` if the page is | ||
unexpectedly bfcached/not bfcached. | ||
- 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 ineligibility (which might be | ||
acceptable due to different BFCache eligibility criteria across browsers), | ||
`assert_bfcached()` and `assert_not_bfcached()` results in | ||
`PRECONDITION_FAILED` rather than ordinal failures. |
8 changes: 8 additions & 0 deletions
8
..._tests/external/wpt/html/browsers/browsing-the-web/back-forward-cache/events-expected.txt
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,8 @@ | ||
This is a testharness.js-based test. | ||
NOTRUN SameOrigin Should be BFCached but actually wasn't | ||
NOTRUN SameSite Should be BFCached but actually wasn't | ||
PASS CrossSite | ||
PASS beforeunload | ||
NOTRUN unload Should be BFCached but actually wasn't | ||
Harness: the test ran to completion. | ||
|
Oops, something went wrong.