Bug 1492482 - Remove CPOW usage from browser_aboutSearchReset.js. r=nhnt11
authorMike Conley <mconley@mozilla.com>
Tue, 02 Oct 2018 17:57:48 +0000
changeset 494966 8e71dda1db8298d36c7ed73cf679a532c7fbf3af
parent 494965 517aee4235da13396a5e3dfd5dda8098277981c5
child 494967 62deabc0023679f3144ba338daa253d2e4972916
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnhnt11
bugs1492482
milestone64.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 1492482 - Remove CPOW usage from browser_aboutSearchReset.js. r=nhnt11 Depends on D6955 Differential Revision: https://phabricator.services.mozilla.com/D6956
browser/components/search/test/browser_aboutSearchReset.js
--- a/browser/components/search/test/browser_aboutSearchReset.js
+++ b/browser/components/search/test/browser_aboutSearchReset.js
@@ -59,17 +59,18 @@ var gTests = [
                       uri.spec;
 
     let rawEngine = engine.wrappedJSObject;
     let initialHash = rawEngine.getAttr("loadPathHash");
     rawEngine.setAttr("loadPathHash", "broken");
     Services.prefs.setCharPref(kStatusPref, "pending");
 
     let loadPromise = promiseStoppedLoad(expectedURL);
-    gBrowser.contentDocumentAsCPOW.getElementById("searchResetKeepCurrent").click();
+    await BrowserTestUtils.synthesizeMouseAtCenter("#searchResetKeepCurrent", {},
+                                                   gBrowser.selectedBrowser);
     await loadPromise;
 
     is(engine, Services.search.currentEngine,
        "the custom engine is still default");
     is(rawEngine.getAttr("loadPathHash"), initialHash,
        "the loadPathHash has been fixed");
 
     checkTelemetryRecords(TELEMETRY_RESULT_ENUM.KEPT_CURRENT);
@@ -77,30 +78,39 @@ var gTests = [
   },
 },
 
 {
   desc: "Test the 'Restore Search Defaults' button.",
   async run() {
     let currentEngine = Services.search.currentEngine;
     let originalEngine = Services.search.originalDefaultEngine;
-    let doc = gBrowser.contentDocumentAsCPOW;
-    let defaultEngineSpan = doc.getElementById("defaultEngine");
-    is(defaultEngineSpan.textContent, originalEngine.name,
+    let browser = gBrowser.selectedBrowser;
+    let defaultEngineSpanText =
+      await ContentTask.spawn(browser, null, async () => {
+        return content.document.getElementById("defaultEngine").textContent;
+      });
+
+    is(defaultEngineSpanText, originalEngine.name,
        "the name of the original default engine is displayed");
 
     let expectedURL = originalEngine.
                       getSubmission(kSearchStr, null, kSearchPurpose).
                       uri.spec;
     let loadPromise = promiseStoppedLoad(expectedURL);
-    let button = doc.getElementById("searchResetChangeEngine");
-    is(doc.activeElement, button,
-       "the 'Change Search Engine' button is focused");
+
+    await ContentTask.spawn(browser, null, async () => {
+      let button = content.document.getElementById("searchResetChangeEngine");
+      Assert.equal(content.document.activeElement, button,
+                   "the 'Change Search Engine' button is focused");
+    });
+
     Services.prefs.setCharPref(kStatusPref, "pending");
-    button.click();
+    await BrowserTestUtils.synthesizeMouseAtCenter("#searchResetChangeEngine",
+                                                   {}, browser);
     await loadPromise;
 
     is(originalEngine, Services.search.currentEngine,
        "the default engine is back to the original one");
 
     checkTelemetryRecords(TELEMETRY_RESULT_ENUM.RESTORED_DEFAULT);
     is(Services.prefs.getCharPref(kStatusPref), "accepted");
     Services.search.currentEngine = currentEngine;
@@ -109,17 +119,19 @@ var gTests = [
 
 {
   desc: "Click the settings link.",
   async run() {
     Services.prefs.setCharPref(kStatusPref, "pending");
     let loadPromise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser,
                                                      false,
                                                      "about:preferences#search");
-    gBrowser.contentDocumentAsCPOW.getElementById("linkSettingsPage").click();
+    let browser = gBrowser.selectedBrowser;
+    await BrowserTestUtils.synthesizeMouseAtCenter("#linkSettingsPage",
+                                                   {}, browser);
     await loadPromise;
 
     checkTelemetryRecords(TELEMETRY_RESULT_ENUM.OPENED_SETTINGS);
     is(Services.prefs.getCharPref(kStatusPref), "customized");
   },
 },
 
 {