-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1909902 [wpt PR 47290] - Shared Storage: Allow x-origin module sc…
…ript in addModule, a=testonly Automatic update from web-platform-tests Shared Storage: Allow x-origin module script in addModule The same-origin restriction for module script loaded by `sharedStorage.worklet.addModule()` is no longer needed, so we remove it. See WICG/shared-storage#158 and https://groups.google.com/a/chromium.org/g/blink-dev/c/YZ4XGewKVuk. Only cross-origin scripts loaded with createWorklet() that use the script origin as their data origin will need the "Shared-Storage-Cross-Origin-Worklet-Allowed: ?1" response header, however. To differentiate between worklets that need to be checked for this header and ones that don't, we add a new "Sec-Shared-Storage-Data-Origin" request header with the data origin used to the requests where the data origin is cross-origin to the context origin. We then use this information to determine if the "Shared-Storage-Cross-Origin-Worklet-Allowed" response header is needed. Bug: 348660660 Change-Id: I55f7f5d6d282b679505be5f23901f26ff7d7d374 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5648386 Commit-Queue: Cammie Smith Barnes <[email protected]> Reviewed-by: Andrey Kosyakov <[email protected]> Reviewed-by: Brendon Tiszka <[email protected]> Reviewed-by: Tsuyoshi Horo <[email protected]> Reviewed-by: Yao Xiao <[email protected]> Cr-Commit-Position: refs/heads/main@{#1332965} -- wpt-commits: c1ba090fe97109f63812fe90a4b612d602f6a87f wpt-pr: 47290
- Loading branch information
1 parent
001bd70
commit 3b9341c
Showing
5 changed files
with
86 additions
and
5 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
...web-platform/tests/shared-storage/add-module-cross-origin-script.tentative.https.sub.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,40 @@ | ||
<!doctype html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/common/utils.js"></script> | ||
<script src="/shared-storage/resources/util.js"></script> | ||
<script src="/fenced-frame/resources/utils.js"></script> | ||
|
||
<body> | ||
<script> | ||
'use strict'; | ||
|
||
promise_test(async t => { | ||
const sameOrigin = location.origin; | ||
const crossOrigin = 'https://{{domains[www]}}:{{ports[https][0]}}'; | ||
const crossOriginScript = crossOrigin | ||
+ "/shared-storage/resources/simple-module2.js"; | ||
await sharedStorage.worklet.addModule(crossOriginScript); | ||
|
||
const ancestor_key = token(); | ||
let url0 = generateURL("/shared-storage/resources/frame0.html", | ||
[ancestor_key]); | ||
let select_url_result = await sharedStorage.selectURL( | ||
"test-url-selection-operation", [{url: url0}], | ||
{data: {'mockResult': 0, 'setKey': 'a', 'setValue': 'b'}, | ||
resolveToConfig: true}); | ||
assert_true(validateSelectURLResult(select_url_result, true)); | ||
attachFencedFrame(select_url_result, 'opaque-ads'); | ||
const result = await nextValueFromServer(ancestor_key); | ||
assert_equals(result, "frame0_loaded"); | ||
|
||
// The invoking context's origin is used as the data origin. | ||
await verifyKeyValueForOrigin('a', 'b', sameOrigin); | ||
await verifyKeyNotFoundForOrigin('a', crossOrigin); | ||
|
||
// Clean up. | ||
return sharedStorage.delete('a'); | ||
}, 'addModule with cross-origin url'); | ||
|
||
</script> | ||
</body> |
25 changes: 25 additions & 0 deletions
25
.../tests/shared-storage/add-module-or-create-worklet-with-data-url.tentative.https.sub.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> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
|
||
<body> | ||
<script> | ||
'use strict'; | ||
|
||
promise_test(async t => { | ||
// Loading the worklet script uses CORS, which doesn't support the data | ||
// scheme. | ||
return promise_rejects_dom(t, "OperationError", | ||
sharedStorage.worklet.addModule( | ||
`data:application/javascript;alert("Hi!")`)); | ||
}, 'addModule() with data URL module script'); | ||
|
||
promise_test(async t => { | ||
// Opaque data origins are not permitted. | ||
return promise_rejects_dom(t, "InvalidAccessError", | ||
sharedStorage.createWorklet( | ||
`data:application/javascript;alert("Hi!")`)); | ||
}, 'createWorklet() with data URL module script and default data origin'); | ||
|
||
</script> | ||
</body> |
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
20 changes: 20 additions & 0 deletions
20
testing/web-platform/tests/shared-storage/resources/simple-module2.js
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,20 @@ | ||
// Copyright 2024 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
class TestURLSelectionOperation { | ||
async run(urls, data) { | ||
if (data && data.hasOwnProperty('setKey') && | ||
data.hasOwnProperty('setValue')) { | ||
await sharedStorage.set(data['setKey'], data['setValue']); | ||
} | ||
|
||
if (data && data.hasOwnProperty('mockResult')) { | ||
return data['mockResult']; | ||
} | ||
|
||
return -1; | ||
} | ||
} | ||
|
||
register('test-url-selection-operation', TestURLSelectionOperation); |
1 change: 1 addition & 0 deletions
1
testing/web-platform/tests/shared-storage/resources/simple-module2.js.headers
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 @@ | ||
Access-Control-Allow-Origin: * |