Files
sousa-gecko/testing/web-platform/tests/js-self-profiling/with-document-policy/dedicated-worker-data.https.html
T
Monica Chintala 48eafe51c7 Bug 2021195 [wpt PR 58274] - Allow JS Self-Profiling in Dedicated Workers, a=testonly
Automatic update from web-platform-tests
Allow JS Self-Profiling in Dedicated Workers

Document Policy is now inherited by Dedicated Workers (see
https://chromium-review.googlesource.com/c/chromium/src/+/7236250).

This change allows the JS Self-Profiling API to be used in workers when
Document Policy is enabled and the js-profiling feature is allowed via
the Document-Policy: js-profiling response header.

This CL also adds WPT tests to verify that Dedicated Workers can use the
profiling API when the js-profiling feature is enabled through Document
Policy.

Spec PR (merged) - https://github.com/WICG/js-self-profiling/pull/88
ChromeStatus - https://chromestatus.com/feature/5159559872249856 I2P -
https://groups.google.com/a/chromium.org/d/msgid/blink-dev/69975252.050a0220.1f729.0da6.GAE%40google.com

Bug: 482085416
Change-Id: Ica61d6d2169926095f29f7a82e482acba56c7fc2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7546208
Reviewed-by: Scott Haseley <shaseley@chromium.org>
Commit-Queue: Monica Chintala <monicach@microsoft.com>
Reviewed-by: Liang Zhao <lzhao@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#1594390}

--

wpt-commits: a8eccee92ad9f1160d03c228126a1d7bfd803c73
wpt-pr: 58274
2026-03-12 15:56:11 +00:00

32 lines
1.2 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
// A data: URL worker should inherit Document-Policy from the creator
// document, allowing profiling when the creator has js-profiling enabled.
promise_test(async t => {
const workerScript = `
try {
new Profiler({ sampleInterval: 10, maxBufferSize: Number.MAX_SAFE_INTEGER });
self.postMessage({ success: true, message: 'Profiler created' });
} catch (e) {
self.postMessage({ success: false, error: e.name, message: e.message });
}
`;
const worker = new Worker('data:text/javascript,' + encodeURIComponent(workerScript));
const result = await new Promise((resolve, reject) => {
worker.onmessage = e => resolve(e.data);
worker.onerror = e => reject(new Error(e.message));
});
assert_true(result.success,
'profiling should succeed in data: dedicated worker with inherited document policy');
worker.terminate();
}, 'data: dedicated worker should inherit js-profiling policy from creator document');
</script>
</body>
</html>