Bug 1367621 - Regression test to ensure that the URL bar is focused when new tabs are opened in fullscreen mode. r?felipe draft
authorMike Conley <mconley@mozilla.com>
Fri, 26 May 2017 12:21:25 -0400
changeset 585660 4c61f2aa4a94471bc6d3f2bd1e71ec291f5a8381
parent 585659 c47a13ef3898e3f3653601ba9042499a7dd540ff
child 630771 b3fe7c20fdbb58a29fc8a905ed2d8e84d0f88113
push id61164
push usermconley@mozilla.com
push dateSat, 27 May 2017 18:28:26 +0000
reviewersfelipe
bugs1367621
milestone55.0a1
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
browser/base/content/test/newtab/browser.ini
browser/base/content/test/newtab/browser_newtab_fullscreen_focus.js
--- 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.");
+});