-
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 1794144 [wpt PR 36333] - Add test for revalidated a cached worker…
… script from a COEP: require-…, a=testonly Automatic update from web-platform-tests Add test for revalidated a cached worker script from a COEP: require-corp document (#36333) This is an upstream for WebKit's WebKit/WebKit#5141. -- wpt-commits: 1bfc087117907a450fc7971c1527a69c80ccb086 wpt-pr: 36333
- Loading branch information
1 parent
ad57b4f
commit 9cf63a5
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
...form/tests/html/cross-origin-embedder-policy/require-corp-worker-script-revalidation.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,25 @@ | ||
<!doctype html> | ||
<title>COEP and dedicated worker</title> | ||
<script src=/resources/testharness.js></script> | ||
<script src=/resources/testharnessreport.js></script> | ||
<script src="/common/get-host-info.sub.js"></script> | ||
<script src="resources/worker-support.js"></script> | ||
<body> | ||
<script> | ||
|
||
promise_test(async (t) => { | ||
const worker1 = new Worker("/html/cross-origin-embedder-policy/resources/dedicated-worker-supporting-revalidation.py"); | ||
worker1.onerror = t.unreached_func('Worker.onerror should not be called for first worker'); | ||
worker1.postMessage("foo"); | ||
const result1 = await waitForMessage(worker1); | ||
assert_equals(result1.data, 'LOADED'); | ||
|
||
// Load the worker a second time, which should trigger revalidation of the cached resource. | ||
const worker2 = new Worker("/html/cross-origin-embedder-policy/resources/dedicated-worker-supporting-revalidation.py"); | ||
worker2.onerror = t.unreached_func('Worker.onerror should not be called worker second worker'); | ||
worker2.postMessage("foo"); | ||
const result2 = await waitForMessage(worker2); | ||
assert_equals(result2.data, 'LOADED'); | ||
}, 'COEP: require-corp with revalidated worker script'); | ||
</script> | ||
</body> |
15 changes: 15 additions & 0 deletions
15
...s/html/cross-origin-embedder-policy/resources/dedicated-worker-supporting-revalidation.py
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,15 @@ | ||
#!/usr/bin/env python | ||
|
||
|
||
def main(request, response): | ||
headers = [] | ||
if request.headers.get(b'if-none-match', None): | ||
status = 304, u"Not Modified" | ||
return status, headers, u"" | ||
else: | ||
headers.append((b"Content-Type", b"text/javascript")) | ||
headers.append((b"Cross-Origin-Embedder-Policy", b"require-corp")) | ||
headers.append((b"Cache-Control", b"private, max-age=0, must-revalidate")) | ||
headers.append((b"ETag", b"abcdef")) | ||
status = 200, u"OK" | ||
return status, headers, u"self.onmessage = (e) => { self.postMessage('LOADED'); };" |