Backed out 3 changesets (bug 1308931) for failing browser_901207_searchbar_in_panel.js, browser_urlbarFocusedCmdK.js and browser_urlbarHashChangeProxyState.js. r=backout
authorSebastian Hengst <archaeopteryx@coole-files.de>
Sat, 29 Oct 2016 17:17:54 +0200
changeset 320191 5fb5979e6bfb1e81637e0c5129e6e4f55567902c
parent 320190 93ab9dfffbbc67c10f933771535dd771da277825
child 320192 d27de07adaae222e1d1f7f2c6f70c32ef3831620
push id20751
push userphilringnalda@gmail.com
push dateSun, 30 Oct 2016 18:06:35 +0000
treeherderfx-team@e3279760cd97 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1308931
milestone52.0a1
backs outeab68afb07088c28bd8bdff5615ef1131799e28f
8109faaf35c0f8886aaabf31c61f7ece6ec33ddd
992fa87b5fbee066579a359fcecd7d4b0054ff9f
Backed out 3 changesets (bug 1308931) for failing browser_901207_searchbar_in_panel.js, browser_urlbarFocusedCmdK.js and browser_urlbarHashChangeProxyState.js. r=backout Backed out changeset eab68afb0708 (bug 1308931) Backed out changeset 8109faaf35c0 (bug 1308931) Backed out changeset 992fa87b5fbe (bug 1308931)
browser/base/content/browser.js
browser/base/content/test/general/browser_aboutHome.js
browser/base/content/test/newtab/browser_newtab_search.js
browser/base/content/test/urlbar/browser.ini
browser/base/content/test/urlbar/browser_urlbarFocusedCmdK.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -3639,28 +3639,36 @@ const BrowserSearch = {
         }
         win = window.openDialog(getBrowserURL(), "_blank",
                                 "chrome,all,dialog=no", "about:blank");
         Services.obs.addObserver(observer, "browser-delayed-startup-finished", false);
       }
       return;
     }
 
-    let focusUrlBarIfSearchFieldIsNotActive = function(aSearchBar) {
+    let openSearchPageIfFieldIsNotActive = function(aSearchBar) {
       if (!aSearchBar || document.activeElement != aSearchBar.textbox.inputField) {
-        focusAndSelectUrlBar();
+        let url = gBrowser.currentURI.spec.toLowerCase();
+        let mm = gBrowser.selectedBrowser.messageManager;
+        let newTabRemoted = Services.prefs.getBoolPref("browser.newtabpage.remote");
+        let localNewTabEnabled = url === "about:newtab" && !newTabRemoted && NewTabUtils.allPages.enabled;
+        if (url === "about:home" || localNewTabEnabled) {
+          ContentSearch.focusInput(mm);
+        } else {
+          openUILinkIn("about:home", "current");
+        }
       }
     };
 
     let searchBar = this.searchBar;
     let placement = CustomizableUI.getPlacementOfWidget("search-container");
     let focusSearchBar = () => {
       searchBar = this.searchBar;
       searchBar.select();
-      focusUrlBarIfSearchFieldIsNotActive(searchBar);
+      openSearchPageIfFieldIsNotActive(searchBar);
     };
     if (placement && placement.area == CustomizableUI.AREA_PANEL) {
       // The panel is not constructed until the first time it is shown.
       PanelUI.show().then(focusSearchBar);
       return;
     }
     if (placement && placement.area == CustomizableUI.AREA_NAVBAR && searchBar &&
         searchBar.parentNode.getAttribute("overflowedItem") == "true") {
@@ -3670,17 +3678,17 @@ const BrowserSearch = {
       });
       return;
     }
     if (searchBar) {
       if (window.fullScreen)
         FullScreen.showNavToolbox();
       searchBar.select();
     }
