Source code

Revision control

Copy as Markdown

Other Tools

<!DOCTYPE html>
<html>
<title>navigator.globalPrivacyControl Window</title>
<head>
<script src="/resources/testharness.js"></script>
</head>
<body>
<div id="log"></div>
<script>
setup({explicit_done: true});
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const expectedValue = urlParams.has("gpc", "true");
test(function(t) {
assert_equals(navigator.globalPrivacyControl, expectedValue, "Expected navigator.globalPrivacyControl value is read from the window");
}, `Expected navigator.globalPrivacyControl value (${expectedValue}) is read from the window`);
async function run() {
await Promise.all([
fetch_tests_from_worker(new Worker(`navigator-globalPrivacyControl.js?gpc=${expectedValue}&workerType=dedicated`)),
fetch_tests_from_worker(new SharedWorker(`navigator-globalPrivacyControl.js?gpc=${expectedValue}&workerType=shared`)),
]);
let r = await navigator.serviceWorker.register(
`navigator-globalPrivacyControl.js?gpc=${expectedValue}&workerType=service`,
{scope: `blank.html`});
let sw = r.active || r.installing || r.waiting;
await fetch_tests_from_worker(sw),
await r.unregister();
done();
}
run();
</script>
</body>
</html>