From 24657932a754579e946b7af6bdf0314c7aab1c70 Mon Sep 17 00:00:00 2001 From: Bill McCloskey Date: Thu, 24 Sep 2015 13:00:53 -0700 Subject: [PATCH] Bug 967873 - Start TabView when starting tests that might lazily load it (r=Gijs) --- browser/base/content/test/general/browser_bug585558.js | 7 +++++++ browser/base/content/test/general/browser_bug597218.js | 6 ++++++ .../base/content/test/general/browser_hide_removing.js | 6 ++++++ browser/base/content/test/general/browser_visibleTabs.js | 9 +++++++-- .../test/general/browser_visibleTabs_bookmarkAllPages.js | 6 ++++++ .../test/general/browser_visibleTabs_bookmarkAllTabs.js | 6 ++++++ .../test/general/browser_visibleTabs_contextMenu.js | 9 +++++++-- .../test/general/browser_visibleTabs_tabPreview.js | 8 ++++++-- browser/components/sessionstore/test/browser_607016.js | 4 ++++ browser/components/sessionstore/test/browser_635418.js | 6 ++++++ 10 files changed, 61 insertions(+), 6 deletions(-) diff --git a/browser/base/content/test/general/browser_bug585558.js b/browser/base/content/test/general/browser_bug585558.js index 772ec98bd849..0f8d5a30cdcd 100644 --- a/browser/base/content/test/general/browser_bug585558.js +++ b/browser/base/content/test/general/browser_bug585558.js @@ -14,6 +14,13 @@ function testAttrib(elem, attrib, attribValue, msg) { function test() { waitForExplicitFinish(); + + // Ensure TabView has been initialized already. Otherwise it could + // activate at an unexpected time and show/hide tabs. + TabView._initFrame(runTest); +} + +function runTest() { is(gBrowser.tabs.length, 1, "one tab is open initially"); // Add several new tabs in sequence, hiding some, to ensure that the diff --git a/browser/base/content/test/general/browser_bug597218.js b/browser/base/content/test/general/browser_bug597218.js index f00e99f72944..a0de75bedefa 100644 --- a/browser/base/content/test/general/browser_bug597218.js +++ b/browser/base/content/test/general/browser_bug597218.js @@ -5,6 +5,12 @@ function test() { waitForExplicitFinish(); + // Ensure TabView has been initialized already. Otherwise it could + // activate at an unexpected time and show/hide tabs. + TabView._initFrame(runTest); +} + +function runTest() { // establish initial state is(gBrowser.tabs.length, 1, "we start with one tab"); diff --git a/browser/base/content/test/general/browser_hide_removing.js b/browser/base/content/test/general/browser_hide_removing.js index be62e2d89e00..77bd5d6df5fc 100644 --- a/browser/base/content/test/general/browser_hide_removing.js +++ b/browser/base/content/test/general/browser_hide_removing.js @@ -7,6 +7,12 @@ function test() { waitForExplicitFinish(); + // Ensure TabView has been initialized already. Otherwise it could + // activate at an unexpected time and show/hide tabs. + TabView._initFrame(runTest); +} + +function runTest() { // Add a tab that will get removed and hidden let testTab = gBrowser.addTab("about:blank", {skipAnimation: true}); is(gBrowser.visibleTabs.length, 2, "just added a tab, so 2 tabs"); diff --git a/browser/base/content/test/general/browser_visibleTabs.js b/browser/base/content/test/general/browser_visibleTabs.js index 4e7410dcdce8..d2f1395cf67d 100644 --- a/browser/base/content/test/general/browser_visibleTabs.js +++ b/browser/base/content/test/general/browser_visibleTabs.js @@ -2,7 +2,11 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -function test() { +add_task(function* () { + // Ensure TabView has been initialized already. Otherwise it could + // activate at an unexpected time and show/hide tabs. + yield new Promise(resolve => TabView._initFrame(resolve)); + // There should be one tab when we start the test let [origTab] = gBrowser.visibleTabs; @@ -100,4 +104,5 @@ function test() { if (tabViewWindow) tabViewWindow.GroupItems.groupItems[0].close(); -} +}); + diff --git a/browser/base/content/test/general/browser_visibleTabs_bookmarkAllPages.js b/browser/base/content/test/general/browser_visibleTabs_bookmarkAllPages.js index 0d9a12067992..67a2c5b70e4c 100644 --- a/browser/base/content/test/general/browser_visibleTabs_bookmarkAllPages.js +++ b/browser/base/content/test/general/browser_visibleTabs_bookmarkAllPages.js @@ -5,6 +5,12 @@ function test() { waitForExplicitFinish(); + // Ensure TabView has been initialized already. Otherwise it could + // activate at an unexpected time and show/hide tabs. + TabView._initFrame(runTest); +} + +function runTest() { let tabOne = gBrowser.addTab("about:blank"); let tabTwo = gBrowser.addTab("http://mochi.test:8888/"); gBrowser.selectedTab = tabTwo; diff --git a/browser/base/content/test/general/browser_visibleTabs_bookmarkAllTabs.js b/browser/base/content/test/general/browser_visibleTabs_bookmarkAllTabs.js index 09d790b94fd6..5e2619c60b0e 100644 --- a/browser/base/content/test/general/browser_visibleTabs_bookmarkAllTabs.js +++ b/browser/base/content/test/general/browser_visibleTabs_bookmarkAllTabs.js @@ -5,6 +5,12 @@ function test() { waitForExplicitFinish(); + // Ensure TabView has been initialized already. Otherwise it could + // activate at an unexpected time and show/hide tabs. + TabView._initFrame(runTest); +} + +function runTest() { // There should be one tab when we start the test let [origTab] = gBrowser.visibleTabs; is(gBrowser.visibleTabs.length, 1, "1 tab should be open"); diff --git a/browser/base/content/test/general/browser_visibleTabs_contextMenu.js b/browser/base/content/test/general/browser_visibleTabs_contextMenu.js index 0539c8106564..50985b66c8e4 100644 --- a/browser/base/content/test/general/browser_visibleTabs_contextMenu.js +++ b/browser/base/content/test/general/browser_visibleTabs_contextMenu.js @@ -2,7 +2,11 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -function test() { +add_task(function* test() { + // Ensure TabView has been initialized already. Otherwise it could + // activate at an unexpected time and show/hide tabs. + yield new Promise(resolve => TabView._initFrame(resolve)); + // There should be one tab when we start the test let [origTab] = gBrowser.visibleTabs; is(gBrowser.visibleTabs.length, 1, "there is one visible tab"); @@ -51,4 +55,5 @@ function test() { gBrowser.removeTab(testTab); gBrowser.removeTab(pinned); -} +}); + diff --git a/browser/base/content/test/general/browser_visibleTabs_tabPreview.js b/browser/base/content/test/general/browser_visibleTabs_tabPreview.js index 9491690cb1ff..ec54520264ed 100644 --- a/browser/base/content/test/general/browser_visibleTabs_tabPreview.js +++ b/browser/base/content/test/general/browser_visibleTabs_tabPreview.js @@ -2,7 +2,11 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -function test() { +add_task(function* test() { + // Ensure TabView has been initialized already. Otherwise it could + // activate at an unexpected time and show/hide tabs. + yield new Promise(resolve => TabView._initFrame(resolve)); + gPrefService.setBoolPref("browser.ctrlTab.previews", true); let [origTab] = gBrowser.visibleTabs; @@ -30,7 +34,7 @@ function test() { if (gPrefService.prefHasUserValue("browser.ctrlTab.previews")) gPrefService.clearUserPref("browser.ctrlTab.previews"); -} +}); function pressCtrlTab(aShiftKey) { EventUtils.synthesizeKey("VK_TAB", { ctrlKey: true, shiftKey: !!aShiftKey }); diff --git a/browser/components/sessionstore/test/browser_607016.js b/browser/components/sessionstore/test/browser_607016.js index ed4b03b9c8ae..3574cc06bedc 100644 --- a/browser/components/sessionstore/test/browser_607016.js +++ b/browser/components/sessionstore/test/browser_607016.js @@ -6,6 +6,10 @@ add_task(function* () { /** Bug 607016 - If a tab is never restored, attributes (eg. hidden) aren't updated correctly **/ ignoreAllUncaughtExceptions(); + // Ensure TabView has been initialized already. Otherwise it could + // activate at an unexpected time and show/hide tabs. + yield new Promise(resolve => TabView._initFrame(resolve)); + // Set the pref to true so we know exactly how many tabs should be restoring at // any given time. This guarantees that a finishing load won't start another. Services.prefs.setBoolPref("browser.sessionstore.restore_on_demand", true); diff --git a/browser/components/sessionstore/test/browser_635418.js b/browser/components/sessionstore/test/browser_635418.js index 461ad1ee84f0..ab0a0bea743b 100644 --- a/browser/components/sessionstore/test/browser_635418.js +++ b/browser/components/sessionstore/test/browser_635418.js @@ -7,6 +7,12 @@ function test() { waitForExplicitFinish(); + // Ensure TabView has been initialized already. Otherwise it could + // activate at an unexpected time and show/hide tabs. + TabView._initFrame(runTest); +} + +function runTest() { // We speed up the interval between session saves to ensure that the test // runs quickly. Services.prefs.setIntPref("browser.sessionstore.interval", 2000);