-    focusUrlBarIfSearchFieldIsNotActive(searchBar);
+    openSearchPageIfFieldIsNotActive(searchBar);
   },
 
   /**
    * Loads a search results page, given a set of search terms. Uses the current
    * engine if the search bar is visible, or the default engine otherwise.
    *
    * @param searchText
    *        The search terms to use for the search.
--- a/browser/base/content/test/general/browser_aboutHome.js
+++ b/browser/base/content/test/general/browser_aboutHome.js
@@ -471,16 +471,44 @@ add_task(function* () {
       yield ContentTaskUtils.waitForCondition(() => doc.activeElement === searchInput,
         "Search input should be the active element.");
       is(searchInput.value, "a", "Search input should be 'a'.");
     });
   });
 });
 
 add_task(function* () {
+  info("Cmd+k should focus the search box in the page when the search box in the toolbar is absent");
+
+  // Remove the search bar from toolbar
+  CustomizableUI.removeWidgetFromArea("search-container");
+
+  yield BrowserTestUtils.withNewTab({ gBrowser, url: "about:home" }, function* (browser) {
+    yield BrowserTestUtils.synthesizeMouseAtCenter("#brandLogo", {}, browser);
+    yield ContentTask.spawn(browser, null, function* () {
+      let doc = content.document;
+      isnot(doc.getElementById("searchText"), doc.activeElement,
+        "Search input should not be the active element.");
+    });
+
+    EventUtils.synthesizeKey("k", { accelKey: true });
+
+    yield ContentTask.spawn(browser, null, function* () {
+      let doc = content.document;
+      let searchInput = doc.getElementById("searchText");
+
+      yield ContentTaskUtils.waitForCondition(() => doc.activeElement === searchInput,
+        "Search input should be the active element.");
+    });
+  });
+
+  CustomizableUI.reset();
+});
+
+add_task(function* () {
   info("Cmd+k should focus the search box in the toolbar when it's present");
 
   yield BrowserTestUtils.withNewTab({ gBrowser, url: "about:home" }, function* (browser) {
     yield BrowserTestUtils.synthesizeMouseAtCenter("#brandLogo", {}, browser);
 
     let doc = window.document;
     let searchInput = doc.getElementById("searchbar").textbox.inputField;
     isnot(searchInput, doc.activeElement, "Search bar should not be the active element.");
--- a/browser/base/content/test/newtab/browser_newtab_search.js
+++ b/browser/base/content/test/newtab/browser_newtab_search.js
@@ -173,16 +173,39 @@ add_task(function* () {
   EventUtils.synthesizeKey("a", { accelKey: true });
   EventUtils.synthesizeKey("VK_DELETE", {});
 
   yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
     Assert.ok(content.document.getElementById("searchSuggestionTable").hidden,
       "Search suggestion table hidden");
   });
 
+  // Remove the search bar from toolbar
+  CustomizableUI.removeWidgetFromArea("search-container");
+  // Focus a different element than the search input from the page.
+  yield BrowserTestUtils.synthesizeMouseAtCenter("#newtab-customize-button", { }, gBrowser.selectedBrowser);
+
+  yield ContentTask.spawn(gBrowser.selectedBrowser, { }, function* () {
+    let input = content.document.getElementById("newtab-search-text");
+    Assert.notEqual(input, content.document.activeElement, "Search input should not be focused");
+  });
+
+  // Test that Ctrl/Cmd + K will focus the input field from the page.
+  let focusPromise = promiseSearchEvents(["FocusInput"]);
+  EventUtils.synthesizeKey("k", { accelKey: true });
+  yield focusPromise;
+
+  yield ContentTask.spawn(gBrowser.selectedBrowser, { }, function* () {
+    let input = content.document.getElementById("newtab-search-text");
+    Assert.equal(input, content.document.activeElement, "Search input should be focused");
+  });
+
+  // Reset changes made to toolbar
+  CustomizableUI.reset();
+
   // Test that Ctrl/Cmd + K will focus the search bar from toolbar.
   EventUtils.synthesizeKey("k", { accelKey: true });
   let searchBar = document.getElementById("searchbar");
   is(searchBar.textbox.inputField, document.activeElement, "Toolbar's search bar should be focused");
 
   // Test that Ctrl/Cmd + K will focus the search bar from a new about:home page if
   // the newtab is disabled from `NewTabUtils.allPages.enabled`.
   let tab = yield* addNewTabPageTab();
--- a/browser/base/content/test/urlbar/browser.ini
+++ b/browser/base/content/test/urlbar/browser.ini
@@ -50,17 +50,16 @@ skip-if = os == 'linux' # Bug 1104755
 subsuite = clipboard
 support-files =
   authenticate.sjs
 [browser_urlbarDecode.js]
 [browser_urlbarDelete.js]
 [browser_urlbarEnter.js]
 [browser_urlbarEnterAfterMouseOver.js]
 skip-if = os == "linux" # Bug 1073339 - Investigate autocomplete test unreliability on Linux/e10s
-[browser_urlbarFocusedCmdK.js]
 [browser_urlbarHashChangeProxyState.js]
 [browser_urlbarKeepStateAcrossTabSwitches.js]
 [browser_urlbarOneOffs.js]
 [browser_urlbarPrivateBrowsingWindowChange.js]
 [browser_urlbarRaceWithTabs.js]
 [browser_urlbarRevert.js]
 [browser_urlbarSearchSingleWordNotification.js]
 [browser_urlbarSearchSuggestions.js]
deleted file mode 100644
--- a/browser/base/content/test/urlbar/browser_urlbarFocusedCmdK.js
+++ /dev/null
@@ -1,17 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-add_task(function*() {
-
-  // Remove the search bar from toolbar
-  CustomizableUI.removeWidgetFromArea("search-container");
-
-  // Test that Ctrl/Cmd + K will focus the url bar
-  yield EventUtils.synthesizeKey("k", { accelKey: true });
-  yield BrowserTestUtils.waitForEvent(gURLBar, "focus");
-  Assert.equal(document.activeElement, gURLBar.inputField, "URL Bar should be focused");
-
-  // Reset changes made to toolbar
-  CustomizableUI.reset();
-});
-