Skip to content

Commit

Permalink
Bug 1794144 [wpt PR 36333] - Add test for revalidated a cached worker…
Browse files Browse the repository at this point in the history
… 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
cdumez authored and moz-wptsync-bot committed Oct 21, 2022
1 parent ad57b4f commit 9cf63a5
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
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>
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'); };"

0 comments on commit 9cf63a5

Please sign in to comment.