Bug 1367621 - Regression test to ensure that the URL bar is focused when new tabs are opened in fullscreen mode. r?felipe
MozReview-Commit-ID: 66Rl2U2Kdbl
--- a/browser/base/content/test/newtab/browser.ini
+++ b/browser/base/content/test/newtab/browser.ini
@@ -23,16 +23,17 @@ skip-if = (os == "mac" && debug) # tempo
[browser_newtab_bug1271075.js]
[browser_newtab_disable.js]
[browser_newtab_drag_drop.js]
[browser_newtab_drag_drop_ext.js]
# temporary until determine why more intermittent on VM
subsuite = clipboard
[browser_newtab_drop_preview.js]
[browser_newtab_focus.js]
+[browser_newtab_fullscreen_focus.js]
[browser_newtab_perwindow_private_browsing.js]
[browser_newtab_reflow_load.js]
support-files =
content-reflows.js
[browser_newtab_search.js]
support-files =
searchEngineNoLogo.xml
searchEngineFavicon.xml
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/newtab/browser_newtab_fullscreen_focus.js
@@ -0,0 +1,35 @@
+"use strict";
+
+function isFullscreenSizeMode() {
+ let sizemode = document.documentElement.getAttribute("sizemode");
+ return sizemode == "fullscreen";
+}
+
+/**
+ * Checks that the URL bar is correctly focused
+ * when a new tab is opened while in fullscreen
+ * mode.
+ */
+add_task(async function() {
+ gURLBar.blur();
+
+ Assert.ok(!window.fullScreen, "Should not start in fullscreen mode.");
+ BrowserFullScreen();
+ await BrowserTestUtils.waitForCondition(() => isFullscreenSizeMode());
+
+ registerCleanupFunction(async function() {
+ // Exit fullscreen if we're still in it.
+ if (window.fullScreen) {
+ BrowserFullScreen();
+ await BrowserTestUtils.waitForCondition(() => !isFullscreenSizeMode());
+ }
+ });
+
+ Assert.ok(window.fullScreen, "Should be in fullscreen mode now.");
+
+ let newTabOpened = BrowserTestUtils.waitForEvent(gBrowser, "TabSwitchDone");
+ BrowserOpenTab();
+ await newTabOpened;
+
+ Assert.ok(gURLBar.focused, "URL bar should be focused.");
+});