diff options
Diffstat (limited to 'browser/base/content/test/about/browser_aboutNewTab_bookmarksToolbarNewWindow.js')
-rw-r--r-- | browser/base/content/test/about/browser_aboutNewTab_bookmarksToolbarNewWindow.js | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/browser/base/content/test/about/browser_aboutNewTab_bookmarksToolbarNewWindow.js b/browser/base/content/test/about/browser_aboutNewTab_bookmarksToolbarNewWindow.js new file mode 100644 index 0000000000..db75376aac --- /dev/null +++ b/browser/base/content/test/about/browser_aboutNewTab_bookmarksToolbarNewWindow.js @@ -0,0 +1,57 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +add_task(async function bookmarks_toolbar_shown_on_newtab() { + let url = + getRootDirectory(gTestPath).replace( + "chrome://mochitests/content", + "https://example.com" + ) + "slow_loading_page.sjs"; + for (let featureEnabled of [true, false]) { + for (let newTabEnabled of [true, false]) { + info( + `Testing with the feature ${ + featureEnabled ? "enabled" : "disabled" + } and newtab ${newTabEnabled ? "enabled" : "disabled"}` + ); + await SpecialPowers.pushPrefEnv({ + set: [ + ["browser.toolbars.bookmarks.2h2020", featureEnabled], + ["browser.newtabpage.enabled", newTabEnabled], + ], + }); + + let newWindowOpened = BrowserTestUtils.domWindowOpened(); + let triggeringPrincipal = Services.scriptSecurityManager.getSystemPrincipal(); + openUILinkIn(url, "window", { triggeringPrincipal }); + + let newWin = await newWindowOpened; + + let exitConditions = { + visible: true, + }; + let slowSiteLoaded = BrowserTestUtils.firstBrowserLoaded(newWin, false); + slowSiteLoaded.then(result => { + exitConditions.earlyExit = result; + }); + + let result = await waitForBookmarksToolbarVisibilityWithExitConditions({ + win: newWin, + exitConditions, + message: "Toolbar should not become visible when loading slow site", + }); + + // The visibility promise will resolve to a Boolean whereas the browser + // load promise will resolve to an Event object. + ok( + typeof result != "boolean", + "The bookmarks toolbar should not become visible before the site is loaded" + ); + ok(!isBookmarksToolbarVisible(newWin), "Toolbar hidden on slow site"); + + await BrowserTestUtils.closeWindow(newWin); + } + } +}); |