Bug 1531347 - Port autoFill tests to QuantumBar. r=mak
☠☠ backed out by 9ee8480e23e7 ☠ ☠
authorMark Banner <standard8@mozilla.com>
Sat, 02 Mar 2019 08:40:02 +0000
changeset 520020 f6c1385bf921c607a4db0ba1877448c131e7c80b
parent 520019 4c03b8915c8eb90367be19212650901f24395bc7
child 520021 9a7e65e00bc0bfe9b539eb5f5e4467a5a13e3f5e
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)
reviewersmak
bugs1531347
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 1531347 - Port autoFill tests to QuantumBar. r=mak Differential Revision: https://phabricator.services.mozilla.com/D21710
browser/components/urlbar/tests/browser/browser.ini
browser/components/urlbar/tests/browser/browser_autoFill_backspaced.js
browser/components/urlbar/tests/browser/browser_autoFill_canonize.js
browser/components/urlbar/tests/browser/browser_autoFill_preserveCase.js
browser/components/urlbar/tests/browser/browser_autoFill_trimURLs.js
browser/components/urlbar/tests/legacy/browser.ini
browser/components/urlbar/tests/legacy/browser_urlbarAutoFillTrimURLs.js
browser/components/urlbar/tests/legacy/browser_urlbarAutofillPreserveCase.js
browser/components/urlbar/tests/legacy/browser_urlbar_autoFill_backspaced.js
browser/components/urlbar/tests/legacy/browser_urlbar_canonize_on_autofill.js
--- a/browser/components/urlbar/tests/browser/browser.ini
+++ b/browser/components/urlbar/tests/browser/browser.ini
@@ -18,16 +18,24 @@ skip-if = true # Bug 1524539 - need to f
 [browser_autocomplete_autoselect.js]
 [browser_autocomplete_cursor.js]
 [browser_autocomplete_edit_completed.js]
 [browser_autocomplete_enter_race.js]
 [browser_autocomplete_no_title.js]
 [browser_autocomplete_readline_navigation.js]
 skip-if = os != "mac" # Mac only feature
 [browser_autocomplete_tag_star_visibility.js]
+[browser_autoFill_backspaced.js]
+skip-if = true # Bug 1531348 - Failing with QuantumBar.
+[browser_autoFill_canonize.js]
+skip-if = true # Bug 1531348 - Failing with QuantumBar.
+[browser_autoFill_preserveCase.js]
+skip-if = true # Bug 1531348 - Failing with QuantumBar.
+[browser_autoFill_trimURLs.js]
+skip-if = true # Bug 1531348 - Failing with QuantumBar.
 [browser_canonizeURL.js]
 [browser_dragdropURL.js]
 [browser_keyword_override.js]
 [browser_keyword_select_and_type.js]
 [browser_keyword.js]
 support-files =
   print_postdata.sjs
 [browser_locationBarCommand.js]
rename from browser/components/urlbar/tests/legacy/browser_urlbar_autoFill_backspaced.js
rename to browser/components/urlbar/tests/browser/browser_autoFill_backspaced.js
--- a/browser/components/urlbar/tests/legacy/browser_urlbar_autoFill_backspaced.js
+++ b/browser/components/urlbar/tests/browser/browser_autoFill_backspaced.js
@@ -1,35 +1,41 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
 /* This test ensures that backspacing autoFilled values still allows to
  * confirm the remaining value.
  */
 
