mirror of
https://github.com/HeyPuter/firefox.git
synced 2026-11-13 20:14:57 -10:00
Automatic update from web-platform-tests Shared Storage: Align createWorklet's default data origin w/addModule's We align the default data origin for createWorklet with that of addModule to be the invoking context's origin. We also hook up the dataOrigin option in createWorklet's options dictionary, so that the script origin can be manually specified to be used as the data origin instead. See https://github.com/WICG/shared-storage/pull/158, https://github.com/WICG/shared-storage/pull/161, and https://groups.google.com/a/chromium.org/g/blink-dev/c/YZ4XGewKVuk. Bug: 353738488 Change-Id: I3578e48f14c9fb1005211b94889ce01ef209162c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5716903 Reviewed-by: Yao Xiao <[email protected]> Commit-Queue: Cammie Smith Barnes <[email protected]> Cr-Commit-Position: refs/heads/main@{#1333189} -- wpt-commits: 71b107815a391a469b081cbb9242e1723ede50fb wpt-pr: 47296
72 lines
2.7 KiB
HTML
72 lines
2.7 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';
|
|
|
|
async function verifyStoreCookieCrossOriginCreateWorkletIncludeCredentials(
|
|
helper_url_params, data_origin_option) {
|
|
const ancestor_key = token();
|
|
const crossOrigin = 'https://{{domains[www]}}:{{ports[https][0]}}';
|
|
const set_cookie_url = crossOrigin + `/cookies/resources/set-cookie.py` +
|
|
`?name=key0` +
|
|
`&path=/shared-storage/`;
|
|
const helper_url = crossOrigin +
|
|
`/shared-storage/resources/credentials-test-helper.py` +
|
|
helper_url_params + `&token=${ancestor_key}`;
|
|
|
|
await fetch(set_cookie_url, { mode: 'no-cors', credentials: 'include' });
|
|
|
|
const options = (data_origin_option === '') ? { credentials: "include" }
|
|
: { credentials: "include", dataOrigin: data_origin_option };
|
|
|
|
const worklet = await sharedStorage.createWorklet(
|
|
helper_url + `&action=store-cookie`, options);
|
|
|
|
const request_cookie_fetch_response =
|
|
await fetch(helper_url + `&action=get-cookie`);
|
|
|
|
const request_cookie_text = await request_cookie_fetch_response.text();
|
|
|
|
assert_equals(request_cookie_text, "key0=1");
|
|
}
|
|
|
|
promise_test(async () => {
|
|
const helper_url_params =
|
|
`?access_control_allow_origin_header=${window.origin}` +
|
|
`&access_control_allow_credentials_header=true`;
|
|
|
|
await verifyStoreCookieCrossOriginCreateWorkletIncludeCredentials(
|
|
helper_url_params, /*data_origin_option=*/'');
|
|
}, 'createWorklet() with cross-origin module script, credentials "include",'
|
|
+ 'and default data origin (context origin).');
|
|
|
|
promise_test(async () => {
|
|
const helper_url_params =
|
|
`?access_control_allow_origin_header=${window.origin}` +
|
|
`&access_control_allow_credentials_header=true`;
|
|
|
|
await verifyStoreCookieCrossOriginCreateWorkletIncludeCredentials(
|
|
helper_url_params, /*data_origin_option=*/'context-origin');
|
|
}, 'createWorklet() with cross-origin module script, credentials "include",'
|
|
+ 'and "context-origin" as dataOrigin.');
|
|
|
|
promise_test(async () => {
|
|
const helper_url_params =
|
|
`?access_control_allow_origin_header=${window.origin}` +
|
|
`&access_control_allow_credentials_header=true` +
|
|
`&shared_storage_cross_origin_worklet_allowed_header=?1`;
|
|
|
|
await verifyStoreCookieCrossOriginCreateWorkletIncludeCredentials(
|
|
helper_url_params, /*data_origin_option=*/'script-origin');
|
|
}, 'createWorklet() with cross-origin module script, credentials "include",'
|
|
+ 'and "script-origin" as dataOrigin.');
|
|
|
|
</script>
|
|
</body>
|