From 5bee6076177d0c013442b52de57c2108db5fc57f Mon Sep 17 00:00:00 2001 From: Alexandre Poirot Date: Thu, 10 Jun 2021 21:26:12 +0000 Subject: [PATCH] Bug 1713810 - [devtools] Fix openTabAndSetupStorage and clearStorage test helpers with fission. r=ladybenko Avoid running failing tests as they don't cleanup their storage on teardown. Differential Revision: https://phabricator.services.mozilla.com/D116478 --- devtools/server/tests/browser/browser.ini | 6 +- .../tests/browser/browser_storage_updates.js | 1 - .../server/tests/browser/storage-helpers.js | 77 ++++--------------- 3 files changed, 18 insertions(+), 66 deletions(-) diff --git a/devtools/server/tests/browser/browser.ini b/devtools/server/tests/browser/browser.ini index dd43adc02348..dffd9a481b64 100644 --- a/devtools/server/tests/browser/browser.ini +++ b/devtools/server/tests/browser/browser.ini @@ -157,11 +157,11 @@ skip-if = e10s # Bug 1183605 - devtools/server/tests/browser/ tests are still di [browser_spawn_actor_in_parent.js] [browser_storage_cookies-duplicate-names.js] [browser_storage_dynamic_windows.js] -fail-if = fission # cookies data is the correct length +skip-if = fission # cookies data is the correct length [browser_storage_listings.js] -fail-if = fission +skip-if = fission [browser_storage_updates.js] -fail-if = fission +skip-if = fission [browser_storage_webext_storage_local.js] [browser_style_utils_getFontPreviewData.js] [browser_styles_getRuleText.js] diff --git a/devtools/server/tests/browser/browser_storage_updates.js b/devtools/server/tests/browser/browser_storage_updates.js index 9af9f42e68cd..ef4bf980f72f 100644 --- a/devtools/server/tests/browser/browser_storage_updates.js +++ b/devtools/server/tests/browser/browser_storage_updates.js @@ -255,7 +255,6 @@ function checkStoreValue(name, value, store) { async function finishTests(target) { await target.destroy(); DevToolsServer.destroy(); - finish(); } async function addCookie(name, value) { diff --git a/devtools/server/tests/browser/storage-helpers.js b/devtools/server/tests/browser/storage-helpers.js index 1cc8e6a573a2..561aab6b495d 100644 --- a/devtools/server/tests/browser/storage-helpers.js +++ b/devtools/server/tests/browser/storage-helpers.js @@ -27,38 +27,15 @@ async function openTabAndSetupStorage(url) { const content = await addTab(url); // Setup the async storages in main window and for all its iframes - await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function() { - /** - * Get all windows including frames recursively. - * - * @param {Window} [baseWindow] - * The base window at which to start looking for child windows - * (optional). - * @return {Set} - * A set of windows. - */ - function getAllWindows(baseWindow) { - const windows = new Set(); - - const _getAllWindows = function(win) { - windows.add(win.wrappedJSObject); - - for (let i = 0; i < win.length; i++) { - _getAllWindows(win[i]); - } - }; - _getAllWindows(baseWindow); - - return windows; - } - - const windows = getAllWindows(content); - for (const win of windows) { - if (win.setup) { - await win.setup(); + const browsingContexts = gBrowser.selectedBrowser.browsingContext.getAllBrowsingContextsInSubtree(); + for (const browsingContext of browsingContexts) { + await SpecialPowers.spawn(browsingContext, [], async function() { + if (content.wrappedJSObject.setup) { + await content.wrappedJSObject.setup(); } - } - }); + }); + } + // selected tab is set in addTab const target = await createAndAttachTargetForTab(gBrowser.selectedTab); const front = await target.getFront("storage"); @@ -66,36 +43,12 @@ async function openTabAndSetupStorage(url) { } async function clearStorage() { - await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function() { - /** - * Get all windows including frames recursively. - * - * @param {Window} [baseWindow] - * The base window at which to start looking for child windows - * (optional). - * @return {Set} - * A set of windows. - */ - function getAllWindows(baseWindow) { - const windows = new Set(); - - const _getAllWindows = function(win) { - windows.add(win.wrappedJSObject); - - for (let i = 0; i < win.length; i++) { - _getAllWindows(win[i]); - } - }; - _getAllWindows(baseWindow); - - return windows; - } - - const windows = getAllWindows(content); - for (const win of windows) { - if (win.clear) { - await win.clear(); + const browsingContexts = gBrowser.selectedBrowser.browsingContext.getAllBrowsingContextsInSubtree(); + for (const browsingContext of browsingContexts) { + await SpecialPowers.spawn(browsingContext, [], async function() { + if (content.wrappedJSObject.clear) { + await content.wrappedJSObject.clear(); } - } - }); + }); + } }