tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 9d85c195d43edb5e8e1e6015b401653902862751
parent 893e048f8bf82fec1e90305ef8e10a1101912786
Author: Guohui Deng <guohuideng@microsoft.com>
Date:   Mon, 10 Nov 2025 22:18:43 +0000

Bug 1998721 [wpt PR 55910] - [WPT] Fix a flaky test resource_dedicated_worker.html., a=testonly

Automatic update from web-platform-tests
[WPT] Fix a flaky test resource_dedicated_worker.html.

It's flakey because the number of resource timing entries depends
on whether `favicon.ico` request is included or not.

Reference:
https://github.com/web-platform-tests/interop/issues/1078#issuecomment-3433226375

A more reliable way to verify the resources from workers don't appear in
the main document, is to verify the resources from workers don't appear
in the main document.

.

Bug: 454485904
Change-Id: I375fa1191ee3ae594cb5302679ccd5195b9baaa2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7081867
Reviewed-by: Noam Rosenthal <nrosenthal@google.com>
Commit-Queue: Guohui Deng <guohuideng@microsoft.com>
Reviewed-by: Michal Mocny <mmocny@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1541263}

--

wpt-commits: a015768bfde4271261fe5cb33664fd2e8f0d5260
wpt-pr: 55910

Diffstat:
Mtesting/web-platform/tests/resource-timing/resource_dedicated_worker.html | 50++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 44 insertions(+), 6 deletions(-)

diff --git a/testing/web-platform/tests/resource-timing/resource_dedicated_worker.html b/testing/web-platform/tests/resource-timing/resource_dedicated_worker.html @@ -9,16 +9,54 @@ <script src="/resources/testharnessreport.js"></script> <script src="resources/webperftestharness.js"></script> <script src="resources/webperftestharnessextension.js"></script> -<link rel="stylesheet" href="resources/resource_timing_test0.css" /> +<script src="/common/get-host-info.sub.js"></script> <script> -setup({explicit_done: true}); + +const mainDocResource = "/images/red.png?noCacheResourceDedicatedWorker"; +// Resources below are requested in the worker thread +// "resources/worker_with_images.js". +const workerResources = [ + "/resource-timing/resources/blue.png", + "/resource-timing/resources/resource_timing_test0.png", +]; + +const {promise: mainDocPromise, resolve: resolveMainDoc} = Promise.withResolvers(); +const {promise: workerPromise, resolve: resolveWorker} = Promise.withResolvers(); + +// Load main document resource +var xhr = new XMLHttpRequest; +xhr.open('get', mainDocResource, true); +xhr.onload = function() { + resolveMainDoc(); +} +xhr.send(); + const worker = new Worker("resources/worker_with_images.js"); worker.onmessage = function(event) { - const context = new PerformanceContext(window.performance); - const entries = context.getEntriesByType('resource'); - test_equals(entries.length, 6, "There should be six entries: 4 scripts, 1 stylesheet, and the worker itself"); - done(); + resolveWorker(); } + +promise_test(async () => { + await Promise.all([ + mainDocPromise, + workerPromise, + ]); + + const context = new PerformanceContext(window.performance); + + // The main doc resource appears in the main document. + const mainDocResourceUrl = new URL(mainDocResource, get_host_info().HTTP_ORIGIN).href; + const mainDocEntries = context.getEntriesByName(mainDocResourceUrl); + assert_greater_than(mainDocEntries.length, 0, "main doc resource appears"); + + // On the other hand, the worker resources don't. + for(resource of workerResources) { + let workerResourceUrl = new URL(resource, get_host_info().HTTP_ORIGIN).href; + let workerEntries = context.getEntriesByName(workerResourceUrl); + assert_equals(workerEntries.length, 0, "worker resources don't appear"); + } +}, "Verify that resources requested by dedicated workers don't appear in the main document"); + </script> </head> <body>