From 77653938ac7fd8cbde6d7bacb724e2bdb707c38a Mon Sep 17 00:00:00 2001 From: Jonathan Njeunje Date: Wed, 29 Mar 2023 12:45:58 -0700 Subject: [PATCH] Fix Flaky WPT external/wpt/storage/partitioned-estimate-usage-details-caches.tentative.https.sub.html Bug: 1407355 Change-Id: I7046d50d763c19049610ae7cfa5837903bb8f043 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4378219 Auto-Submit: Jonathan Njeunje Reviewed-by: Ben Kelly Commit-Queue: Ben Kelly Cr-Commit-Position: refs/heads/main@{#1123766} --- ...ge-details-caches.tentative.https.sub.html | 19 ++++++++++++------- ...ate-usage-details-caches-helper-frame.html | 2 ++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/storage/partitioned-estimate-usage-details-caches.tentative.https.sub.html b/storage/partitioned-estimate-usage-details-caches.tentative.https.sub.html index 2eac826eb10d2e..dc2af7c213c549 100644 --- a/storage/partitioned-estimate-usage-details-caches.tentative.https.sub.html +++ b/storage/partitioned-estimate-usage-details-caches.tentative.https.sub.html @@ -28,19 +28,23 @@ `/resources/partitioned-estimate-usage-details-caches-helper-frame.html` document.body.appendChild(iframe); + async_test(test => { if (location.origin === alt_origin) return; + let cache, cache_url; - test.step(async () => { - details.init = await usageDetails(); - [cache, cache_url] = await createSomeUsage(test); - details.after = await usageDetails(); - assert_greater_than(details.after, details.init); + window.addEventListener("message", test.step_func(async event => { + if (event.data === "iframe-is-ready") { + details.init = await usageDetails(); + [cache, cache_url] = await createSomeUsage(test); + details.after = await usageDetails(); + assert_greater_than(details.after, details.init); - iframe.contentWindow.postMessage("get-details", iframe.origin); - }); + iframe.contentWindow.postMessage("get-details", iframe.origin); + } + })); window.addEventListener("message", test.step_func(event => { if (event.data.source === "same-site") { @@ -48,6 +52,7 @@ const cross_site_window = window .open(`${alt_origin}${location.pathname}`, "", "noopener=false"); + test.add_cleanup(() => cross_site_window.close()); } if (event.data.source === "cross-site") { diff --git a/storage/resources/partitioned-estimate-usage-details-caches-helper-frame.html b/storage/resources/partitioned-estimate-usage-details-caches-helper-frame.html index 13786d7ceafca7..0679c1decf5583 100644 --- a/storage/resources/partitioned-estimate-usage-details-caches-helper-frame.html +++ b/storage/resources/partitioned-estimate-usage-details-caches-helper-frame.html @@ -25,4 +25,6 @@ parent.opener.postMessage(details, parent.opener.origin); } }); + + window.parent.postMessage("iframe-is-ready", window.parent.origin);