Skip to content
This repository was archived by the owner on Mar 19, 2021. It is now read-only.

Commit 4fd7cb2

Browse files
nhirokiHexcles
authored andcommitted
Worker: Add upgrade-insecure-requests tests for top-level classic shared worker script loading
This CL changes the code generator of upgrade-insecure-requests tests to add tests for top-level classic shared worker script loading. The test files (shared-worker-(redirect-)upgrade.https.html) are generated by external/wpt/upgrade-insecure-requests/support/generate.py. Bug: 917532, 989399 Change-Id: If4a3f27c6c8fe08e55dc8d86a8cbf925596490fa Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1728570 Commit-Queue: Hiroki Nakagawa <[email protected]> Reviewed-by: Hiroshige Hayashizaki <[email protected]> Cr-Commit-Position: refs/heads/master@{#683445}
1 parent dbe28e6 commit 4fd7cb2

File tree

4 files changed

+55
-2
lines changed

4 files changed

+55
-2
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<!-- Generated by wpt/upgrade-insecure-requests/support/generate.py -->
5+
<title>Upgrade Insecure Requests: shared-worker.</title>
6+
<script src="/resources/testharness.js"></script>
7+
<script src="/resources/testharnessreport.js"></script>
8+
<script src="./support/testharness-helper.sub.js"></script>
9+
<script src="/common/security-features/resources/common.js"></script>
10+
11+
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
12+
</head>
13+
<body>
14+
<script>
15+
const tests = generateRedirectTests(ResourceType.SHARED_WORKER, true);
16+
tests.forEach(test => testMap['shared-worker'](test));
17+
</script>
18+
</body>
19+
</html>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<!-- Generated by wpt/upgrade-insecure-requests/support/generate.py -->
5+
<title>Upgrade Insecure Requests: shared-worker.</title>
6+
<script src="/resources/testharness.js"></script>
7+
<script src="/resources/testharnessreport.js"></script>
8+
<script src="./support/testharness-helper.sub.js"></script>
9+
<script src="/common/security-features/resources/common.js"></script>
10+
11+
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
12+
</head>
13+
<body>
14+
<script>
15+
const tests = generateTests(ResourceType.SHARED_WORKER, true);
16+
tests.forEach(test => testMap['shared-worker'](test));
17+
</script>
18+
</body>
19+
</html>

upgrade-insecure-requests/support/generate.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,19 @@ def getLong(file):
4040
('worker', 'WORKER'),
4141
('module-worker', 'WORKER'),
4242
('worker-subresource-xhr', 'FETCH'),
43-
('worker-subresource-fetch', 'FETCH')]:
44-
sameOriginOnly = 'true' if resourceType == 'WORKER' else 'false'
43+
('worker-subresource-fetch', 'FETCH'),
44+
('shared-worker', 'SHARED_WORKER')]:
45+
# TODO(https://crbug.com/989399): Add tests for subresource requests on shared
46+
# workers, and main/subresource requests on service workers.
47+
48+
sameOriginOnly = 'false'
49+
if resourceType == 'WORKER' or resourceType == 'SHARED_WORKER':
50+
sameOriginOnly = 'true'
51+
4552
types = [('', 'generateTests'), ('-redirect', 'generateRedirectTests')]
4653
if name == 'module-worker' or resourceType == 'WORKLET':
4754
types.append(('-import', 'generateModuleImportTests'))
55+
4856
for typeName, generatorName in types:
4957
filename = '%s%s-upgrade.https.html' % (name, typeName)
5058
with open(filename, 'w') as html_file:

upgrade-insecure-requests/support/testharness-helper.sub.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const ResourceType = {
1212
IMAGE: "image",
1313
FRAME: "frame",
1414
WORKER: "worker",
15+
SHARED_WORKER: "shared-worker",
1516
WORKLET: "worklet",
1617
WEBSOCKET: "websocket",
1718
FETCH: "fetch",
@@ -36,6 +37,8 @@ function generateURL(host, protocol, resourceType) {
3637
url.pathname = "echo";
3738
} else if (resourceType == ResourceType.WORKER) {
3839
url.pathname += "worker.py";
40+
} else if (resourceType == ResourceType.SHARED_WORKER) {
41+
url.pathname += "shared-worker.py";
3942
} else if (resourceType == ResourceType.WORKLET) {
4043
url.pathname += "worker.py";
4144
} else if (resourceType == ResourceType.FETCH) {
@@ -184,6 +187,10 @@ const testMap = {
184187
{}),
185188
test.name),
186189

190+
"shared-worker":
191+
test => promise_test(
192+
() => requestViaSharedWorker(test.url), test.name),
193+
187194
"audio-worklet":
188195
test => promise_test(
189196
() => requestViaWorklet('audio', test.url), test.name),

0 commit comments

Comments
 (0)