Files
firefox/testing/web-platform/tests/shared-storage/add-module-cross-origin-script.tentative.https.sub.html
Camillia Smith Barnes 7b21265e02 Bug 1909902 [wpt PR 47290] - Shared Storage: Allow x-origin module script 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 https://github.com/WICG/shared-storage/pull/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
2024-07-30 06:57:15 +00:00

41 lines
1.4 KiB
HTML

<!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>