Bug 1384068 - Clicking search settings should redirect to about:preferences#search in old and new org since new org move search section into an independent pane. draft
authorEvan Tseng <evan@tseng.io>
Wed, 26 Jul 2017 07:54:09 +0800
changeset 617324 49cccd5d56573af34e8ec2d7f16a57a552d01a65
parent 614015 5928d905c0bc0b28f5488b236444c7d7991cf8d4
child 639798 7abaf74cf3060cb29b3e1e4922766b326cf6333d
push id71033
push userbmo:evan@tseng.io
push dateFri, 28 Jul 2017 10:30:10 +0000
bugs1384068
milestone56.0a1
Bug 1384068 - Clicking search settings should redirect to about:preferences#search in old and new org since new org move search section into an independent pane. MozReview-Commit-ID: 7I90HUkZqMq
browser/base/content/test/about/browser.ini
browser/base/content/test/about/browser_aboutHome_change_search_settings.js
browser/modules/ContentSearch.jsm
--- a/browser/base/content/test/about/browser.ini
+++ b/browser/base/content/test/about/browser.ini
@@ -15,8 +15,9 @@ support-files =
 run-if = nightly_build # Photon only
 [browser_aboutNetError.js]
 [browser_aboutSupport.js]
 [browser_aboutSupport_newtab_security_state.js]
 [browser_aboutHealthReport.js]
 skip-if = os == "linux" # Bug 924307
 [browser_aboutHome.js]
 [browser_aboutHome_wrapsCorrectly.js]
+[browser_aboutHome_change_search_settings.js]
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/about/browser_aboutHome_change_search_settings.js
@@ -0,0 +1,53 @@
+add_task(async function() {
+  await BrowserTestUtils.withNewTab({ gBrowser, url: "about:home" }, async function(browser) {
+    // Ensure about:home page is loaded to start test.
+    await new Promise(resolve => {
+      browser.addEventListener("AboutHomeLoadSnippetsCompleted", function listener(event) {
+        browser.removeEventListener("AboutHomeLoadSnippetsCompleted", listener, true);
+        resolve();
+      }, true, true);
+    });
+
+    await ContentTask.spawn(browser, null, async function() {
+      let input = content.document.getElementById("searchText");
+      input.focus();
+    });
+    await BrowserTestUtils.synthesizeKey("VK_DOWN", {}, browser);
+
+    await ContentTask.spawn(browser, null, async function() {
+      // Wait for the search suggestions to become visible.
+      let table = content.document.getElementById("searchSuggestionTable");
+      let input = content.document.getElementById("searchText");
+
+      await new Promise(resolve => {
+        let observer = new content.MutationObserver(() => {
+          if (input.getAttribute("aria-expanded") == "true") {
+            observer.disconnect();
+            ok(!table.hidden, "Search suggestion table unhidden");
+            resolve();
+          }
+        });
+        observer.observe(input, {
+          attributes: true,
+          attributeFilter: ["aria-expanded"],
+        });
+      });
+    });
+
+    await ContentTask.spawn(browser, null, async function() {
+      let searchController = content.wrappedJSObject.gContentSearchController;
+      let index = searchController._indexOfTableItem(content.document.getElementById("contentSearchSettingsButton"));
+      // ContentSearchUIController looks at the current selectedIndex when
+      // performing a search. Synthesizing the mouse event on the suggestion
+      // doesn't actually mouseover the suggestion and trigger it to be flagged
+      // as selected, so we manually select it first.
+      searchController.selectedIndex = index;
+    });
+
+    let prefsPromise = BrowserTestUtils.waitForLocationChange(gBrowser, "about:preferences#search");
+    await BrowserTestUtils.synthesizeMouseAtCenter("#contentSearchSettingsButton", {}, browser);
+    await prefsPromise;
+    ok(true, "Redirect to about:preferences#search after clicking the change search settings button.");
+    await BrowserTestUtils.removeTab(gBrowser.selectedTab);
+  });
+});
--- a/browser/modules/ContentSearch.jsm
+++ b/browser/modules/ContentSearch.jsm
@@ -410,22 +410,17 @@ this.ContentSearch = {
   },
 
   _onMessageSetCurrentEngine(msg, data) {
     Services.search.currentEngine = Services.search.getEngineByName(data);
   },
 
   _onMessageManageEngines(msg, data) {
     let browserWin = msg.target.ownerGlobal;
-    let pref = Services.prefs.getBoolPref("browser.preferences.useOldOrganization");
-    if (pref) {
-      browserWin.openPreferences("paneSearch", {origin: "contentSearch"});
-    } else {
-      browserWin.openPreferences("general-search", {origin: "contentSearch"});
-    }
+    browserWin.openPreferences("paneSearch", {origin: "contentSearch"});
   },
 
   async _onMessageGetSuggestions(msg, data) {
     this._ensureDataHasProperties(data, [
       "engineName",
       "searchString",
     ]);
     let {engineName, searchString} = data;