commit ffbd20a25b8459060bf3a1e8a76532e7732f169f
parent 14fb585c62e74b861d9241cbb3986fa56f002520
Author: Vincent Hilla <vhilla@mozilla.com>
Date: Thu, 20 Nov 2025 13:42:19 +0000
Bug 1775609 - Fix load race in browser_sessionStorage.js. r=sessionstore-reviewers,farre
Differential Revision: https://phabricator.services.mozilla.com/D273405
Diffstat:
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/browser/components/sessionstore/test/browser_sessionStorage.html b/browser/components/sessionstore/test/browser_sessionStorage.html
@@ -16,6 +16,8 @@
let iframe = document.getElementById("iframe");
let isSecure = args.indexOf("secure") > -1;
let scheme = isSecure ? "https" : "http";
+ // WARNING This iframe might not finish loading before the top level document does
+ // See intermittent bug 1775609, bug 2001322
iframe.setAttribute("src", scheme + "://example.com" + location.pathname + "?" + rand);
}
@@ -23,6 +25,11 @@
sessionStorage.test = (isOuter ? "outer" : "inner") + "-value-" + rand;
document.title = sessionStorage.test;
}
+
+ // Log the load so that it becomes more obvious if intermittent failures reoccur
+ onload = () => {
+ dump(`browser_sessionStorage.html ${isOuter ? 'TOP LEVEL' : 'IFRAME'} loaded\n`);
+ }
</script>
</body>
</html>
diff --git a/browser/components/sessionstore/test/browser_sessionStorage.js b/browser/components/sessionstore/test/browser_sessionStorage.js
@@ -85,7 +85,12 @@ add_task(async function session_storage() {
// Test that duplicating a tab works.
let tab2 = gBrowser.duplicateTab(tab);
let browser2 = tab2.linkedBrowser;
- await promiseTabRestored(tab2);
+ // See bug 2001322, need to wait for iframe of tab2 to finish loading
+ const subframeLoaded = BrowserTestUtils.browserLoaded(tab2.linkedBrowser, {
+ includeSubFrames: true,
+ wantLoad: url => url.startsWith("http://example.com"),
+ });
+ await Promise.all([promiseTabRestored(tab2), subframeLoaded]);
// Flush to make sure chrome received all data.
await TabStateFlusher.flush(browser2);
@@ -248,7 +253,12 @@ add_task(async function respect_privacy_level() {
tab = BrowserTestUtils.addTab(gBrowser, URL + "&secure");
await promiseBrowserLoaded(tab.linkedBrowser);
let tab2 = gBrowser.duplicateTab(tab);
- await promiseTabRestored(tab2);
+ // See bug 2001322, need to wait for iframe of tab2 to finish loading
+ const subframeLoaded = BrowserTestUtils.browserLoaded(tab2.linkedBrowser, {
+ includeSubFrames: true,
+ wantLoad: url => url.startsWith("https://example.com"),
+ });
+ await Promise.all([promiseTabRestored(tab2), subframeLoaded]);
await promiseRemoveTabAndSessionState(tab);
// With privacy_level=2 the |tab| shouldn't have any sessionStorage data.