+"use strict";
+
 async function test_autocomplete(data) {
-  let {desc, typed, autofilled, modified, keys, action, onAutoFill} = data;
+  let {desc, typed, autofilled, modified, keys, type, onAutoFill} = data;
   info(desc);
 
   await promiseAutocompleteResultPopup(typed);
-  is(gURLBar.textValue, autofilled, "autofilled value is as expected");
+  Assert.equal(gURLBar.textValue, autofilled, "autofilled value is as expected");
   if (onAutoFill)
     onAutoFill();
 
   keys.forEach(key => EventUtils.synthesizeKey(key));
 
-  is(gURLBar.textValue, modified, "backspaced value is as expected");
+  Assert.equal(gURLBar.textValue, modified, "backspaced value is as expected");
 
   await promiseSearchComplete();
 
-  ok(gURLBar.popup.richlistbox.itemChildren.length > 0, "Should get at least 1 result");
-  let result = gURLBar.popup.richlistbox.itemChildren[0];
-  let type = result.getAttribute("type");
-  let types = type.split(/\s+/);
-  ok(types.includes(action), `The type attribute "${type}" includes the expected action "${action}"`);
+  Assert.greater(UrlbarTestUtils.getResultCount(window), 0,
+    "Should get at least 1 result");
+
+  let result = await UrlbarTestUtils.getDetailsOfResultAt(window, 0);
 
-  gURLBar.popup.hidePopup();
-  await promisePopupHidden(gURLBar.popup);
+  Assert.equal(result.type, type,
+    "Should have the correct result type");
+
+  await UrlbarTestUtils.promisePopupClose(window);
   gURLBar.blur();
 }
 
 add_task(async function() {
   registerCleanupFunction(async function() {
     Services.prefs.clearUserPref("browser.urlbar.autoFill");
     gURLBar.handleRevert();
     await PlacesUtils.history.clear();
@@ -42,103 +48,103 @@ add_task(async function() {
     transition: Ci.nsINavHistoryService.TRANSITION_TYPED,
   });
 
   await test_autocomplete({ desc: "DELETE the autofilled part should search",
                             typed: "exam",
                             autofilled: "example.com/",
                             modified: "exam",
                             keys: ["KEY_Delete"],
-                            action: "searchengine",
+                            type: UrlbarUtils.RESULT_TYPE.SEARCH,
                           });
   await test_autocomplete({ desc: "DELETE the final slash should visit",
                             typed: "example.com",
                             autofilled: "example.com/",
                             modified: "example.com",
                             keys: ["KEY_Delete"],
-                            action: "visiturl",
+                            type: UrlbarUtils.RESULT_TYPE.URL,
                           });
 
   await test_autocomplete({ desc: "BACK_SPACE the autofilled part should search",
                             typed: "exam",
                             autofilled: "example.com/",
                             modified: "exam",
                             keys: ["KEY_Backspace"],
-                            action: "searchengine",
+                            type: UrlbarUtils.RESULT_TYPE.SEARCH,
                           });
   await test_autocomplete({ desc: "BACK_SPACE the final slash should visit",
                             typed: "example.com",
                             autofilled: "example.com/",
                             modified: "example.com",
                             keys: ["KEY_Backspace"],
-                            action: "visiturl",
+                            type: UrlbarUtils.RESULT_TYPE.URL,
                           });
 
   await test_autocomplete({ desc: "DELETE the autofilled part, then BACK_SPACE, should search",
                             typed: "exam",
                             autofilled: "example.com/",
                             modified: "exa",
                             keys: ["KEY_Delete", "KEY_Backspace"],
-                            action: "searchengine",
+                            type: UrlbarUtils.RESULT_TYPE.SEARCH,
                           });
   await test_autocomplete({ desc: "DELETE the final slash, then BACK_SPACE, should search",
                             typed: "example.com",
                             autofilled: "example.com/",
                             modified: "example.co",
                             keys: ["KEY_Delete", "KEY_Backspace"],
-                            action: "visiturl",
+                            type: UrlbarUtils.RESULT_TYPE.URL,
                           });
 
   await test_autocomplete({ desc: "BACK_SPACE the autofilled part, then BACK_SPACE, should search",
                             typed: "exam",
                             autofilled: "example.com/",
                             modified: "exa",
                             keys: ["KEY_Backspace", "KEY_Backspace"],
-                            action: "searchengine",
+                            type: UrlbarUtils.RESULT_TYPE.SEARCH,
                           });
   await test_autocomplete({ desc: "BACK_SPACE the final slash, then BACK_SPACE, should search",
                             typed: "example.com",
                             autofilled: "example.com/",
                             modified: "example.co",
                             keys: ["KEY_Backspace", "KEY_Backspace"],
-                            action: "visiturl",
+                            type: UrlbarUtils.RESULT_TYPE.URL,
                           });
 
   await test_autocomplete({ desc: "BACK_SPACE after blur should search",
                             typed: "ex",
                             autofilled: "example.com/",
                             modified: "e",
                             keys: ["KEY_Backspace"],
-                            action: "searchengine",
+                            type: UrlbarUtils.RESULT_TYPE.SEARCH,
                             onAutoFill: () => {
                               gURLBar.blur();
                               gURLBar.focus();
                               gURLBar.selectionStart = 1;
                               gURLBar.selectionEnd = 12;
                             },
                          });
   await test_autocomplete({ desc: "DELETE after blur should search",
                             typed: "ex",
                             autofilled: "example.com/",
                             modified: "e",
                             keys: ["KEY_Delete"],
-                            action: "searchengine",
+                            type: UrlbarUtils.RESULT_TYPE.SEARCH,
                             onAutoFill: () => {
                               gURLBar.blur();
                               gURLBar.focus();
                               gURLBar.selectionStart = 1;
                               gURLBar.selectionEnd = 12;
                             },
                           });
   await test_autocomplete({ desc: "double BACK_SPACE after blur should search",
                             typed: "ex",
                             autofilled: "example.com/",
                             modified: "e",
                             keys: ["KEY_Backspace", "KEY_Backspace"],
-                            action: "searchengine",
+                            type: UrlbarUtils.RESULT_TYPE.SEARCH,
                             onAutoFill: () => {
                               gURLBar.blur();
                               gURLBar.focus();
                               gURLBar.selectionStart = 2;
                               gURLBar.selectionEnd = 12;
                             },
                          });
 
rename from browser/components/urlbar/tests/legacy/browser_urlbar_canonize_on_autofill.js
rename to browser/components/urlbar/tests/browser/browser_autoFill_canonize.js
--- a/browser/components/urlbar/tests/legacy/browser_urlbar_canonize_on_autofill.js
+++ b/browser/components/urlbar/tests/browser/browser_autoFill_canonize.js
@@ -5,24 +5,24 @@
  * value, and only considers what the user typed (but not just enter).
  */
 
 async function test_autocomplete(data) {
   let {desc, typed, autofilled, modified, waitForUrl, keys} = data;
   info(desc);
 
   await promiseAutocompleteResultPopup(typed);
-  is(gURLBar.textValue, autofilled, "autofilled value is as expected");
+  Assert.equal(gURLBar.textValue, autofilled, "autofilled value is as expected");
 
   let promiseLoad =
     BrowserTestUtils.waitForDocLoadAndStopIt(waitForUrl, gBrowser.selectedBrowser);
 
   keys.forEach(([key, mods]) => EventUtils.synthesizeKey(key, mods));
 
-  is(gURLBar.textValue, modified, "value is as expected");
+  Assert.equal(gURLBar.textValue, modified, "value is as expected");
 
   await promiseLoad;
   gURLBar.blur();
 }
 
 add_task(async function() {
   registerCleanupFunction(async function() {
     Services.prefs.clearUserPref("browser.urlbar.autoFill");
rename from browser/components/urlbar/tests/legacy/browser_urlbarAutofillPreserveCase.js
rename to browser/components/urlbar/tests/browser/browser_autoFill_preserveCase.js
--- a/browser/components/urlbar/tests/legacy/browser_urlbarAutofillPreserveCase.js
+++ b/browser/components/urlbar/tests/browser/browser_autoFill_preserveCase.js
@@ -1,8 +1,11 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
 // This test makes sure that when the user starts typing origins and URLs, the
 // case of the user's search string is preserved inside the origin part of the
 // autofilled string.
 
 "use strict";
 
 add_task(async function init() {
   await cleanUp();
@@ -63,12 +66,12 @@ add_task(async function urlPort() {
   }]);
   await promiseAutocompleteResultPopup("ExAmple.com:8888/f");
   Assert.equal(gURLBar.value, "ExAmple.com:8888/foo");
   await cleanUp();
 });
 
 async function cleanUp() {
   EventUtils.synthesizeKey("KEY_Escape");
-  await promisePopupHidden(gURLBar.popup);
+  await UrlbarTestUtils.promisePopupClose(window);
   await PlacesUtils.bookmarks.eraseEverything();
   await PlacesUtils.history.clear();
 }
rename from browser/components/urlbar/tests/legacy/browser_urlbarAutoFillTrimURLs.js
rename to browser/components/urlbar/tests/browser/browser_autoFill_trimURLs.js
--- a/browser/components/urlbar/tests/legacy/browser_urlbarAutoFillTrimURLs.js
+++ b/browser/components/urlbar/tests/browser/browser_autoFill_trimURLs.js
@@ -1,11 +1,16 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
 // This test ensures that autoFilled values are not trimmed, unless the user
 // selects from the autocomplete popup.
 
+"use strict";
+
 add_task(async function setup() {
   const PREF_TRIMURL = "browser.urlbar.trimURLs";
   const PREF_AUTOFILL = "browser.urlbar.autoFill";
 
   registerCleanupFunction(async function() {
     Services.prefs.clearUserPref(PREF_TRIMURL);
     Services.prefs.clearUserPref(PREF_AUTOFILL);
     await PlacesUtils.history.clear();
@@ -32,98 +37,113 @@ async function promiseSearch(searchtext)
   await promiseSearchComplete();
 }
 
 async function promiseTestResult(test) {
   info("Searching for '${test.search}'");
 
   await promiseSearch(test.search);
 
-  is(gURLBar.inputField.value, test.autofilledValue,
-     `Autofilled value is as expected for search '${test.search}'`);
+  Assert.equal(gURLBar.inputField.value, test.autofilledValue,
+    `Autofilled value is as expected for search '${test.search}'`);
 
-  let result = gURLBar.popup.richlistbox.getItemAtIndex(0);
+  let result = await UrlbarTestUtils.getDetailsOfResultAt(window, 0);
+
+  Assert.equal(result.displayed.title, test.resultListDisplayTitle,
+    `Autocomplete result should have displayed title as expected for search '${test.search}'`);
 
-  is(result._titleText.textContent, test.resultListDisplayTitle,
-     `Autocomplete result should have displayed title as expected for search '${test.search}'`);
-
-  is(result._actionText.textContent, test.resultListActionText,
-     `Autocomplete action text should be as expected for search '${test.search}'`);
+  if (!UrlbarPrefs.get("quantumbar") && test.resultListActionText == "Visit") {
+    Assert.equal(result.displayed.action, "",
+      `Autocomplete action text should be empty for search '${test.search}'`);
+  } else {
+    Assert.equal(result.displayed.action, test.resultListActionText,
+      `Autocomplete action text should be as expected for search '${test.search}'`);
+  }
 
-  is(result.getAttribute("type"), test.resultListType,
-     `Autocomplete result should have searchengine for the type for search '${test.search}'`);
+  Assert.equal(result.type, test.resultListType,
+    `Autocomplete result should have searchengine for the type for search '${test.search}'`);
 
-  let actualValue = gURLBar.mController.getFinalCompleteValueAt(0);
-  let actualAction = PlacesUtils.parseActionUrl(actualValue);
-  let expectedAction = PlacesUtils.parseActionUrl(test.finalCompleteValue);
-  Assert.equal(!!actualAction, !!expectedAction);
-  if (actualAction) {
-    Assert.deepEqual(actualAction, expectedAction);
+  if (UrlbarPrefs.get("quantumbar")) {
+    Assert.equal(result.url, test.expectedUrl, "Should have the correct URL");
   } else {
-    Assert.equal(actualValue, test.finalCompleteValue);
+    let actualValue = gURLBar.mController.getFinalCompleteValueAt(0);
+    let actualAction = PlacesUtils.parseActionUrl(actualValue);
+    let expectedAction = PlacesUtils.parseActionUrl(test.finalCompleteValue);
+    Assert.equal(!!actualAction, !!expectedAction,
+      "Should have an action if expected");
+    if (actualAction) {
+      Assert.deepEqual(actualAction, expectedAction,
+        "Should have the correct action details");
+    } else {
+      Assert.equal(actualValue, test.finalCompleteValue,
+        "Should have the correct action details");
+    }
   }
 }
 
 const tests = [{
     search: "http://",
     autofilledValue: "http://",
     resultListDisplayTitle: "http://",
     resultListActionText: "Search with Google",
-    resultListType: "searchengine",
+    resultListType: UrlbarUtils.RESULT_TYPE.SEARCH,
     finalCompleteValue: 'moz-action:searchengine,{"engineName":"Google","input":"http%3A%2F%2F","searchQuery":"http%3A%2F%2F"}',
   },
   {
     search: "https://",
     autofilledValue: "https://",
     resultListDisplayTitle: "https://",
     resultListActionText: "Search with Google",
-    resultListType: "searchengine",
+    resultListType: UrlbarUtils.RESULT_TYPE.SEARCH,
     finalCompleteValue: 'moz-action:searchengine,{"engineName":"Google","input":"https%3A%2F%2F","searchQuery":"https%3A%2F%2F"}',
   },
   {
     search: "au",
     autofilledValue: "autofilltrimurl.com/",
     resultListDisplayTitle: "www.autofilltrimurl.com",
     resultListActionText: "Visit",
-    resultListType: "",
+    resultListType: UrlbarUtils.RESULT_TYPE.URL,
     finalCompleteValue: "http://www.autofilltrimurl.com/",
   },
   {
     search: "http://au",
     autofilledValue: "http://autofilltrimurl.com/",
     resultListDisplayTitle: "www.autofilltrimurl.com",
     resultListActionText: "Visit",
-    resultListType: "",
+    resultListType: UrlbarUtils.RESULT_TYPE.URL,
     finalCompleteValue: "http://www.autofilltrimurl.com/",
   },
   {
     search: "sec",
     autofilledValue: "secureautofillurl.com/",
     resultListDisplayTitle: "https://www.secureautofillurl.com",
     resultListActionText: "Visit",
-    resultListType: "",
+    resultListType: UrlbarUtils.RESULT_TYPE.URL,
     finalCompleteValue: "https://www.secureautofillurl.com/",
   },
   {
     search: "https://sec",
     autofilledValue: "https://secureautofillurl.com/",
     resultListDisplayTitle: "https://www.secureautofillurl.com",
     resultListActionText: "Visit",
-    resultListType: "",
+    resultListType: UrlbarUtils.RESULT_TYPE.URL,
     finalCompleteValue: "https://www.secureautofillurl.com/",
   },
 ];
 
 add_task(async function autofill_tests() {
   for (let test of tests) {
     await promiseTestResult(test);
   }
 });
 
 add_task(async function autofill_complete_domain() {
   await promiseSearch("http://www.autofilltrimurl.com");
-  is(gURLBar.inputField.value, "http://www.autofilltrimurl.com/", "Autofilled value is as expected");
+  Assert.equal(gURLBar.inputField.value, "http://www.autofilltrimurl.com/",
+    "Should have the correct autofill value");
 
   // Now ensure selecting from the popup correctly trims.
-  is(gURLBar.controller.matchCount, 2, "Found the expected number of matches");
+  Assert.equal(UrlbarTestUtils.getResultCount(window), 2,
+    "Should have the correct matches");
   EventUtils.synthesizeKey("KEY_ArrowDown");
-  is(gURLBar.inputField.value, "www.autofilltrimurl.com/whatever", "trim was applied correctly");
+  Assert.equal(gURLBar.inputField.value, "www.autofilltrimurl.com/whatever",
+    "Should have applied trim correctly");
 });
--- a/browser/components/urlbar/tests/legacy/browser.ini
+++ b/browser/components/urlbar/tests/legacy/browser.ini
@@ -20,32 +20,28 @@ subsuite = clipboard
 [browser_switchtab_override_keynav.js]
 
 [browser_urlbarAddonIframe.js]
 support-files =
   ../browser/Panel.jsm
   ../browser/urlbarAddonIframe.html
   ../browser/urlbarAddonIframe.js
   ../browser/urlbarAddonIframeContentScript.js
-[browser_urlbarAutofillPreserveCase.js]
-[browser_urlbarAutoFillTrimURLs.js]
 [browser_urlbarKeepStateAcrossTabSwitches.js]
 [browser_urlbarPrivateBrowsingWindowChange.js]
 [browser_urlbarRaceWithTabs.js]
 skip-if = os == "linux" # Bug 1382456
 [browser_urlbarSearchSuggestions_opt-out.js]
 support-files =
   ../browser/searchSuggestionEngine.xml
   ../browser/searchSuggestionEngine.sjs
 [browser_urlbarSearchTelemetry.js]
 support-files =
   ../browser/searchSuggestionEngine.xml
   ../browser/searchSuggestionEngine.sjs
-[browser_urlbar_autoFill_backspaced.js]
-[browser_urlbar_canonize_on_autofill.js]
 [browser_urlbar_stop_pending.js]
 support-files =
   ../browser/slow-page.sjs
 
 
 # These are tests that are already running with QuantumBar, but we want to run them
 # against both the legacy urlbar and the new QuantumBar. The references in this
 # directory will run them against the old urlbar as per the pref above.
@@ -56,16 +52,20 @@ support-files =
 skip-if = (verify && !debug && (os == 'win'))
 [../browser/browser_autocomplete_autoselect.js]
 [../browser/browser_autocomplete_cursor.js]
 [../browser/browser_autocomplete_edit_completed.js]
 [../browser/browser_autocomplete_enter_race.js]
 [../browser/browser_autocomplete_no_title.js]
 [../browser/browser_autocomplete_readline_navigation.js]
 skip-if = os != "mac" # Mac only feature
+[../browser/browser_autoFill_backspaced.js]
+[../browser/browser_autoFill_canonize.js]
+[../browser/browser_autoFill_preserveCase.js]
+[../browser/browser_autoFill_trimURLs.js]
 [../browser/browser_autocomplete_tag_star_visibility.js]
 [../browser/browser_canonizeURL.js]
 [../browser/browser_dragdropURL.js]
 [../browser/browser_keyword_override.js]
 [../browser/browser_keyword_select_and_type.js]
 [../browser/browser_keyword.js]
 support-files =
   ../browser/print_postdata.sjs