зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1705302 [wpt PR 28501] - [Credentialless] Add tests for dedicated worker., a=testonly
Automatic update from web-platform-tests [Credentialless] Add tests for dedicated worker. (#28501) Change-Id: I5677d89ef762f8e67327ff857f19a631459fb904 Bug: 1199282, 1199754 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2825954 Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org> Reviewed-by: Yifan Luo <lyf@chromium.org> Commit-Queue: Yifan Luo <lyf@chromium.org> Cr-Commit-Position: refs/heads/master@{#873779} Co-authored-by: Yifan Luo <lyf@chromium.org> -- wpt-commits: 884ab466c4fc87141b35a35f399bba6b27f64c60 wpt-pr: 28501
This commit is contained in:
Родитель
c4a6c34ef2
Коммит
000619984d
|
@ -0,0 +1,102 @@
|
||||||
|
<!doctype html>
|
||||||
|
<title>CORS or Credentialless and dedicated worker</title>
|
||||||
|
<meta name="timeout" content="long">
|
||||||
|
<script src=/resources/testharness.js></script>
|
||||||
|
<script src=/resources/testharnessreport.js></script>
|
||||||
|
<script src="/common/get-host-info.sub.js"></script>
|
||||||
|
<script src="/common/utils.js"></script>
|
||||||
|
<script src="../resources/common.js"></script>
|
||||||
|
<script src="../resources/dispatcher.js"></script>
|
||||||
|
<script>
|
||||||
|
|
||||||
|
const same_origin = get_host_info().HTTPS_ORIGIN;
|
||||||
|
const cross_origin = get_host_info().HTTPS_REMOTE_ORIGIN;
|
||||||
|
const cookie_key = "credentialless_dedicated_worker";
|
||||||
|
const cookie_same_origin = "same_origin";
|
||||||
|
const cookie_cross_origin = "cross_origin";
|
||||||
|
|
||||||
|
promise_test(async test => {
|
||||||
|
|
||||||
|
await Promise.all([
|
||||||
|
setCookie(same_origin, cookie_key, cookie_same_origin),
|
||||||
|
setCookie(cross_origin, cookie_key, cookie_cross_origin),
|
||||||
|
]);
|
||||||
|
|
||||||
|
// One window with COEP:none. (control)
|
||||||
|
const w_control_token = token();
|
||||||
|
const w_control_url = same_origin + executor_path +
|
||||||
|
coep_none + `&uuid=${w_control_token}`
|
||||||
|
const w_control = window.open(w_control_url);
|
||||||
|
add_completion_callback(() => w_control.close());
|
||||||
|
|
||||||
|
// One window with COEP:credentialless. (experiment)
|
||||||
|
const w_credentialless_token = token();
|
||||||
|
const w_credentialless_url = same_origin + executor_path +
|
||||||
|
coep_credentialless + `&uuid=${w_credentialless_token}`;
|
||||||
|
const w_credentialless = window.open(w_credentialless_url);
|
||||||
|
add_completion_callback(() => w_credentialless.close());
|
||||||
|
|
||||||
|
const dedicatedWorkerTest = function(
|
||||||
|
description, origin, coep_for_worker,
|
||||||
|
expected_cookies_control,
|
||||||
|
expected_cookies_credentialless)
|
||||||
|
{
|
||||||
|
promise_test_parallel(async t => {
|
||||||
|
// Create workers for both window.
|
||||||
|
const worker_token_1 = token();
|
||||||
|
const worker_token_2 = token();
|
||||||
|
|
||||||
|
const w_worker_src_1 = same_origin + executor_js_path +
|
||||||
|
coep_for_worker + `&uuid=${worker_token_1}`;
|
||||||
|
send(w_control_token, `new Worker("${w_worker_src_1}", {});`);
|
||||||
|
|
||||||
|
const w_worker_src_2 = same_origin + executor_js_path +
|
||||||
|
coep_for_worker + `&uuid=${worker_token_2}`;
|
||||||
|
send(w_credentialless_token, `new Worker("${w_worker_src_2}", {});`);
|
||||||
|
|
||||||
|
// Fetch resources with the workers.
|
||||||
|
const request_token_1 = token();
|
||||||
|
const request_token_2 = token();
|
||||||
|
const request_url_1 = showRequestHeaders(origin, request_token_1);
|
||||||
|
const request_url_2 = showRequestHeaders(origin, request_token_2);
|
||||||
|
send(worker_token_1,
|
||||||
|
`fetch("${request_url_1}", {mode: 'no-cors', credentials: 'include'})`);
|
||||||
|
send(worker_token_2,
|
||||||
|
`fetch("${request_url_2}", {mode: 'no-cors', credentials: 'include'})`);
|
||||||
|
|
||||||
|
// Retrieve the resource request info.
|
||||||
|
const headers_control = JSON.parse(await receive(request_token_1));
|
||||||
|
const headers_credentialless = JSON.parse(await receive(request_token_2));
|
||||||
|
|
||||||
|
assert_equals(parseCookies(headers_control)[cookie_key],
|
||||||
|
expected_cookies_control,
|
||||||
|
"coep:none => ");
|
||||||
|
assert_equals(parseCookies(headers_credentialless)[cookie_key],
|
||||||
|
expected_cookies_credentialless,
|
||||||
|
"coep:credentialless => ");
|
||||||
|
}, `fetch ${description}`)
|
||||||
|
};
|
||||||
|
|
||||||
|
dedicatedWorkerTest("same-origin + credentialless worker",
|
||||||
|
same_origin, coep_credentialless,
|
||||||
|
cookie_same_origin,
|
||||||
|
cookie_same_origin);
|
||||||
|
|
||||||
|
dedicatedWorkerTest("same-origin",
|
||||||
|
same_origin, coep_none,
|
||||||
|
cookie_same_origin,
|
||||||
|
cookie_same_origin);
|
||||||
|
|
||||||
|
dedicatedWorkerTest("cross-origin",
|
||||||
|
cross_origin, coep_none,
|
||||||
|
cookie_cross_origin,
|
||||||
|
cookie_cross_origin);
|
||||||
|
|
||||||
|
dedicatedWorkerTest("cross-origin + credentialless worker",
|
||||||
|
cross_origin, coep_credentialless,
|
||||||
|
undefined,
|
||||||
|
undefined);
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
|
@ -1,5 +1,6 @@
|
||||||
const directory = '/html/cross-origin-embedder-policy/credentialless';
|
const directory = '/html/cross-origin-embedder-policy/credentialless';
|
||||||
const executor_path = directory + '/resources/executor.html?pipe=';
|
const executor_path = directory + '/resources/executor.html?pipe=';
|
||||||
|
const executor_js_path = directory + '/resources/executor.js?pipe=';
|
||||||
|
|
||||||
// COEP
|
// COEP
|
||||||
const coep_none =
|
const coep_none =
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
importScripts('./dispatcher.js');
|
||||||
|
|
||||||
|
const params = new URLSearchParams(location.search);
|
||||||
|
const uuid = params.get('uuid');
|
||||||
|
|
||||||
|
let executeOrders = async function() {
|
||||||
|
while(true) {
|
||||||
|
let task = await receive(uuid);
|
||||||
|
eval(`(async () => {${task}})()`);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
executeOrders();
|
Загрузка…
Ссылка в новой задаче