Skip to content

Commit c7a0f09

Browse files
sisidovskimoz-wptsync-bot
authored andcommitted
Bug 1879240 [wpt PR 44460] - Use OK status to check RaceNetworkRequest response, a=testonly
Automatic update from web-platform-tests Use OK status to check RaceNetworkRequest response Reflecting the comment on yoshisatoyanagisawa/ServiceWorker#10 (comment) Bug: 1371756 Change-Id: I6de1fed384e32fbdae40799ef48d4ce2eeb3eccd Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5276401 Reviewed-by: Minoru Chikamune <[email protected]> Reviewed-by: Yoshisato Yanagisawa <[email protected]> Reviewed-by: Kouhei Ueno <[email protected]> Commit-Queue: Shunya Shishido <[email protected]> Cr-Commit-Position: refs/heads/main@{#1257762} -- wpt-commits: 4c4bec5ff51e2230e4d3ee69773c608ae255f04d wpt-pr: 44460
1 parent 2d02f30 commit c7a0f09

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

testing/web-platform/tests/service-workers/service-worker/tentative/static-router/resources/direct.py

+4
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,8 @@
44
def main(request, response):
55
if 'server_slow' in request.url_parts.query:
66
time.sleep(0.2)
7+
if 'server_no_content' in request.url_parts.query:
8+
return 204, [(b'Content-Type', b'text/plain')], u'Network with %s request' % request.method
9+
if 'server_not_found' in request.url_parts.query:
10+
return 404, [(b'Content-Type', b'text/plain')], u'Not Found'
711
return 200, [(b'Content-Type', b'text/plain')], u'Network with %s request' % request.method

testing/web-platform/tests/service-workers/service-worker/tentative/static-router/static-router-race-network-and-fetch-handler.https.html

+26
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,31 @@
6161
const {requests} = await get_info_from_worker(worker);
6262
assert_equals(requests.length, 2);
6363
}, 'Subresource load matched the rule with race-network-and-fetch-handler source, and the server reseponse is faster than the fetch handler');
64+
65+
promise_test(async t => {
66+
const rnd = randomString();
67+
const worker = await registerAndActivate(t, ROUTER_KEY, SW_SRC);
68+
const iframe = await createIframe(t, FRAME_SRC);
69+
// Expect the response from the network request.
70+
const response = await iframe.contentWindow.fetch(`?nonce=${rnd}&sw_slow&server_no_content`);
71+
assert_equals(response.status, 204);
72+
// Ensure the fetch handler is also executed.
73+
const {requests} = await get_info_from_worker(worker);
74+
assert_equals(requests.length, 2);
75+
}, 'Subresource load matched the rule with race-network-and-fetch-handler source, and the server reseponse with 204 response is faster than the fetch handler');
76+
77+
78+
promise_test(async t => {
79+
const rnd = randomString();
80+
const worker = await registerAndActivate(t, ROUTER_KEY, SW_SRC);
81+
const iframe = await createIframe(t, FRAME_SRC);
82+
const response = await iframe.contentWindow.fetch(`?nonce=${rnd}&sw_slow&server_not_found`);
83+
// Expect the response from the network request was faster, but the result was 404.
84+
// So, the fetch handler result will be used instead.
85+
assert_equals(response.status, 200);
86+
assert_equals(await response.text(), rnd);
87+
const {requests} = await get_info_from_worker(worker);
88+
assert_equals(requests.length, 2);
89+
}, 'Subresource load matched the rule with race-network-and-fetch-handler source, and the server reseponse is faster than the fetch handler, but not found');
6490
</script>
6591
</body>

0 commit comments

Comments
 (0)