From d3dfe276ddb4138f147933d9dfa64d636a41af89 Mon Sep 17 00:00:00 2001 From: Youssef Bourouphael Date: Fri, 10 May 2024 16:17:07 -0700 Subject: [PATCH] Revert "Reland "Reland "Service worker web platform tests.""" This reverts commit 9bd67ed90e90d6a2c2134d26bb8bcc4cd9436b19. Reason for revert: Failing in some cases. Original change's description: > Reland "Reland "Service worker web platform tests."" > > This reverts commit 93a580699ecf6d102a5853455b5faeceea4cd31e. > > Reason for revert: Removed the test case that times out, > (the one that waits for the update url). > > Original change's description: > > Revert "Reland "Service worker web platform tests."" > > > > This reverts commit 436f1b9f6153002fd41599d5d4ec8343cf930a43. > > > > Reason for revert: There are still timeouts in some tests > > > > Original change's description: > > > Reland "Service worker web platform tests." > > > > > > This reverts commit 36a1c457dac0ecaa54c0553b28f67c0c61752494. > > > > > > Reason for revert: The test that looks for 'update-url.py' takes too long and therefore will require this test file to be part of slowTests > > > > > > Original change's description: > > > > Revert "Service worker web platform tests." > > > > > > > > This reverts commit 63858f1b1ed058d07e73cebb0a98214aa2cfc715. > > > > > > > > Reason for revert: New test added; fails immediately on some bots. > > > > > > > > See > > > > https://ci.chromium.org/ui/p/chromium/builders/ci/mac11-arm64-rel-tests/38089/overview > > > > for the first failures. (And consistently in subsequent builds) > > > > > > > > Original change's description: > > > > > Service worker web platform tests. > > > > > > > > > > This tests that when an auction is ran, service workers do not intercept requests with URLs that are meant to be private. > > > > > > > > > > > > > > > Bug: 293383734 > > > > > Change-Id: I06858f7cae4794a35c045fb8dad30d6316a26ead > > > > > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5459094 > > > > > Commit-Queue: Youssef Bourouphael > > > > > Reviewed-by: mmenke > > > > > Reviewed-by: Orr Bernstein > > > > > Cr-Commit-Position: refs/heads/main@{#1294960} > > > > > > > > Bug: 293383734 > > > > Change-Id: I3431f0e45e65767ff1529002d8a2d14657d0cb5a > > > > No-Presubmit: true > > > > No-Tree-Checks: true > > > > No-Try: true > > > > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5506634 > > > > Auto-Submit: Ian Clelland > > > > Owners-Override: Ian Clelland > > > > Commit-Queue: Rubber Stamper > > > > Bot-Commit: Rubber Stamper > > > > Cr-Commit-Position: refs/heads/main@{#1295015} > > > > > > Bug: 293383734 > > > Change-Id: I762dd50282f99617796df64d73a27d149cac0a86 > > > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5512083 > > > Commit-Queue: Youssef Bourouphael > > > Bot-Commit: Rubber Stamper > > > Reviewed-by: Orr Bernstein > > > Reviewed-by: mmenke > > > Cr-Commit-Position: refs/heads/main@{#1296948} > > > > Bug: 293383734 > > Change-Id: I9b06c0453656aaa448d0030960a48fc264bcf867 > > No-Presubmit: true > > No-Tree-Checks: true > > No-Try: true > > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5515623 > > Auto-Submit: Youssef Bourouphael > > Commit-Queue: Rubber Stamper > > Commit-Queue: mmenke > > Reviewed-by: mmenke > > Bot-Commit: Rubber Stamper > > Cr-Commit-Position: refs/heads/main@{#1297048} > > Bug: 293383734 > Change-Id: I7ae169c2750432bb1cb9c1c340585dc27d8cd419 > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5521778 > Commit-Queue: Youssef Bourouphael > Bot-Commit: Rubber Stamper > Reviewed-by: mmenke > Reviewed-by: Orr Bernstein > Cr-Commit-Position: refs/heads/main@{#1298807} Bug: 293383734 Change-Id: I182736b58e83dbe7fc2c5fc7e20a3e3f909772a2 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5526425 Bot-Commit: Rubber Stamper Commit-Queue: Youssef Bourouphael Cr-Commit-Position: refs/heads/main@{#1298902} --- fledge/tentative/TODO | 3 - fledge/tentative/service-worker-helper.js | 49 ------- ...-worker-request-visibility.https.window.js | 123 ------------------ 3 files changed, 175 deletions(-) delete mode 100644 fledge/tentative/service-worker-helper.js delete mode 100644 fledge/tentative/service-worker-request-visibility.https.window.js diff --git a/fledge/tentative/TODO b/fledge/tentative/TODO index 0d29efcc9a9df2..8760e59d21f6f4 100644 --- a/fledge/tentative/TODO +++ b/fledge/tentative/TODO @@ -96,6 +96,3 @@ If possible: but maybe a test where batching could be used, and make sure things work, whether batching is used or not? * reporting timeout being 0. -* Test that service workers cannot see update urls. - * This was attempted in [here](https://chromium-review.googlesource.com/c/chromium/src/+/5512083), - but needed to be reverted because it kept timing out, [see here](https://g-issues.chromium.org/issues/339048485) diff --git a/fledge/tentative/service-worker-helper.js b/fledge/tentative/service-worker-helper.js deleted file mode 100644 index dfcd1379d737f5..00000000000000 --- a/fledge/tentative/service-worker-helper.js +++ /dev/null @@ -1,49 +0,0 @@ -"use strict;" - -const privateRequests = ['resources/trusted-bidding-signals.py', - 'update-url.py', // This requires another test, since it takes a while, - // see TODO file for more info. - 'wasm-helper.py', - 'bidding-logic.py', - 'decision-logic.py', - 'trusted-scoring-signals.py', - 'trusted-bidding-signals.py', - 'bidder_report', - 'seller_report']; -const publicRequests = ['direct-from-seller-signals.py']; - -// The service worker intercepts fetch calls and uses -// pre-defined lists to categorize requests as "public" -// or "private". It broadcasts a success/failure status -// on the appropriate BroadcastChannel. -self.addEventListener('fetch', (event) => { - const privateRequestChannel = new BroadcastChannel('private-requests-test'); - const publicRequestChannel = new BroadcastChannel('public-requests-test'); - - privateRequests.forEach(privateRequest => { - if (event.request.url.includes(privateRequest)) { - privateRequestChannel.postMessage({ - result: 'failed', - message: "service worker should not have seen: " + - privateRequest - }); - } - }); - - publicRequests.forEach(publicRequest => { - if (event.request.url.includes(publicRequest)) { - publicRequestChannel.postMessage({ - result: 'passed', - message: "service worker properly saw: " + - publicRequest - }); - } - }); - - // This endpoint is specifically for the 'private-requests-test' to signal - // completion and ensure proper BroadcastChannel response behavior. - if (event.request.url.includes('COMPLETE-TEST')) { - privateRequestChannel.postMessage({result:'completed'}); - } -}); - diff --git a/fledge/tentative/service-worker-request-visibility.https.window.js b/fledge/tentative/service-worker-request-visibility.https.window.js deleted file mode 100644 index c533c9cf61de80..00000000000000 --- a/fledge/tentative/service-worker-request-visibility.https.window.js +++ /dev/null @@ -1,123 +0,0 @@ -// META: script=/resources/testdriver.js -// META: script=/common/utils.js -// META: script=resources/fledge-util.sub.js -// META: script=/common/subset-tests.js -// META: timeout=long -// META: variant=?1-last - -"use strict;" - -const SERVICE_WORKER_SCRIPT = "service-worker-helper.js"; - -async function setUpServiceWorkerAndGetBroadcastChannel(broadcastChannelName) { - await registerServiceWorker(); - await checkServiceWorkersAndReload(); - return new BroadcastChannel(broadcastChannelName); -} - -// In order to validate a service worker, its scriptURL should -// be the one we registered in registerServiceWorker(). -function validateServiceWorker() { - if (navigator.serviceWorker.controller) { - return navigator.serviceWorker.controller.scriptURL.includes(SERVICE_WORKER_SCRIPT); - } - return false; -} - -// Prepares the test environment by ensuring a valid service worker -// registration. Reloads the page if no service worker is found or -// if it's not registered correctly. -async function checkServiceWorkersAndReload() { - let count = (await navigator.serviceWorker.getRegistrations()).length; - if (count === 0 || !validateServiceWorker()) { - window.location.reload(); - } -} - -// Registers a service worker to the current scope. -async function registerServiceWorker() { - try { - await navigator.serviceWorker.register(`./${SERVICE_WORKER_SCRIPT}`); - await navigator.serviceWorker.ready; - } catch (error) { - throw (Error, "Error while registering service worker: " + error); - } -} - -// Tests that public requests are seen by the service worker. -// Specifically anything that contains: -// - 'direct-from-seller-signals.py' - -// This test works by having the service worker send a message over -// the broadcastChannel, if it sees a request that contains any of -// the following strings above, it will send a 'passed' result and -// also change the variable 'finish_test', to true, so that guarantees -// that the request was seen before we complete the test. -subsetTest(promise_test, async test => { - const broadcastChannel = await setUpServiceWorkerAndGetBroadcastChannel('public-requests-test'); - - let finishTest = new Promise((resolve, reject) => { - broadcastChannel.addEventListener('message', (event) => { - if (event.data.result === 'passed') { - resolve(); - } else { - reject(`unexpected result: ${event.data.message}`); - } - }); - }); - - await fetchDirectFromSellerSignals({ 'Buyer-Origin': window.location.origin }); - await finishTest; -}, "Make sure service workers do see public requests."); - -// Tests that private requests are not seen by the service worker. -// Specifically anything that contains: -// - 'resources/trusted-bidding-signals.py' -// - 'resources/trusted-scoring-signals.py' -// - 'wasm-helper.py' -// - 'bidding-logic.py' -// - 'decision-logic.py' -// - 'seller_report' -// - 'bidder_report' - -// This test works by having the service worker send a message -// over the broadcastChannel, if it sees a request that contains -// any of the following strings above, it will send a 'failed' -// result which will cause assert_false case to fail. -subsetTest(promise_test, async test => { - const uuid = generateUuid(test); - const broadcastChannel = await setUpServiceWorkerAndGetBroadcastChannel('private-requests-test'); - - let finishTest = new Promise((resolve, reject) => { - broadcastChannel.addEventListener('message', (event) => { - if (event.data.result === 'completed') { - resolve(); - } else { - reject(`unexpected result: ${event.data.message}`); - } - }); - }); - broadcastChannel.addEventListener('message', (event) => { - assert_false(event.data.result === 'failed', - /*errorMessage=*/event.data.message); - }); - let interestGroupOverrides = { - biddingWasmHelperURL: `${RESOURCE_PATH}wasm-helper.py`, - trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL, - trustedScoringSignalsURL: TRUSTED_SCORING_SIGNALS_URL, - }; - - await joinInterestGroup(test, uuid, interestGroupOverrides); - await runBasicFledgeAuctionAndNavigate(test, uuid); - // By verifying that these requests are observed we can assume - // none of the other requests were seen by the service-worker. - await waitForObservedRequests( - uuid, - [createBidderReportURL(uuid), createSellerReportURL(uuid)]); - - // Service worker will post a 'completed' result when it sees a fetch request with - // 'COMPLETE-TEST' within the URL. This let's us ensure that the service worker's - // 'postMessage' has nothing pending. - await fetch('COMPLETE-TEST'); - await finishTest; -}, "Make sure service workers do not see private requests");