From ccaf13bf0a3f3c11e9120e15da2286c35a5081fb Mon Sep 17 00:00:00 2001 From: Steve Fink Date: Fri, 21 May 2021 22:08:06 +0000 Subject: [PATCH] Bug 1712006 - Speed up browser_gc_schedule.js with Promise.all and removing unnecessary waitForNewTab calls r=pbone Differential Revision: https://phabricator.services.mozilla.com/D115554 --- dom/ipc/tests/browser_gc_schedule.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/dom/ipc/tests/browser_gc_schedule.js b/dom/ipc/tests/browser_gc_schedule.js index 071b40a3601c..aff58ac53e0c 100644 --- a/dom/ipc/tests/browser_gc_schedule.js +++ b/dom/ipc/tests/browser_gc_schedule.js @@ -124,24 +124,24 @@ function checkAllCompleted(events, expectTabsCompleted) { } async function setupTabs(num_tabs) { - var tabs = []; var pids = []; const parent_pid = getProcessID(); info("Parent process PID is " + parent_pid); - for (var i = 0; i < num_tabs; i++) { - var newTabPromise = BrowserTestUtils.waitForNewTab(gBrowser, null, true); - const tab = await BrowserTestUtils.openNewForegroundTab({ - gBrowser, - opening: TEST_PAGE, - forceNewProcess: true, - }); - // Make sure the tab is ready - await newTabPromise; - - tabs[i] = tab; + const tabs = await Promise.all( + Array(num_tabs) + .fill() + .map(_ => { + return BrowserTestUtils.openNewForegroundTab({ + gBrowser, + opening: TEST_PAGE, + forceNewProcess: true, + }); + }) + ); + for (const [i, tab] of Object.entries(tabs)) { const tab_pid = await SpecialPowers.spawn( tab.linkedBrowser, [],