diff --git a/browser/metro/base/tests/mochitest/browser_bookmarks.js b/browser/metro/base/tests/mochitest/browser_bookmarks.js index af8772016ce..761b525af57 100644 --- a/browser/metro/base/tests/mochitest/browser_bookmarks.js +++ b/browser/metro/base/tests/mochitest/browser_bookmarks.js @@ -5,7 +5,7 @@ "use strict"; -let gStartView = BookmarksStartView._view; +let gStartView = null; function test() { runTests(); @@ -13,16 +13,17 @@ function test() { function setup() { PanelUI.hide(); + + if (!BrowserUI.isStartTabVisible) { + let tab = yield addTab("about:start"); + gStartView = tab.browser.contentWindow.BookmarksStartView._view; + + yield waitForCondition(() => BrowserUI.isStartTabVisible); + + yield hideContextUI(); + } + BookmarksTestHelper.setup(); - - yield hideContextUI(); - - if (StartUI.isStartPageVisible) - return; - - yield addTab("about:start"); - - yield waitForCondition(() => StartUI.isStartPageVisible); } function tearDown() { diff --git a/browser/metro/base/tests/mochitest/browser_context_ui.js b/browser/metro/base/tests/mochitest/browser_context_ui.js index 917896eea5a..a3c9ae817b0 100644 --- a/browser/metro/base/tests/mochitest/browser_context_ui.js +++ b/browser/metro/base/tests/mochitest/browser_context_ui.js @@ -15,10 +15,10 @@ gTests.push({ yield addTab("about:start"); yield waitForCondition(function () { - return StartUI.isStartPageVisible; + return BrowserUI.isStartTabVisible; }); - is(StartUI.isVisible, true, "Start UI is displayed on about:start"); + is(BrowserUI.isStartTabVisible, true, "Start UI is displayed on about:start"); is(ContextUI.navbarVisible, true, "Navbar is displayed on about:start"); is(ContextUI.tabbarVisible, false, "Tabbar is not displayed initially"); is(ContextUI.contextAppbarVisible, false, "Appbar is not displayed initially"); @@ -41,7 +41,7 @@ gTests.push({ is(ContextUI.tabbarVisible, true, "Tabbar is visible after third swipe"); is(ContextUI.contextAppbarVisible, false, "Appbar is hidden after third swipe"); - is(StartUI.isVisible, true, "Start UI is still visible"); + is(BrowserUI.isStartTabVisible, true, "Start UI is still visible"); } }); @@ -50,7 +50,7 @@ gTests.push({ run: function testAbout() { yield addTab("about:"); ContextUI.dismiss(); - is(StartUI.isVisible, false, "Start UI is not visible on about:"); + is(BrowserUI.isStartTabVisible, false, "Start UI is not visible on about:"); is(ContextUI.navbarVisible, false, "Navbar is not initially visible on about:"); is(ContextUI.tabbarVisible, false, "Tabbar is not initially visible on about:"); @@ -62,7 +62,7 @@ gTests.push({ is(ContextUI.navbarVisible, false, "Navbar is not visible after second swipe"); is(ContextUI.tabbarVisible, false, "Tabbar is not visible after second swipe"); - is(StartUI.isVisible, false, "Start UI is still not visible"); + is(BrowserUI.isStartTabVisible, false, "Start UI is still not visible"); } }); diff --git a/browser/metro/base/tests/mochitest/browser_history.js b/browser/metro/base/tests/mochitest/browser_history.js index 39b10bd71d3..e7c4a7439ac 100644 --- a/browser/metro/base/tests/mochitest/browser_history.js +++ b/browser/metro/base/tests/mochitest/browser_history.js @@ -5,31 +5,31 @@ "use strict"; -let gStartView = HistoryStartView._view; +let gStartView = null; function test() { runTests(); } function scrollToEnd() { - let startBox = document.getElementById("start-scrollbox"); - let [, scrollInterface] = ScrollUtils.getScrollboxFromElement(startBox); - - scrollInterface.scrollBy(50000, 0); + let scroller = getBrowser().contentWindow.StartUI.getScrollBoxObject(); + scroller.scrollBy(50000, 0); } function setup() { PanelUI.hide(); - HistoryTestHelper.setup(); - if (!StartUI.isStartPageVisible) { - yield addTab("about:start"); + if (!BrowserUI.isStartTabVisible) { + let tab = yield addTab("about:start"); + gStartView = tab.browser.contentWindow.HistoryStartView._view; - yield waitForCondition(() => StartUI.isStartPageVisible); + yield waitForCondition(() => BrowserUI.isStartTabVisible); yield hideContextUI(); } + HistoryTestHelper.setup(); + // Scroll to make sure all tiles are visible. scrollToEnd(); } diff --git a/browser/metro/base/tests/mochitest/browser_remotetabs.js b/browser/metro/base/tests/mochitest/browser_remotetabs.js index a807369b192..be46ee67646 100644 --- a/browser/metro/base/tests/mochitest/browser_remotetabs.js +++ b/browser/metro/base/tests/mochitest/browser_remotetabs.js @@ -18,25 +18,25 @@ function test() { gTests.push({ desc: "Test sync tabs from other devices UI", run: function run() { - if (StartUI.isStartPageVisible) + if (BrowserUI.isStartTabVisible) return; yield addTab("about:start"); - yield waitForCondition(() => StartUI.isStartPageVisible); + yield waitForCondition(() => BrowserUI.isStartTabVisible); yield hideContextUI(); is(Weave.Status.checkSetup(), Weave.CLIENT_NOT_CONFIGURED, "Sync should be disabled on start"); - let vbox = document.getElementById("start-remotetabs"); + let vbox = Browser.selectedBrowser.contentDocument.getElementById("start-remotetabs"); ok(vbox.hidden, "remote tabs in the start page should be hidden when sync is not enabled"); - RemoteTabsStartView._view.setUIAccessVisible(true); + Browser.selectedBrowser.contentWindow.RemoteTabsStartView._view.setUIAccessVisible(true); // start page grid should be visible ok(vbox, "remote tabs grid is present on start page"); is(vbox.hidden, false, "remote tabs should be visible in start page when sync is enabled"); - RemoteTabsStartView._view.setUIAccessVisible(false); + Browser.selectedBrowser.contentWindow.RemoteTabsStartView._view.setUIAccessVisible(false); ok(vbox.hidden, "remote tabs in the start page should be hidden when sync is not enabled"); } diff --git a/browser/metro/base/tests/mochitest/browser_selection_basic.js b/browser/metro/base/tests/mochitest/browser_selection_basic.js index cd8b1a95986..9434fcf45f6 100644 --- a/browser/metro/base/tests/mochitest/browser_selection_basic.js +++ b/browser/metro/base/tests/mochitest/browser_selection_basic.js @@ -38,7 +38,7 @@ gTests.push({ yield addTab(chromeRoot + "browser_selection_basic.html"); yield waitForCondition(function () { - return !StartUI.isStartPageVisible; + return !BrowserUI.isStartTabVisible; }, 10000, 100); yield hideContextUI(); diff --git a/browser/metro/base/tests/mochitest/browser_selection_caretfocus.js b/browser/metro/base/tests/mochitest/browser_selection_caretfocus.js index e12290647e2..f6074420a90 100644 --- a/browser/metro/base/tests/mochitest/browser_selection_caretfocus.js +++ b/browser/metro/base/tests/mochitest/browser_selection_caretfocus.js @@ -31,7 +31,7 @@ gTests.push({ yield addTab(chromeRoot + "browser_selection_caretfocus.html"); yield waitForCondition(function () { - return !StartUI.isStartPageVisible; + return !BrowserUI.isStartTabVisible; }); yield hideContextUI(); diff --git a/browser/metro/base/tests/mochitest/browser_selection_contenteditable.js b/browser/metro/base/tests/mochitest/browser_selection_contenteditable.js index 8fd00719ca8..d5d836201de 100644 --- a/browser/metro/base/tests/mochitest/browser_selection_contenteditable.js +++ b/browser/metro/base/tests/mochitest/browser_selection_contenteditable.js @@ -20,7 +20,7 @@ gTests.push({ info(chromeRoot + "browser_selection_contenteditable.html"); yield addTab(chromeRoot + "browser_selection_contenteditable.html"); yield waitForCondition(function () { - return !StartUI.isStartPageVisible; + return !BrowserUI.isStartTabVisible; }, kCommonWaitMs, kCommonPollMs); yield hideContextUI(); diff --git a/browser/metro/base/tests/mochitest/browser_selection_frame_content.js b/browser/metro/base/tests/mochitest/browser_selection_frame_content.js index 7d0860761fa..4914646f670 100644 --- a/browser/metro/base/tests/mochitest/browser_selection_frame_content.js +++ b/browser/metro/base/tests/mochitest/browser_selection_frame_content.js @@ -38,7 +38,7 @@ gTests.push({ yield addTab(chromeRoot + "browser_selection_frame_content.html"); yield waitForCondition(function () { - return !StartUI.isStartPageVisible; + return !BrowserUI.isStartTabVisible; }, 10000, 100); yield hideContextUI(); diff --git a/browser/metro/base/tests/mochitest/browser_selection_frame_inputs.js b/browser/metro/base/tests/mochitest/browser_selection_frame_inputs.js index 6cc74f0001f..7b8ee805cb2 100644 --- a/browser/metro/base/tests/mochitest/browser_selection_frame_inputs.js +++ b/browser/metro/base/tests/mochitest/browser_selection_frame_inputs.js @@ -41,7 +41,7 @@ gTests.push({ yield addTab(chromeRoot + "browser_selection_frame_inputs.html"); yield waitForCondition(function () { - return !StartUI.isStartPageVisible; + return !BrowserUI.isStartTabVisible; }, 10000, 100); yield hideContextUI(); diff --git a/browser/metro/base/tests/mochitest/browser_selection_frame_textarea.js b/browser/metro/base/tests/mochitest/browser_selection_frame_textarea.js index faf9d8ccebb..8423249e1f4 100644 --- a/browser/metro/base/tests/mochitest/browser_selection_frame_textarea.js +++ b/browser/metro/base/tests/mochitest/browser_selection_frame_textarea.js @@ -41,7 +41,7 @@ gTests.push({ yield addTab(chromeRoot + "browser_selection_frame_textarea.html"); yield waitForCondition(function () { - return !StartUI.isStartPageVisible; + return !BrowserUI.isStartTabVisible; }, 10000, 100); yield hideContextUI(); diff --git a/browser/metro/base/tests/mochitest/browser_selection_inputs.js b/browser/metro/base/tests/mochitest/browser_selection_inputs.js index a262e2e6098..093f41adee9 100644 --- a/browser/metro/base/tests/mochitest/browser_selection_inputs.js +++ b/browser/metro/base/tests/mochitest/browser_selection_inputs.js @@ -44,7 +44,7 @@ gTests.push({ yield addTab(chromeRoot + "browser_selection_inputs.html"); yield waitForCondition(function () { - return !StartUI.isStartPageVisible; + return !BrowserUI.isStartTabVisible; }); yield hideContextUI(); diff --git a/browser/metro/base/tests/mochitest/browser_selection_textarea.js b/browser/metro/base/tests/mochitest/browser_selection_textarea.js index 97bd563e983..40a13cc1d70 100644 --- a/browser/metro/base/tests/mochitest/browser_selection_textarea.js +++ b/browser/metro/base/tests/mochitest/browser_selection_textarea.js @@ -38,7 +38,7 @@ gTests.push({ yield addTab(chromeRoot + "browser_selection_textarea.html"); yield waitForCondition(function () { - return !StartUI.isStartPageVisible; + return !BrowserUI.isStartTabVisible; }, 10000, 100); yield hideContextUI(); diff --git a/browser/metro/base/tests/mochitest/browser_selection_urlbar.js b/browser/metro/base/tests/mochitest/browser_selection_urlbar.js index 4ce2ae3bea5..b8e1ed0a610 100644 --- a/browser/metro/base/tests/mochitest/browser_selection_urlbar.js +++ b/browser/metro/base/tests/mochitest/browser_selection_urlbar.js @@ -23,7 +23,7 @@ gTests.push({ yield addTab(chromeRoot + "res/textblock01.html"); yield waitForCondition(function () { - return !StartUI.isStartPageVisible; + return !BrowserUI.isStartTabVisible; }); yield hideContextUI(); diff --git a/browser/metro/base/tests/mochitest/browser_topsites.js b/browser/metro/base/tests/mochitest/browser_topsites.js index ef38cd8e88c..274a8c2865e 100644 --- a/browser/metro/base/tests/mochitest/browser_topsites.js +++ b/browser/metro/base/tests/mochitest/browser_topsites.js @@ -9,14 +9,20 @@ // Test helpers let TopSitesTestHelper = { + get grid() { + return Browser.selectedBrowser.contentDocument.getElementById("start-topsites-grid"); + }, + get document() { + return Browser.selectedBrowser.contentDocument; + }, setup: function() { return Task.spawn(function(){ - if (StartUI.isStartPageVisible) + if (BrowserUI.isStartTabVisible) return; yield addTab("about:start"); - yield waitForCondition(() => StartUI.isStartPageVisible); + yield waitForCondition(() => BrowserUI.isStartTabVisible); }); }, mockLinks: function th_mockLinks(aLinks) { @@ -176,18 +182,18 @@ gTests.push({ desc: "load and display top sites", setUp: function() { yield TopSitesTestHelper.setup(); - let grid = document.getElementById("start-topsites-grid"); + let grid = TopSitesTestHelper.grid; // setup - set history to known state yield TopSitesTestHelper.setLinks("brian,dougal,dylan,ermintrude,florence,moose,sgtsam,train,zebedee,zeebad"); let arrangedPromise = waitForEvent(grid, "arranged"); yield TopSitesTestHelper.updatePagesAndWait(); - yield arrangedPromise; // pause until the update has fired and the view is finishd updating + yield arrangedPromise; }, run: function() { - let grid = document.getElementById("start-topsites-grid"); + let grid = TopSitesTestHelper.grid; let items = grid.children; is(items.length, 8, "should be 8 topsites"); // i.e. not 10 if(items.length) { @@ -217,17 +223,17 @@ gTests.push({ this.pins ); // pause until the update has fired and the view is finishd updating - let arrangedPromise = waitForEvent(document.getElementById("start-topsites-grid"), "arranged"); + let arrangedPromise = waitForEvent(TopSitesTestHelper.grid, "arranged"); yield TopSitesTestHelper.updatePagesAndWait(); yield arrangedPromise; }, run: function() { // test that pinned state of each site as rendered matches our expectations let pins = this.pins.split(","); - let items = document.getElementById("start-topsites-grid").children; + let items = TopSitesTestHelper.grid.children; is(items.length, 8, "should be 8 topsites in the grid"); - is(document.querySelectorAll("#start-topsites-grid > [pinned]").length, 3, "should be 3 children with 'pinned' attribute"); + is(TopSitesTestHelper.document.querySelectorAll("#start-topsites-grid > [pinned]").length, 3, "should be 3 children with 'pinned' attribute"); try { Array.forEach(items, function(aItem, aIndex){ // pinned state should agree with the pins array @@ -258,7 +264,7 @@ gTests.push({ // setup - set history to known state yield TopSitesTestHelper.setLinks("sgtsam,train,zebedee,zeebad", []); // nothing initially pinned // pause until the update has fired and the view is finishd updating - let arrangedPromise = waitForEvent(document.getElementById("start-topsites-grid"), "arranged"); + let arrangedPromise = waitForEvent(TopSitesTestHelper.grid, "arranged"); yield TopSitesTestHelper.updatePagesAndWait(); yield arrangedPromise; }, @@ -266,7 +272,7 @@ gTests.push({ // pin a site // test that site is pinned as expected // and that sites fill positions around it - let grid = document.getElementById("start-topsites-grid"), + let grid = TopSitesTestHelper.grid, items = grid.children; is(items.length, 4, this.desc + ": should be 4 topsites"); @@ -315,14 +321,14 @@ gTests.push({ this.pins ); // pause until the update has fired and the view is finishd updating - let arrangedPromise = waitForEvent(document.getElementById("start-topsites-grid"), "arranged"); + let arrangedPromise = waitForEvent(TopSitesTestHelper.grid, "arranged"); yield TopSitesTestHelper.updatePagesAndWait(); yield arrangedPromise; }, run: function() { // unpin a pinned site // test that sites are unpinned as expected - let grid = document.getElementById("start-topsites-grid"), + let grid = TopSitesTestHelper.grid, items = grid.children; is(items.length, 8, this.desc + ": should be 8 topsites"); let site = { @@ -356,7 +362,7 @@ gTests.push({ ",dougal" ); // pause until the update has fired and the view is finishd updating - let arrangedPromise = waitForEvent(document.getElementById("start-topsites-grid"), "arranged"); + let arrangedPromise = waitForEvent(TopSitesTestHelper.grid, "arranged"); yield TopSitesTestHelper.updatePagesAndWait(); yield arrangedPromise; }, @@ -364,7 +370,7 @@ gTests.push({ try { // block a site // test that sites are removed from the grid as expected - let grid = document.getElementById("start-topsites-grid"), + let grid = TopSitesTestHelper.grid, items = grid.children; is(items.length, 8, this.desc + ": should be 8 topsites"); @@ -444,14 +450,14 @@ gTests.push({ this.pins ); // pause until the update has fired and the view is finishd updating - let arrangedPromise = waitForEvent(document.getElementById("start-topsites-grid"), "arranged"); + let arrangedPromise = waitForEvent(TopSitesTestHelper.grid, "arranged"); yield TopSitesTestHelper.updatePagesAndWait(); yield arrangedPromise; }, run: function() { // delete a both pinned and unpinned sites // test that sites are removed from the grid - let grid = document.getElementById("start-topsites-grid"), + let grid = TopSitesTestHelper.grid, items = grid.children; is(items.length, 4, this.desc + ": should be 4 topsites"); diff --git a/browser/metro/base/tests/mochitest/browser_urlbar.js b/browser/metro/base/tests/mochitest/browser_urlbar.js index a3d2e33168c..a29f2d197f0 100644 --- a/browser/metro/base/tests/mochitest/browser_urlbar.js +++ b/browser/metro/base/tests/mochitest/browser_urlbar.js @@ -91,19 +91,16 @@ function removeMockSearchDefault(aTimeoutMs) { =============================================================================*/ function test() { - runTests(); + waitForExplicitFinish(); + Task.spawn(function(){ + yield addTab("about:blank"); + }).then(runTests); } - function setUp() { if (!gEdit) gEdit = document.getElementById("urlbar-edit"); - - yield addTab("about:start"); yield showNavBar(); - yield waitForCondition(function () { - return StartUI.isStartPageVisible; - }); } function tearDown() { @@ -164,6 +161,8 @@ gTests.push({ run: function testSearchKeyboard() { yield addMockSearchDefault(); + yield waitForCondition(() => !Browser.selectedTab.isLoading()); + sendElementTap(window, gEdit); ok(gEdit.isEditing, "focus urlbar: in editing mode"); ok(!gEdit.popup.popupOpen, "focus urlbar: popup not open yet"); @@ -209,6 +208,8 @@ gTests.push({ run: function testUrlbarSearchesTouch() { yield addMockSearchDefault(); + yield waitForCondition(() => !Browser.selectedTab.isLoading()); + sendElementTap(window, gEdit); ok(gEdit.isEditing, "focus urlbar: in editing mode"); ok(!gEdit.popup.popupOpen, "focus urlbar: popup not open yet"); diff --git a/browser/metro/base/tests/mochitest/head.js b/browser/metro/base/tests/mochitest/head.js index f1ffea88469..af3f242417a 100644 --- a/browser/metro/base/tests/mochitest/head.js +++ b/browser/metro/base/tests/mochitest/head.js @@ -780,8 +780,9 @@ function runTests() { let badTabs = []; Browser.tabs.forEach(function(item, index, array) { let location = item.browser.currentURI.spec; - if (index == 0 && location == "about:blank") + if (index == 0 && location == "about:blank" || location == "about:start") { return; + } ok(false, "Left over tab after test: '" + location + "'"); badTabs.push(item); });