Bug 1527922: Ensure the Reload button is disabled when testing against blank tabs in the browser toolbar key nav tests. r=Gijs
authorJames Teh <jteh@mozilla.com>
Thu, 07 Mar 2019 18:10:13 +0000
changeset 520910 c26d4a8d43c4d0d6f6e13135b8f35924123fe99e
parent 520909 91fcd9232c7e64ec113afd5f9eb183939cd52110
child 520911 4a8244ddd0c470edf74c6ea0927aa154be89651d
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1527922
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1527922: Ensure the Reload button is disabled when testing against blank tabs in the browser toolbar key nav tests. r=Gijs For a blank tab, the Reload button should be disabled. These tests depend on this. This seems to be true when setting the new tab page to blank in Firefox Options. However, when we open about:blank with BrowserTestUtils.withNewTab, this is unreliable. That is, sometimes the Reload button is enabled, sometimes it isn't. I don't understand why this happens. For the purposes of these tests, just force the Reload button to be disabled for new, blank tabs so we get consistent results. Differential Revision: https://phabricator.services.mozilla.com/D22449
browser/base/content/test/keyboard/browser_toolbarKeyNav.js
--- a/browser/base/content/test/keyboard/browser_toolbarKeyNav.js
+++ b/browser/base/content/test/keyboard/browser_toolbarKeyNav.js
@@ -47,28 +47,41 @@ function startFromUrlBar() {
 
 // The Reload button is disabled for a short time even after the page finishes
 // loading. Wait for it to be enabled.
 async function waitUntilReloadEnabled() {
   let button = document.getElementById("reload-button");
   await TestUtils.waitForCondition(() => !button.disabled);
 }
 
+// Opens a new, blank tab, executes a task and closes the tab.
+function withNewBlankTab(taskFn) {
+  return BrowserTestUtils.withNewTab("about:blank", async function() {
+    // For a blank tab, the Reload button should be disabled. However, when we
+    // open about:blank with BrowserTestUtils.withNewTab, this is unreliable.
+    // Therefore, explicitly disable the reload command.
+    // We disable the command (rather than disabling the button directly) so the
+    // button will be updated correctly for future page loads.
+    document.getElementById("Browser:Reload").setAttribute("disabled", "true");
+    await taskFn();
+  });
+}
+
 add_task(async function setPref() {
   await SpecialPowers.pushPrefEnv({
     set: [
       ["browser.toolbars.keyboard_navigation", true],
       ["accessibility.tabfocus", 7],
     ],
   });
 });
 
 // Test tab stops with no page loaded.
 add_task(async function testTabStopsNoPage() {
-  await BrowserTestUtils.withNewTab("about:blank", async function() {
+  await withNewBlankTab(async function() {
     startFromUrlBar();
     await expectFocusAfterKey("Shift+Tab", "home-button");
     await expectFocusAfterKey("Shift+Tab", "tabbrowser-tabs", true);
     await expectFocusAfterKey("Tab", "home-button");
     await expectFocusAfterKey("Tab", gURLBar.inputField);
     await expectFocusAfterKey("Tab", "library-button");
     await expectFocusAfterKey("Tab", gBrowser.selectedBrowser);
   });
@@ -120,17 +133,17 @@ add_task(async function testTabStopsWith
     startFromUrlBar();
     await expectFocusAfterKey("Tab", "library-button");
     await expectFocusAfterKey("Tab", gBrowser.selectedBrowser);
   });
 });
 
 // Test a focusable toolbartabstop which has no navigable buttons.
 add_task(async function testTabStopNoButtons() {
-  await BrowserTestUtils.withNewTab("about:blank", async function() {
+  await withNewBlankTab(async function() {
     // The Back, Forward and Reload buttons are all currently disabled.
     // The Home button is the only other button at that tab stop.
     CustomizableUI.removeWidgetFromArea("home-button");
     startFromUrlBar();
     await expectFocusAfterKey("Shift+Tab", "tabbrowser-tabs", true);
     await expectFocusAfterKey("Tab", gURLBar.inputField);
     CustomizableUI.reset();
     // Make sure the button is reachable now that it has been re-added.