Bug 1594356 - Remove browser_moz_action_link.js, that is failing with Fission. r=adw
authorMarco Bonardo <mbonardo@mozilla.com>
Wed, 06 Nov 2019 21:41:42 +0000
changeset 500960 c618a187003cdb556ff44868b5520021ca024f43
parent 500959 ffed8d3b4ac5ed66ec2632275f24234b796acdf6
child 500961 f2a5d56c886dd7f31aaebfcf6016539aa1d5d42f
push id114166
push userapavel@mozilla.com
push dateThu, 07 Nov 2019 10:04:01 +0000
treeherdermozilla-inbound@d271c572a9bc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw
bugs1594356
milestone72.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 1594356 - Remove browser_moz_action_link.js, that is failing with Fission. r=adw Differential Revision: https://phabricator.services.mozilla.com/D51997
browser/base/content/browser.js
browser/components/urlbar/tests/browser/browser.ini
browser/components/urlbar/tests/browser/browser_moz_action_link.js
browser/components/urlbar/tests/browser/browser_urlbarDecode.js
toolkit/components/places/PlacesUtils.jsm
toolkit/components/places/UnifiedComplete.jsm
toolkit/components/places/tests/unifiedcomplete/head_autocomplete.js
toolkit/components/places/tests/unifiedcomplete/test_autofill_search_engine_aliases.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -3315,20 +3315,16 @@ function URLBarSetURI(aURI, updatePopupN
     gURLBar.selectionStart = gURLBar.selectionEnd = 0;
   }
 
   SetPageProxyState(valid ? "valid" : "invalid", updatePopupNotifications);
 }
 
 function losslessDecodeURI(aURI) {
   let scheme = aURI.scheme;
-  if (scheme == "moz-action") {
-    throw new Error("losslessDecodeURI should never get a moz-action URI");
-  }
-
   var value = aURI.displaySpec;
 
   let decodeASCIIOnly = !["https", "http", "file", "ftp"].includes(scheme);
   // Try to decode as UTF-8 if there's no encoding sequence that we would break.
   if (!/%25(?:3B|2F|3F|3A|40|26|3D|2B|24|2C|23)/i.test(value)) {
     if (decodeASCIIOnly) {
       // This only decodes ascii characters (hex) 20-7e, except 25 (%).
       // This avoids both cases stipulated below (%-related issues, and \r, \n
--- a/browser/components/urlbar/tests/browser/browser.ini
+++ b/browser/components/urlbar/tests/browser/browser.ini
@@ -63,18 +63,16 @@ support-files =
 [browser_keyword.js]
 support-files =
   print_postdata.sjs
   searchSuggestionEngine.xml
   searchSuggestionEngine.sjs
 [browser_locationBarCommand.js]
 skip-if = (os == 'mac' && os_version == '10.14') # bug 1554807
 [browser_locationBarExternalLoad.js]
-[browser_moz_action_link.js]
-skip-if = fission # Timeouts
 [browser_new_tab_urlbar_reset.js]
 [browser_openViewOnFocus.js]
 [browser_pasteAndGo.js]
 tags = clipboard
 [browser_percent_encoded.js]
 [browser_populateAfterPushState.js]
 [browser_primary_selection_safe_on_new_tab.js]
 [browser_privateBrowsingWindowChange.js]
deleted file mode 100644
--- a/browser/components/urlbar/tests/browser/browser_moz_action_link.js
+++ /dev/null
@@ -1,40 +0,0 @@
-"use strict";
-
-const kURIs = ["moz-action:foo,", "moz-action:foo"];
-
-add_task(async function() {
-  for (let uri of kURIs) {
-    let dataURI = `data:text/html,<a id=a href="${uri}" target=_blank rel="opener">Link</a>`;
-    let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, dataURI);
-
-    let tabSwitchPromise = BrowserTestUtils.switchTab(gBrowser, function() {});
-    await ContentTask.spawn(tab.linkedBrowser, null, async function() {
-      content.document.getElementById("a").click();
-    });
-    await tabSwitchPromise;
-    isnot(gBrowser.selectedTab, tab, "Switched to new tab!");
-    is(
-      gURLBar.value,
-      "about:blank",
-      "URL bar should be displaying about:blank"
-    );
-    let newTab = gBrowser.selectedTab;
-    await BrowserTestUtils.switchTab(gBrowser, tab);
-    await BrowserTestUtils.switchTab(gBrowser, newTab);
-    is(gBrowser.selectedTab, newTab, "Switched to new tab again!");
-    is(
-      gURLBar.value,
-      "about:blank",
-      "URL bar should be displaying about:blank after tab switch"
-    );
-    // Finally, check that directly setting it produces the right results, too:
-    URLBarSetURI(makeURI(uri));
-    is(
-      gURLBar.value,
-      "about:blank",
-      "URL bar should still be displaying about:blank"
-    );
-    BrowserTestUtils.removeTab(newTab);
-    BrowserTestUtils.removeTab(tab);
-  }
-});
--- a/browser/components/urlbar/tests/browser/browser_urlbarDecode.js
+++ b/browser/components/urlbar/tests/browser/browser_urlbarDecode.js
@@ -49,18 +49,17 @@ add_task(function losslessDecode() {
 
 add_task(async function actionURILosslessDecode() {
   let urlNoScheme = "example.com/\u30a2\u30a4\u30a6\u30a8\u30aa";
   let url = "http://" + urlNoScheme;
   await promiseAutocompleteResultPopup(url);
 
   // At this point the heuristic result is selected but the urlbar's value is
   // simply `url`.  Key down and back around until the heuristic result is
-  // selected again, and at that point the urlbar's value should be a visiturl
-  // moz-action.
+  // selected again.
   do {
     EventUtils.synthesizeKey("KEY_ArrowDown");
   } while (UrlbarTestUtils.getSelectedRowIndex(window) != 0);
 
   let result = await UrlbarTestUtils.getDetailsOfResultAt(window, 0);
 
   Assert.equal(
     result.type,
--- a/toolkit/components/places/PlacesUtils.jsm
+++ b/toolkit/components/places/PlacesUtils.jsm
@@ -439,17 +439,16 @@ var PlacesUtils = {
   TOPIC_DATABASE_LOCKED: "places-database-locked",
   TOPIC_EXPIRATION_FINISHED: "places-expiration-finished",
   TOPIC_FAVICONS_EXPIRED: "places-favicons-expired",
   TOPIC_VACUUM_STARTING: "places-vacuum-starting",
   TOPIC_BOOKMARKS_RESTORE_BEGIN: "bookmarks-restore-begin",
   TOPIC_BOOKMARKS_RESTORE_SUCCESS: "bookmarks-restore-success",
   TOPIC_BOOKMARKS_RESTORE_FAILED: "bookmarks-restore-failed",
 
-  ACTION_SCHEME: "moz-action:",
   observers: PlacesObservers,
 
   /**
    * GUIDs associated with virtual queries that are used for displaying the
    * top-level folders in the left pane.
    */
   virtualAllBookmarksGuid: "allbms_____v",
   virtualHistoryGuid: "history____v",
@@ -571,51 +570,29 @@ var PlacesUtils = {
     return bundle.formatStringFromName(key, params);
   },
 
   getString: function PU_getString(key) {
     return bundle.GetStringFromName(key);
   },
 
   /**
-   * Makes a moz-action URI for the given action and set of parameters.
-   *
-   * @param   type
-   *          The action type.
-   * @param   params
-   *          A JS object of action params.
-   * @returns A moz-action URI as a string.
-   */
-  mozActionURI(type, params) {
-    let encodedParams = {};
-    for (let key in params) {
-      // Strip null or undefined.
-      // Regardless, don't encode them or they would be converted to a string.
-      if (params[key] === null || params[key] === undefined) {
-        continue;
-      }
-      encodedParams[key] = encodeURIComponent(params[key]);
-    }
-    return this.ACTION_SCHEME + type + "," + JSON.stringify(encodedParams);
-  },
-
-  /**
    * Parses a moz-action URL and returns its parts.
    *
    * @param url A moz-action URI.
    * @note URL is in the format moz-action:ACTION,JSON_ENCODED_PARAMS
    */
   parseActionUrl(url) {
     if (url instanceof Ci.nsIURI) {
       url = url.spec;
     } else if (url instanceof URL) {
       url = url.href;
     }
     // Faster bailout.
-    if (!url.startsWith(this.ACTION_SCHEME)) {
+    if (!url.startsWith("moz-action:")) {
       return null;
     }
 
     try {
       let [, type, params] = url.match(MOZ_ACTION_REGEX);
       let action = {
         type,
         params: JSON.parse(params),
--- a/toolkit/components/places/UnifiedComplete.jsm
+++ b/toolkit/components/places/UnifiedComplete.jsm
@@ -508,17 +508,17 @@ function stripHttpAndTrim(spec, trimSlas
  * @param   {object} match
  *          The match object.
  * @returns {value} Some opaque key object.  Use ObjectUtils.deepEqual() to
  *          compare keys.
  */
 function makeKeyForMatch(match) {
   // For autofill entries, we need to have a key based on the comment rather
   // than the value field, because the latter may have been trimmed.
-  if (match.hasOwnProperty("style") && match.style.includes("autofill")) {
+  if (match.style && match.style.includes("autofill")) {
     return [stripHttpAndTrim(match.comment), null];
   }
 
   let action = PlacesUtils.parseActionUrl(match.value);
   if (!action) {
     return [stripHttpAndTrim(match.value), null];
   }
 
@@ -586,16 +586,38 @@ function substringAt(sourceStr, targetSt
  *          empty string if targetStr does not occur in sourceStr.
  */
 function substringAfter(sourceStr, targetStr) {
   let index = sourceStr.indexOf(targetStr);
   return index < 0 ? "" : sourceStr.substr(index + targetStr.length);
 }
 
 /**
+ * Makes a moz-action url for the given action and set of parameters.
+ *
+ * @param   type
+ *          The action type.
+ * @param   params
+ *          A JS object of action params.
+ * @returns A moz-action url as a string.
+ */
+function makeActionUrl(type, params) {
+  let encodedParams = {};
+  for (let key in params) {
+    // Strip null or undefined.
+    // Regardless, don't encode them or they would be converted to a string.
+    if (params[key] === null || params[key] === undefined) {
+      continue;
+    }
+    encodedParams[key] = encodeURIComponent(params[key]);
+  }
+  return `moz-action:${type},${JSON.stringify(encodedParams)}`;
+}
+
+/**
  * Manages a single instance of an autocomplete search.
  *
  * The first three parameters all originate from the similarly named parameters
  * of nsIAutoCompleteSearch.startSearch().
  *
  * @param searchString
  *        The search string.
  * @param searchParam
@@ -1319,17 +1341,17 @@ Search.prototype = {
           // front end will style it as a search engine result.  The front end
           // uses `finalCompleteValue` as the URL for autofill results, so set
           // that to the moz-action URL.
           let aliasPreservingUserCase = token + alias.substr(token.length);
           let value = aliasPreservingUserCase + " ";
           this._result.setDefaultIndex(0);
           this._addMatch({
             value,
-            finalCompleteValue: PlacesUtils.mozActionURI("searchengine", {
+            finalCompleteValue: makeActionUrl("searchengine", {
               engineName: engine.name,
               alias: aliasPreservingUserCase,
               input: value,
               searchQuery: "",
             }),
             comment: engine.name,
             frecency: FRECENCY_DEFAULT,
             style: "autofill action searchengine",
@@ -1628,17 +1650,17 @@ Search.prototype = {
       // It's not possible to bind a param to this keyword.
       return false;
     }
 
     let style = "keyword";
     let value = url;
     if (this._enableActions) {
       style = "action " + style;
-      value = PlacesUtils.mozActionURI("keyword", {
+      value = makeActionUrl("keyword", {
         url,
         keyword,
         input: this._originalSearchString,
         postData,
       });
     }
 
     let match = {
@@ -1773,17 +1795,17 @@ Search.prototype = {
     let count =
       this._counts[UrlbarUtils.RESULT_GROUP.EXTENSION] +
       this._counts[UrlbarUtils.RESULT_GROUP.HEURISTIC];
     if (count >= UrlbarUtils.MAXIMUM_ALLOWED_EXTENSION_MATCHES) {
       return;
     }
 
     this._addMatch({
-      value: PlacesUtils.mozActionURI("extension", {
+      value: makeActionUrl("extension", {
         content,
         keyword: this._heuristicToken,
       }),
       comment,
       icon: "chrome://browser/content/extension.svg",
       style: "action extension",
       frecency: Infinity,
       type: UrlbarUtils.RESULT_GROUP.EXTENSION,
@@ -1842,17 +1864,17 @@ Search.prototype = {
       match.style += " alias";
     }
     if (suggestion) {
       actionURLParams.searchSuggestion = suggestion;
       match.style += " suggestion";
       match.type = UrlbarUtils.RESULT_GROUP.SUGGESTION;
     }
 
-    match.value = PlacesUtils.mozActionURI("searchengine", actionURLParams);
+    match.value = makeActionUrl("searchengine", actionURLParams);
     this._addMatch(match);
   },
 
   _matchExtensionSuggestions() {
     let data = {
       keyword: this._heuristicToken,
       text: this._originalSearchString,
       inPrivateWindow: this._inPrivateWindow,
@@ -1901,17 +1923,17 @@ Search.prototype = {
         icon = PlacesUtils.favicons.getFaviconLinkForIcon(
           Services.io.newURI(icon)
         ).spec;
       }
 
       let match = {
         // We include the deviceName in the action URL so we can render it in
         // the URLBar.
-        value: PlacesUtils.mozActionURI("remotetab", { url, deviceName }),
+        value: makeActionUrl("remotetab", { url, deviceName }),
         comment: title || url,
         style: "action remotetab",
         // we want frecency > FRECENCY_DEFAULT so it doesn't get pushed out
         // by "remote" matches.
         frecency: FRECENCY_DEFAULT + 1,
         icon,
       };
       if (lastUsed > Date.now() - RECENT_REMOTE_TAB_THRESHOLD_MS) {
@@ -1945,17 +1967,17 @@ Search.prototype = {
     let searchUrl = this._trimmedOriginalSearchString;
     try {
       fixupInfo = Services.uriFixup.getFixupURIInfo(searchUrl, flags);
     } catch (e) {
       if (
         e.result == Cr.NS_ERROR_MALFORMED_URI &&
         !UrlbarPrefs.get("keyword.enabled")
       ) {
-        let value = PlacesUtils.mozActionURI("visiturl", {
+        let value = makeActionUrl("visiturl", {
           url: searchUrl,
           input: searchUrl,
         });
         this._addMatch({
           value,
           comment: searchUrl,
           style: "action visiturl",
           frecency: Infinity,
@@ -1991,17 +2013,17 @@ Search.prototype = {
     // to be displayed to the user, and in any case the front-end should not
     // rely on it being canonical.
     let escapedURL = uri.displaySpec;
     let displayURL = Services.textToSubURI.unEscapeURIForUI(
       "UTF-8",
       escapedURL
     );
 
-    let value = PlacesUtils.mozActionURI("visiturl", {
+    let value = makeActionUrl("visiturl", {
       url: escapedURL,
       input: searchUrl,
     });
 
     let match = {
       value,
       comment: displayURL,
       style: "action visiturl",
@@ -2070,17 +2092,17 @@ Search.prototype = {
     if (
       this._searchTokens.length &&
       this._searchTokens.every(token => !terms.includes(token.value))
     ) {
       return;
     }
 
     // Turn the match into a searchengine action with a favicon.
-    match.value = PlacesUtils.mozActionURI("searchengine", {
+    match.value = makeActionUrl("searchengine", {
       engineName: parseResult.engineName,
       input: parseResult.terms,
       searchQuery: parseResult.terms,
     });
     match.comment = parseResult.engineName;
     match.icon = match.icon || match.iconUrl;
     match.style = "action searchengine favicon";
   },
@@ -2421,17 +2443,17 @@ Search.prototype = {
     };
 
     if (
       this._enableActions &&
       openPageCount > 0 &&
       this.hasBehavior("openpage")
     ) {
       // Actions are enabled and the page is open.  Add a switch-to-tab result.
-      match.value = PlacesUtils.mozActionURI("switchtab", { url: match.value });
+      match.value = makeActionUrl("switchtab", { url: match.value });
       match.style = "action switchtab";
     } else if (
       this.hasBehavior("history") &&
       !this.hasBehavior("bookmark") &&
       !tags
     ) {
       // The consumer wants only history and not bookmarks and there are no
       // tags.  We'll act as if the page is not bookmarked.
--- a/toolkit/components/places/tests/unifiedcomplete/head_autocomplete.js
+++ b/toolkit/components/places/tests/unifiedcomplete/head_autocomplete.js
@@ -443,17 +443,17 @@ function stripPrefix(spec) {
 }
 
 function makeActionURI(action, params) {
   let encodedParams = {};
   for (let key in params) {
     encodedParams[key] = encodeURIComponent(params[key]);
   }
   let url = "moz-action:" + action + "," + JSON.stringify(encodedParams);
-  return NetUtil.newURI(url);
+  return Services.io.newURI(url);
 }
 
 // Creates a full "match" entry for a search result, suitable for passing as
 // an entry to check_autocomplete.
 function makeSearchMatch(input, extra = {}) {
   let params = {
     engineName: extra.engineName || "MozSearch",
     input,
--- a/toolkit/components/places/tests/unifiedcomplete/test_autofill_search_engine_aliases.js
+++ b/toolkit/components/places/tests/unifiedcomplete/test_autofill_search_engine_aliases.js
@@ -28,22 +28,22 @@ add_task(async function basic() {
   // search uses an @ alias.  When an @ alias is autofilled, there should be no
   // other matches except the autofill heuristic match.
   await PlacesTestUtils.addVisits({
     uri: "http://example.com/",
     title: TEST_ENGINE_ALIAS,
   });
 
   let autofilledValue = TEST_ENGINE_ALIAS + " ";
-  let completedURL = PlacesUtils.mozActionURI("searchengine", {
+  let completedURL = makeActionURI("searchengine", {
     engineName: TEST_ENGINE_NAME,
     alias: TEST_ENGINE_ALIAS,
     input: autofilledValue,
     searchQuery: "",
-  });
+  }).spec;
   await check_autocomplete({
     search: TEST_ENGINE_ALIAS.substr(
       0,
       Math.round(TEST_ENGINE_ALIAS.length / 2)
     ),
     autofilled: autofilledValue,
     completed: completedURL,
     matches: [
@@ -70,22 +70,22 @@ add_task(async function preserveCase() {
   });
 
   let search = TEST_ENGINE_ALIAS.toUpperCase().substr(
     0,
     Math.round(TEST_ENGINE_ALIAS.length / 2)
   );
   let alias = search + TEST_ENGINE_ALIAS.substr(search.length);
   let autofilledValue = alias + " ";
-  let completedURL = PlacesUtils.mozActionURI("searchengine", {
+  let completedURL = makeActionURI("searchengine", {
     engineName: TEST_ENGINE_NAME,
     alias,
     input: autofilledValue,
     searchQuery: "",
-  });
+  }).spec;
   await check_autocomplete({
     search,
     autofilled: autofilledValue,
     completed: completedURL,
     matches: [
       {
         value: autofilledValue,
         comment: TEST_ENGINE_NAME,