-
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.
WPTs for
fetch-event
source in the static routing API
This CL adds tests to the case if the service worker has router rules containing `fetch-event` source. Bug: 1519727 Change-Id: I3ddff71418c7c50d95b089bcd87362b263fd1e8a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5252633 Reviewed-by: Yoshisato Yanagisawa <[email protected]> Commit-Queue: Shunya Shishido <[email protected]> Cr-Commit-Position: refs/heads/main@{#1254403}
- Loading branch information
1 parent
ef0aff0
commit 3087c1e
Showing
2 changed files
with
41 additions
and
0 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
39 changes: 39 additions & 0 deletions
39
service-workers/service-worker/tentative/static-router/static-router-fetch-event.https.html
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,39 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title> | ||
Static Router: routers are evaluated with the fetch-event source. | ||
</title> | ||
<script src="/common/get-host-info.sub.js"></script> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/service-workers/service-worker/resources/test-helpers.sub.js"> | ||
</script> | ||
<script src="resources/static-router-helpers.sub.js"> | ||
</script> | ||
<body> | ||
<script> | ||
const ROUTER_KEY = 'condition-urlpattern-string-source-fetch-event'; | ||
const REGISTERED_ROUTE = 'resources/simple.html'; | ||
|
||
promise_test(async t => { | ||
const worker = await registerAndActivate(t, ROUTER_KEY); | ||
const rnd = randomString(); | ||
const iframe = await createIframe(t, `${REGISTERED_ROUTE}?nonce=${rnd}`); | ||
const {errors, requests} = await get_info_from_worker(worker); | ||
|
||
assert_equals(errors.length, 0); | ||
assert_equals(requests.length, 1); | ||
assert_equals(iframe.contentWindow.document.body.innerText, rnd); | ||
}, 'Main resource matched the rule with fetch-event source'); | ||
|
||
iframeTest(REGISTERED_ROUTE, ROUTER_KEY, async (t, iwin, worker) => { | ||
const rnd = randomString(); | ||
const response = await iwin.fetch(`?nonce=${rnd}`); | ||
assert_equals(response.status, 200); | ||
assert_equals(await response.text(), rnd); | ||
const {requests} = await get_info_from_worker(worker); | ||
// Main resource request + subreosurce request = 2. | ||
assert_equals(requests.length, 2); | ||
}, 'Subresource load matched the rule fetch-event source'); | ||
</script> | ||
</body> |