Bug 1638215: Use https for canonization the URL. r=mak
authorDaisuke Akatsuka <daisuke@birchill.co.jp>
Mon, 07 Dec 2020 01:54:05 +0000
changeset 559596 a4ca06311d43bd6cec694660c4437e3951362181
parent 559595 4d8dcbd8732385e491912e929ff3c72bdf4c1efa
child 559597 bbaee6a208d8995f01e8024864804aa0aa49d70a
push id38009
push userccoroiu@mozilla.com
push dateMon, 07 Dec 2020 09:28:23 +0000
treeherdermozilla-central@e090b0e10f5d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1638215
milestone85.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 1638215: Use https for canonization the URL. r=mak Differential Revision: https://phabricator.services.mozilla.com/D97942
browser/base/content/test/general/browser_newTabDrop.js
browser/base/content/test/general/browser_newWindowDrop.js
browser/base/content/test/general/browser_tabDrop.js
browser/components/urlbar/UrlbarInput.jsm
browser/components/urlbar/tests/browser/browser_autoFill_canonize.js
browser/components/urlbar/tests/browser/browser_canonizeURL.js
browser/components/urlbar/tests/browser/browser_searchSuggestions.js
browser/components/urlbar/tests/browser/browser_updateForDomainCompletion.js
browser/components/urlbar/tests/browser/browser_urlbar_event_telemetry.js
docshell/base/URIFixup.jsm
docshell/test/unit/test_URIFixup_info.js
modules/libpref/init/all.js
--- a/browser/base/content/test/general/browser_newTabDrop.js
+++ b/browser/base/content/test/general/browser_newTabDrop.js
@@ -21,106 +21,106 @@ add_task(async function test_setup() {
   });
   let engine = Services.search.getEngineByName("MozSearch");
   originalEngine = await Services.search.getDefault();
   await Services.search.setDefault(engine);
 });
 
 // New Tab Button opens any link.
 add_task(async function single_url() {
-  await dropText("mochi.test/first", ["http://www.mochi.test/first"]);
+  await dropText("mochi.test/first", ["https://www.mochi.test/first"]);
 });
 add_task(async function single_url2() {
-  await dropText("mochi.test/second", ["http://www.mochi.test/second"]);
+  await dropText("mochi.test/second", ["https://www.mochi.test/second"]);
 });
 add_task(async function single_url3() {
-  await dropText("mochi.test/third", ["http://www.mochi.test/third"]);
+  await dropText("mochi.test/third", ["https://www.mochi.test/third"]);
 });
 
 // Single text/plain item, with multiple links.
 add_task(async function multiple_urls() {
   await dropText("mochi.test/1\nmochi.test/2", [
-    "http://www.mochi.test/1",
-    "http://www.mochi.test/2",
+    "https://www.mochi.test/1",
+    "https://www.mochi.test/2",
   ]);
 });
 
 // Multiple text/plain items, with single and multiple links.
 add_task(async function multiple_items_single_and_multiple_links() {
   await drop(
     [
       [{ type: "text/plain", data: "mochi.test/5" }],
       [{ type: "text/plain", data: "mochi.test/6\nmochi.test/7" }],
     ],
     [
-      "http://www.mochi.test/5",
-      "http://www.mochi.test/6",
-      "http://www.mochi.test/7",
+      "https://www.mochi.test/5",
+      "https://www.mochi.test/6",
+      "https://www.mochi.test/7",
     ]
   );
 });
 
 // Single text/x-moz-url item, with multiple links.
 // "text/x-moz-url" has titles in even-numbered lines.
 add_task(async function single_moz_url_multiple_links() {
   await drop(
     [
       [
         {
           type: "text/x-moz-url",
           data: "mochi.test/8\nTITLE8\nmochi.test/9\nTITLE9",
         },
       ],
     ],
-    ["http://www.mochi.test/8", "http://www.mochi.test/9"]
+    ["https://www.mochi.test/8", "https://www.mochi.test/9"]
   );
 });
 
 // Single item with multiple types.
 add_task(async function single_item_multiple_types() {
   await drop(
     [
       [
         { type: "text/plain", data: "mochi.test/10" },
         { type: "text/x-moz-url", data: "mochi.test/11\nTITLE11" },
       ],
     ],
-    ["http://www.mochi.test/11"]
+    ["https://www.mochi.test/11"]
   );
 });
 
 // Warn when too many URLs are dropped.
 add_task(async function multiple_tabs_under_max() {
   let urls = [];
   for (let i = 0; i < 5; i++) {
     urls.push("mochi.test/multi" + i);
   }
   await dropText(urls.join("\n"), [
-    "http://www.mochi.test/multi0",
-    "http://www.mochi.test/multi1",
-    "http://www.mochi.test/multi2",
-    "http://www.mochi.test/multi3",
-    "http://www.mochi.test/multi4",
+    "https://www.mochi.test/multi0",
+    "https://www.mochi.test/multi1",
+    "https://www.mochi.test/multi2",
+    "https://www.mochi.test/multi3",
+    "https://www.mochi.test/multi4",
   ]);
 });
 add_task(async function multiple_tabs_over_max_accept() {
   await pushPrefs(["browser.tabs.maxOpenBeforeWarn", 4]);
 
   let confirmPromise = BrowserTestUtils.promiseAlertDialog("accept");
 
   let urls = [];
   for (let i = 0; i < 5; i++) {
     urls.push("mochi.test/accept" + i);
   }
   await dropText(urls.join("\n"), [
-    "http://www.mochi.test/accept0",
-    "http://www.mochi.test/accept1",
-    "http://www.mochi.test/accept2",
-    "http://www.mochi.test/accept3",
-    "http://www.mochi.test/accept4",
+    "https://www.mochi.test/accept0",
+    "https://www.mochi.test/accept1",
+    "https://www.mochi.test/accept2",
+    "https://www.mochi.test/accept3",
+    "https://www.mochi.test/accept4",
   ]);
 
   await confirmPromise;
 
   await popPrefs();
 });
 add_task(async function multiple_tabs_over_max_cancel() {
   await pushPrefs(["browser.tabs.maxOpenBeforeWarn", 4]);
@@ -146,20 +146,20 @@ add_task(async function multiple_urls() 
     mochi.test/urls1
     mochi.test/urls2
     non url0
     mochi.test/urls3
     non url1
     non url2
 `,
     [
-      "http://www.mochi.test/urls0",
-      "http://www.mochi.test/urls1",
-      "http://www.mochi.test/urls2",
-      "http://www.mochi.test/urls3",
+      "https://www.mochi.test/urls0",
+      "https://www.mochi.test/urls1",
+      "https://www.mochi.test/urls2",
+      "https://www.mochi.test/urls3",
     ]
   );
 });
 
 // Open single search if there's no URL.
 add_task(async function multiple_text() {
   await dropText(
     `
--- a/browser/base/content/test/general/browser_newWindowDrop.js
+++ b/browser/base/content/test/general/browser_newWindowDrop.js
@@ -33,129 +33,129 @@ add_task(async function test_setup() {
     registerCleanupFunction(function() {
       CustomizableUI.removeWidgetFromArea("new-window-button");
     });
   }
 });
 
 // New Window Button opens any link.
 add_task(async function single_url() {
-  await dropText("mochi.test/first", ["http://www.mochi.test/first"]);
+  await dropText("mochi.test/first", ["https://www.mochi.test/first"]);
 });
 add_task(async function single_javascript() {
   await dropText("javascript:'bad'", ["about:blank"]);
 });
 add_task(async function single_javascript_capital() {
   await dropText("jAvascript:'bad'", ["about:blank"]);
 });
 add_task(async function single_url2() {
-  await dropText("mochi.test/second", ["http://www.mochi.test/second"]);
+  await dropText("mochi.test/second", ["https://www.mochi.test/second"]);
 });
 add_task(async function single_data_url() {
   await dropText("data:text/html,bad", ["data:text/html,bad"]);
 });
 add_task(async function single_url3() {
-  await dropText("mochi.test/third", ["http://www.mochi.test/third"]);
+  await dropText("mochi.test/third", ["https://www.mochi.test/third"]);
 });
 
 // Single text/plain item, with multiple links.
 add_task(async function multiple_urls() {
   await dropText("mochi.test/1\nmochi.test/2", [
-    "http://www.mochi.test/1",
-    "http://www.mochi.test/2",
+    "https://www.mochi.test/1",
+    "https://www.mochi.test/2",
   ]);
 });
 add_task(async function multiple_urls_javascript() {
   await dropText("javascript:'bad1'\nmochi.test/3", [
     "about:blank",
-    "http://www.mochi.test/3",
+    "https://www.mochi.test/3",
   ]);
 });
 add_task(async function multiple_urls_data() {
   await dropText("mochi.test/4\ndata:text/html,bad1", [
-    "http://www.mochi.test/4",
+    "https://www.mochi.test/4",
     "data:text/html,bad1",
   ]);
 });
 
 // Multiple text/plain items, with single and multiple links.
 add_task(async function multiple_items_single_and_multiple_links() {
   await drop(
     [
       [{ type: "text/plain", data: "mochi.test/5" }],
       [{ type: "text/plain", data: "mochi.test/6\nmochi.test/7" }],
     ],
     [
-      "http://www.mochi.test/5",
-      "http://www.mochi.test/6",
-      "http://www.mochi.test/7",
+      "https://www.mochi.test/5",
+      "https://www.mochi.test/6",
+      "https://www.mochi.test/7",
     ]
   );
 });
 
 // Single text/x-moz-url item, with multiple links.
 // "text/x-moz-url" has titles in even-numbered lines.
 add_task(async function single_moz_url_multiple_links() {
   await drop(
     [
       [
         {
           type: "text/x-moz-url",
           data: "mochi.test/8\nTITLE8\nmochi.test/9\nTITLE9",
         },
       ],
     ],
-    ["http://www.mochi.test/8", "http://www.mochi.test/9"]
+    ["https://www.mochi.test/8", "https://www.mochi.test/9"]
   );
 });
 
 // Single item with multiple types.
 add_task(async function single_item_multiple_types() {
   await drop(
     [
       [
         { type: "text/plain", data: "mochi.test/10" },
         { type: "text/x-moz-url", data: "mochi.test/11\nTITLE11" },
       ],
     ],
-    ["http://www.mochi.test/11"]
+    ["https://www.mochi.test/11"]
   );
 });
 
 // Warn when too many URLs are dropped.
 add_task(async function multiple_tabs_under_max() {
   let urls = [];
   for (let i = 0; i < 5; i++) {
     urls.push("mochi.test/multi" + i);
   }
   await dropText(urls.join("\n"), [
-    "http://www.mochi.test/multi0",
-    "http://www.mochi.test/multi1",
-    "http://www.mochi.test/multi2",
-    "http://www.mochi.test/multi3",
-    "http://www.mochi.test/multi4",
+    "https://www.mochi.test/multi0",
+    "https://www.mochi.test/multi1",
+    "https://www.mochi.test/multi2",
+    "https://www.mochi.test/multi3",
+    "https://www.mochi.test/multi4",
   ]);
 });
 add_task(async function multiple_tabs_over_max_accept() {
   await pushPrefs(["browser.tabs.maxOpenBeforeWarn", 4]);
 
   let confirmPromise = BrowserTestUtils.promiseAlertDialog("accept");
 
   let urls = [];
   for (let i = 0; i < 5; i++) {
     urls.push("mochi.test/accept" + i);
   }
   await dropText(
     urls.join("\n"),
     [
-      "http://www.mochi.test/accept0",
-      "http://www.mochi.test/accept1",
-      "http://www.mochi.test/accept2",
-      "http://www.mochi.test/accept3",
-      "http://www.mochi.test/accept4",
+      "https://www.mochi.test/accept0",
+      "https://www.mochi.test/accept1",
+      "https://www.mochi.test/accept2",
+      "https://www.mochi.test/accept3",
+      "https://www.mochi.test/accept4",
     ],
     true
   );
 
   await confirmPromise;
 
   await popPrefs();
 });
--- a/browser/base/content/test/general/browser_tabDrop.js
+++ b/browser/base/content/test/general/browser_tabDrop.js
@@ -1,8 +1,11 @@
+// TODO (Bug 1680996): Investigate why this test takes a long time.
+requestLongerTimeout(2);
+
 const ANY_URL = undefined;
 
 registerCleanupFunction(async function cleanup() {
   while (gBrowser.tabs.length > 1) {
     BrowserTestUtils.removeTab(gBrowser.tabs[gBrowser.tabs.length - 1]);
   }
   await Services.search.setDefault(originalEngine);
   let engine = Services.search.getEngineByName("MozSearch");
@@ -17,42 +20,42 @@ add_task(async function test_setup() {
     template: "http://example.com/?q={searchTerms}",
   });
   let engine = Services.search.getEngineByName("MozSearch");
   originalEngine = await Services.search.getDefault();
   await Services.search.setDefault(engine);
 });
 
 add_task(async function single_url() {
-  await dropText("mochi.test/first", ["http://www.mochi.test/first"]);
+  await dropText("mochi.test/first", ["https://www.mochi.test/first"]);
 });
 add_task(async function single_javascript() {
   await dropText("javascript:'bad'", []);
 });
 add_task(async function single_javascript_capital() {
   await dropText("jAvascript:'bad'", []);
 });
 add_task(async function single_search() {
   await dropText("search this", [ANY_URL]);
 });
 add_task(async function single_url2() {
-  await dropText("mochi.test/second", ["http://www.mochi.test/second"]);
+  await dropText("mochi.test/second", ["https://www.mochi.test/second"]);
 });
 add_task(async function single_data_url() {
   await dropText("data:text/html,bad", []);
 });
 add_task(async function single_url3() {
-  await dropText("mochi.test/third", ["http://www.mochi.test/third"]);
+  await dropText("mochi.test/third", ["https://www.mochi.test/third"]);
 });
 
 // Single text/plain item, with multiple links.
 add_task(async function multiple_urls() {
   await dropText("mochi.test/1\nmochi.test/2", [
-    "http://www.mochi.test/1",
-    "http://www.mochi.test/2",
+    "https://www.mochi.test/1",
+    "https://www.mochi.test/2",
   ]);
 });
 add_task(async function multiple_urls_javascript() {
   await dropText("javascript:'bad1'\nmochi.test/3", []);
 });
 add_task(async function multiple_urls_data() {
   await dropText("mochi.test/4\ndata:text/html,bad1", []);
 });
@@ -60,81 +63,81 @@ add_task(async function multiple_urls_da
 // Multiple text/plain items, with single and multiple links.
 add_task(async function multiple_items_single_and_multiple_links() {
   await drop(
     [
       [{ type: "text/plain", data: "mochi.test/5" }],
       [{ type: "text/plain", data: "mochi.test/6\nmochi.test/7" }],
     ],
     [
-      "http://www.mochi.test/5",
-      "http://www.mochi.test/6",
-      "http://www.mochi.test/7",
+      "https://www.mochi.test/5",
+      "https://www.mochi.test/6",
+      "https://www.mochi.test/7",
     ]
   );
 });
 
 // Single text/x-moz-url item, with multiple links.
 // "text/x-moz-url" has titles in even-numbered lines.
 add_task(async function single_moz_url_multiple_links() {
   await drop(
     [
       [
         {
           type: "text/x-moz-url",
           data: "mochi.test/8\nTITLE8\nmochi.test/9\nTITLE9",
         },
       ],
     ],
-    ["http://www.mochi.test/8", "http://www.mochi.test/9"]
+    ["https://www.mochi.test/8", "https://www.mochi.test/9"]
   );
 });
 
 // Single item with multiple types.
 add_task(async function single_item_multiple_types() {
   await drop(
     [
       [
         { type: "text/plain", data: "mochi.test/10" },
         { type: "text/x-moz-url", data: "mochi.test/11\nTITLE11" },
       ],
     ],
-    ["http://www.mochi.test/11"]
+    ["https://www.mochi.test/11"]
   );
 });
 
 // Warn when too many URLs are dropped.
 add_task(async function multiple_tabs_under_max() {
   let urls = [];
   for (let i = 0; i < 5; i++) {
     urls.push("mochi.test/multi" + i);
   }
   await dropText(urls.join("\n"), [
-    "http://www.mochi.test/multi0",
-    "http://www.mochi.test/multi1",
-    "http://www.mochi.test/multi2",
-    "http://www.mochi.test/multi3",
-    "http://www.mochi.test/multi4",
+    "https://www.mochi.test/multi0",
+    "https://www.mochi.test/multi1",
+    "https://www.mochi.test/multi2",
+    "https://www.mochi.test/multi3",
+    "https://www.mochi.test/multi4",
   ]);
 });
 add_task(async function multiple_tabs_over_max_accept() {
   await pushPrefs(["browser.tabs.maxOpenBeforeWarn", 4]);
 
   let confirmPromise = BrowserTestUtils.promiseAlertDialog("accept");
 
   let urls = [];
   for (let i = 0; i < 5; i++) {
     urls.push("mochi.test/accept" + i);
   }
   await dropText(urls.join("\n"), [
-    "http://www.mochi.test/accept0",
-    "http://www.mochi.test/accept1",
-    "http://www.mochi.test/accept2",
-    "http://www.mochi.test/accept3",
-    "http://www.mochi.test/accept4",
+    "https://www.mochi.test/accept0",
+    "https://www.mochi.test/accept1",
+    "https://www.mochi.test/accept2",
+    "https://www.mochi.test/accept3",
+    "https://www.mochi.test/accept4",
   ]);
 
   await confirmPromise;
 
   await popPrefs();
 });
 add_task(async function multiple_tabs_over_max_cancel() {
   await pushPrefs(["browser.tabs.maxOpenBeforeWarn", 4]);
--- a/browser/components/urlbar/UrlbarInput.jsm
+++ b/browser/components/urlbar/UrlbarInput.jsm
@@ -2260,17 +2260,28 @@ class UrlbarInput {
     if (firstSlash >= 0) {
       value =
         value.substring(0, firstSlash) +
         suffix +
         value.substring(firstSlash + 1);
     } else {
       value = value + suffix;
     }
-    value = "http://www." + value;
+
+    try {
+      const info = Services.uriFixup.getFixupURIInfo(
+        value,
+        Ci.nsIURIFixup.FIXUP_FLAGS_MAKE_ALTERNATE_URI
+      );
+      value = info.fixedURI.spec;
+    } catch (ex) {
+      Cu.reportError(
+        `An error occured while trying to fixup "${value}": ${ex}`
+      );
+    }
 
     this.value = value;
     return value;
   }
 
   /**
    * Autofills a value into the input.  The value will be autofilled regardless
    * of the input's current value.
--- a/browser/components/urlbar/tests/browser/browser_autoFill_canonize.js
+++ b/browser/components/urlbar/tests/browser/browser_autoFill_canonize.js
@@ -50,13 +50,13 @@ add_task(async function() {
     waitForUrl: "http://example.com/",
     keys: [["KEY_Enter"]],
   });
 
   await test_autocomplete({
     desc: "CTRL+ENTER on the autofilled part should bypass autofill",
     typed: "exam",
     autofilled: "example.com/",
-    modified: "www.exam.com",
-    waitForUrl: "http://www.exam.com/",
+    modified: "https://www.exam.com",
+    waitForUrl: "https://www.exam.com/",
     keys: [["KEY_Enter", { ctrlKey: true }]],
   });
 });
--- a/browser/components/urlbar/tests/browser/browser_canonizeURL.js
+++ b/browser/components/urlbar/tests/browser/browser_canonizeURL.js
@@ -10,25 +10,25 @@ const TEST_ENGINE_BASENAME = "searchSugg
 add_task(async function checkCtrlWorks() {
   registerCleanupFunction(async function() {
     await PlacesUtils.history.clear();
     await UrlbarTestUtils.formHistory.clear();
   });
 
   let defaultEngine = await Services.search.getDefault();
   let testcases = [
-    ["example", "http://www.example.com/", { ctrlKey: true }],
+    ["example", "https://www.example.com/", { ctrlKey: true }],
     // Check that a direct load is not overwritten by a previous canonization.
     ["http://example.com/test/", "http://example.com/test/", {}],
-    ["ex-ample", "http://www.ex-ample.com/", { ctrlKey: true }],
-    ["  example ", "http://www.example.com/", { ctrlKey: true }],
-    [" example/foo ", "http://www.example.com/foo", { ctrlKey: true }],
+    ["ex-ample", "https://www.ex-ample.com/", { ctrlKey: true }],
+    ["  example ", "https://www.example.com/", { ctrlKey: true }],
+    [" example/foo ", "https://www.example.com/foo", { ctrlKey: true }],
     [
       " example/foo bar ",
-      "http://www.example.com/foo%20bar",
+      "https://www.example.com/foo%20bar",
       { ctrlKey: true },
     ],
     ["example.net", "http://example.net/", { ctrlKey: true }],
     ["http://example", "http://example/", { ctrlKey: true }],
     ["example:8080", "http://example:8080/", { ctrlKey: true }],
     ["ex-ample.foo", "http://ex-ample.foo/", { ctrlKey: true }],
     ["example.foo/bar ", "http://example.foo/bar", { ctrlKey: true }],
     ["1.1.1.1", "http://1.1.1.1/", { ctrlKey: true }],
@@ -153,21 +153,21 @@ add_task(async function autofill() {
   await PlacesTestUtils.addVisits([
     {
       uri: "http://example.com/",
       transition: PlacesUtils.history.TRANSITIONS.TYPED,
     },
   ]);
 
   let testcases = [
-    ["ex", "http://www.ex.com/", { ctrlKey: true }],
+    ["ex", "https://www.ex.com/", { ctrlKey: true }],
     // Check that a direct load is not overwritten by a previous canonization.
     ["ex", "http://example.com/", {}],
     // search alias
-    ["@goo", "http://www%2E@goo.com/", { ctrlKey: true }],
+    ["@goo", "https://www.goo.com/", { ctrlKey: true }],
   ];
 
   function promiseAutofill() {
     return BrowserTestUtils.waitForEvent(gURLBar.inputField, "select");
   }
 
   for (let [inputValue, expectedURL, options] of testcases) {
     let promiseLoad = BrowserTestUtils.waitForDocLoadAndStopIt(
@@ -227,23 +227,23 @@ add_task(async function() {
   const testWord = "example";
   simulatePastingToUrlbar(testWord);
   is(gURLBar.value, testWord, "Paste the test word correctly");
 
   info("Release the ctrl key befoer typing Enter key");
   EventUtils.synthesizeKey("VK_CONTROL", { type: "keyup" });
 
   info("Send enter key with the ctrl");
+  const onLoad = BrowserTestUtils.waitForDocLoadAndStopIt(
+    `https://www.${testWord}.com/`,
+    gBrowser.selectedBrowser
+  );
   EventUtils.synthesizeKey("VK_RETURN", { type: "keydown", ctrlKey: true });
-  await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
-  is(
-    gBrowser.selectedBrowser.documentURI.spec,
-    `http://www.${testWord}.com/`,
-    "The loaded url is canonized"
-  );
+  await onLoad;
+  info("The loaded url is canonized");
 });
 
 function simulatePastingToUrlbar(text) {
   gURLBar.focus();
 
   const keyForPaste = document
     .getElementById("key_paste")
     .getAttribute("key")
--- a/browser/components/urlbar/tests/browser/browser_searchSuggestions.js
+++ b/browser/components/urlbar/tests/browser/browser_searchSuggestions.js
@@ -127,17 +127,19 @@ async function testPressEnterOnSuggestio
   await UrlbarTestUtils.formHistory.clear();
 }
 
 add_task(async function plainEnterOnSuggestion() {
   await testPressEnterOnSuggestion();
 });
 
 add_task(async function ctrlEnterOnSuggestion() {
-  await testPressEnterOnSuggestion("http://www.foofoo.com/", { ctrlKey: true });
+  await testPressEnterOnSuggestion("https://www.foofoo.com/", {
+    ctrlKey: true,
+  });
 });
 
 add_task(async function copySuggestionText() {
   gURLBar.focus();
   await UrlbarTestUtils.promiseAutocompleteResultPopup({
     window,
     value: "foo",
   });
--- a/browser/components/urlbar/tests/browser/browser_updateForDomainCompletion.js
+++ b/browser/components/urlbar/tests/browser/browser_updateForDomainCompletion.js
@@ -6,19 +6,19 @@
  */
 add_task(async function() {
   await SpecialPowers.pushPrefEnv({ set: [["keyword.enabled", false]] });
   await BrowserTestUtils.withNewTab(
     { gBrowser, url: "about:blank" },
     async function(browser) {
       gURLBar.value = "example";
       gURLBar.select();
-      let loadPromise = BrowserTestUtils.browserLoaded(
-        browser,
-        false,
-        url => url == "http://www.example.com/"
+      const loadPromise = BrowserTestUtils.waitForDocLoadAndStopIt(
+        "https://www.example.com/",
+        gBrowser.selectedBrowser
       );
+
       EventUtils.sendKey("return");
       await loadPromise;
-      is(gURLBar.value, "www.example.com");
+      ok(true, "https://www.example.com is loaded correctly");
     }
   );
 });
--- a/browser/components/urlbar/tests/browser/browser_urlbar_event_telemetry.js
+++ b/browser/components/urlbar/tests/browser/browser_urlbar_event_telemetry.js
@@ -382,17 +382,20 @@ const tests = [
         provider: tipProvider.name,
       },
     };
   },
 
   async function(win) {
     info("Type something and canonize");
     win.gURLBar.select();
-    let promise = BrowserTestUtils.browserLoaded(win.gBrowser.selectedBrowser);
+    const promise = BrowserTestUtils.waitForDocLoadAndStopIt(
+      "https://www.example.com/",
+      gBrowser.selectedBrowser
+    );
     await UrlbarTestUtils.promiseAutocompleteResultPopup({
       window: win,
       value: "example",
       fireInputEvent: true,
     });
     EventUtils.synthesizeKey("VK_RETURN", { ctrlKey: true }, win);
     await promise;
     return {
--- a/docshell/base/URIFixup.jsm
+++ b/docshell/base/URIFixup.jsm
@@ -62,16 +62,22 @@ XPCOMUtils.defineLazyPreferenceGetter(
   true
 );
 XPCOMUtils.defineLazyPreferenceGetter(
   this,
   "alternateEnabled",
   "browser.fixup.alternate.enabled",
   true
 );
+XPCOMUtils.defineLazyPreferenceGetter(
+  this,
+  "alternateProtocol",
+  "browser.fixup.alternate.protocol",
+  "https"
+);
 
 const {
   FIXUP_FLAG_NONE,
   FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP,
   FIXUP_FLAGS_MAKE_ALTERNATE_URI,
   FIXUP_FLAG_PRIVATE_CONTEXT,
   FIXUP_FLAG_FIX_SCHEME_TYPOS,
 } = Ci.nsIURIFixup;
@@ -775,16 +781,17 @@ function maybeSetAlternateFixedURI(info,
   if (!newHost) {
     return false;
   }
 
   // Assign the new host string over the old one
   try {
     info.fixedURI = uri
       .mutate()
+      .setScheme(alternateProtocol)
       .setHost(newHost)
       .finalize();
   } catch (ex) {
     if (ex.result != Cr.NS_ERROR_MALFORMED_URI) {
       throw ex;
     }
     return false;
   }
--- a/docshell/test/unit/test_URIFixup_info.js
+++ b/docshell/test/unit/test_URIFixup_info.js
@@ -54,22 +54,22 @@ var testcases = [
   {
     input: "www.mozilla.org",
     fixedURI: "http://www.mozilla.org/",
     protocolChange: true,
   },
   {
     input: "http://mozilla/",
     fixedURI: "http://mozilla/",
-    alternateURI: "http://www.mozilla.com/",
+    alternateURI: "https://www.mozilla.com/",
   },
   {
     input: "http://test./",
     fixedURI: "http://test./",
-    alternateURI: "http://www.test./",
+    alternateURI: "https://www.test./",
   },
   {
     input: "127.0.0.1",
     fixedURI: "http://127.0.0.1/",
     protocolChange: true,
   },
   {
     input: "1.2.3.4/",
@@ -229,39 +229,39 @@ var testcases = [
     fixedURI: "http://0.0.4.210/",
     keywordLookup: true,
     protocolChange: true,
     affectedByDNSForSingleWordHosts: true,
   },
   {
     input: "whitelisted/foo.txt",
     fixedURI: "http://whitelisted/foo.txt",
-    alternateURI: "http://www.whitelisted.com/foo.txt",
+    alternateURI: "https://www.whitelisted.com/foo.txt",
     protocolChange: true,
   },
   {
     input: "mozilla",
     fixedURI: "http://mozilla/",
-    alternateURI: "http://www.mozilla.com/",
+    alternateURI: "https://www.mozilla.com/",
     keywordLookup: true,
     protocolChange: true,
     affectedByDNSForSingleWordHosts: true,
   },
   {
     input: "test.",
     fixedURI: "http://test./",
-    alternateURI: "http://www.test./",
+    alternateURI: "https://www.test./",
     keywordLookup: true,
     protocolChange: true,
     affectedByDNSForSingleWordHosts: true,
   },
   {
     input: ".test",
     fixedURI: "http://.test/",
-    alternateURI: "http://www..test/",
+    alternateURI: "https://www..test/",
     keywordLookup: true,
     protocolChange: true,
     affectedByDNSForSingleWordHosts: true,
   },
   {
     input: "mozilla is amazing",
     keywordLookup: true,
   },
@@ -279,25 +279,25 @@ var testcases = [
   },
   {
     input: "london's map",
     keywordLookup: true,
   },
   {
     input: "mozilla ",
     fixedURI: "http://mozilla/",
-    alternateURI: "http://www.mozilla.com/",
+    alternateURI: "https://www.mozilla.com/",
     keywordLookup: true,
     protocolChange: true,
     affectedByDNSForSingleWordHosts: true,
   },
   {
     input: "   mozilla  ",
     fixedURI: "http://mozilla/",
-    alternateURI: "http://www.mozilla.com/",
+    alternateURI: "https://www.mozilla.com/",
     keywordLookup: true,
     protocolChange: true,
     affectedByDNSForSingleWordHosts: true,
   },
   {
     input: "mozilla \\",
     keywordLookup: true,
   },
@@ -307,33 +307,33 @@ var testcases = [
   },
   {
     input: "mozilla \\\r foo.txt",
     keywordLookup: true,
   },
   {
     input: "mozilla\n",
     fixedURI: "http://mozilla/",
-    alternateURI: "http://www.mozilla.com/",
+    alternateURI: "https://www.mozilla.com/",
     keywordLookup: true,
     protocolChange: true,
     affectedByDNSForSingleWordHosts: true,
   },
   {
     input: "mozilla \r\n",
     fixedURI: "http://mozilla/",
-    alternateURI: "http://www.mozilla.com/",
+    alternateURI: "https://www.mozilla.com/",
     keywordLookup: true,
     protocolChange: true,
     affectedByDNSForSingleWordHosts: true,
   },
   {
     input: "moz\r\nfirefox\nos\r",
     fixedURI: "http://mozfirefoxos/",
-    alternateURI: "http://www.mozfirefoxos.com/",
+    alternateURI: "https://www.mozfirefoxos.com/",
     keywordLookup: true,
     protocolChange: true,
     affectedByDNSForSingleWordHosts: true,
   },
   {
     input: "moz\r\n firefox\n",
     keywordLookup: true,
   },
@@ -343,74 +343,74 @@ var testcases = [
   },
   {
     input: "[]",
     keywordLookup: true,
   },
   {
     input: "http://whitelisted/",
     fixedURI: "http://whitelisted/",
-    alternateURI: "http://www.whitelisted.com/",
+    alternateURI: "https://www.whitelisted.com/",
     inWhitelist: true,
   },
   {
     input: "whitelisted",
     fixedURI: "http://whitelisted/",
-    alternateURI: "http://www.whitelisted.com/",
+    alternateURI: "https://www.whitelisted.com/",
     protocolChange: true,
     inWhitelist: true,
   },
   {
     input: "whitelisted.",
     fixedURI: "http://whitelisted./",
-    alternateURI: "http://www.whitelisted./",
+    alternateURI: "https://www.whitelisted./",
     protocolChange: true,
     inWhitelist: true,
   },
   {
     input: "mochi.test",
     fixedURI: "http://mochi.test/",
-    alternateURI: "http://www.mochi.test/",
+    alternateURI: "https://www.mochi.test/",
     protocolChange: true,
     inWhitelist: true,
   },
   // local.domain is a whitelisted suffix...
   {
     input: "some.local.domain",
     fixedURI: "http://some.local.domain/",
     protocolChange: true,
     inWhitelist: true,
   },
   // ...but .domain is not.
   {
     input: "some.domain",
     fixedURI: "http://some.domain/",
-    alternateURI: "http://www.some.domain/",
+    alternateURI: "https://www.some.domain/",
     keywordLookup: true,
     protocolChange: true,
     affectedByDNSForSingleWordHosts: true,
   },
   {
     input: "café.com",
     fixedURI: "http://xn--caf-dma.com/",
-    alternateURI: "http://www.xn--caf-dma.com/",
+    alternateURI: "https://www.xn--caf-dma.com/",
     protocolChange: true,
   },
   {
     input: "mozilla.nonexistent",
     fixedURI: "http://mozilla.nonexistent/",
-    alternateURI: "http://www.mozilla.nonexistent/",
+    alternateURI: "https://www.mozilla.nonexistent/",
     keywordLookup: true,
     protocolChange: true,
     affectedByDNSForSingleWordHosts: true,
   },
   {
     input: "mochi.ocm",
     fixedURI: "http://mochi.com/",
-    alternateURI: "http://www.mochi.com/",
+    alternateURI: "https://www.mochi.com/",
     protocolChange: true,
   },
   {
     input: "47.6182,-122.830",
     fixedURI: "http://47.6182,-122.830/",
     keywordLookup: true,
     protocolChange: true,
     affectedByDNSForSingleWordHosts: true,
@@ -434,17 +434,17 @@ var testcases = [
     fixedURI: "http://32.0.0.7/",
     keywordLookup: true,
     protocolChange: true,
     affectedByDNSForSingleWordHosts: true,
   },
   {
     input: "5+2",
     fixedURI: "http://5+2/",
-    alternateURI: "http://www.5+2.com/",
+    alternateURI: "https://www.5+2.com/",
     keywordLookup: true,
     protocolChange: true,
     affectedByDNSForSingleWordHosts: true,
   },
   {
     input: "5/2",
     fixedURI: "http://0.0.0.5/2",
     keywordLookup: true,
@@ -453,60 +453,60 @@ var testcases = [
   },
   {
     input: "moz ?.::%27",
     keywordLookup: true,
   },
   {
     input: "mozilla.com/?q=search",
     fixedURI: "http://mozilla.com/?q=search",
-    alternateURI: "http://www.mozilla.com/?q=search",
+    alternateURI: "https://www.mozilla.com/?q=search",
     protocolChange: true,
   },
   {
     input: "mozilla.com?q=search",
     fixedURI: "http://mozilla.com/?q=search",
-    alternateURI: "http://www.mozilla.com/?q=search",
+    alternateURI: "https://www.mozilla.com/?q=search",
     protocolChange: true,
   },
   {
     input: "mozilla.com ?q=search",
     keywordLookup: true,
   },
   {
     input: "mozilla.com.?q=search",
     fixedURI: "http://mozilla.com./?q=search",
     protocolChange: true,
   },
   {
     input: "mozilla.com'?q=search",
     fixedURI: "http://mozilla.com/?q=search",
-    alternateURI: "http://www.mozilla.com/?q=search",
+    alternateURI: "https://www.mozilla.com/?q=search",
     protocolChange: true,
   },
   {
     input: "mozilla.com':search",
     keywordLookup: true,
   },
   {
     input: "[mozilla]",
     keywordLookup: true,
   },
   {
     input: "':?",
     fixedURI: "http://'/?",
-    alternateURI: "http://www.'.com/?",
+    alternateURI: "https://www.'.com/?",
     keywordLookup: true,
     protocolChange: true,
     affectedByDNSForSingleWordHosts: true,
   },
   {
     input: "whitelisted?.com",
     fixedURI: "http://whitelisted/?.com",
-    alternateURI: "http://www.whitelisted.com/?.com",
+    alternateURI: "https://www.whitelisted.com/?.com",
     protocolChange: true,
   },
   {
     input: "?'.com",
     keywordLookup: true,
   },
   {
     input: "' ?.com",
@@ -518,47 +518,47 @@ var testcases = [
   },
   {
     input: "??mozilla",
     keywordLookup: true,
   },
   {
     input: "mozilla/",
     fixedURI: "http://mozilla/",
-    alternateURI: "http://www.mozilla.com/",
+    alternateURI: "https://www.mozilla.com/",
     protocolChange: true,
   },
   {
     input: "mozilla",
     fixedURI: "http://mozilla/",
-    alternateURI: "http://www.mozilla.com/",
+    alternateURI: "https://www.mozilla.com/",
     protocolChange: true,
     keywordLookup: true,
     affectedByDNSForSingleWordHosts: true,
   },
   {
     input: "mozilla5/2",
     fixedURI: "http://mozilla5/2",
-    alternateURI: "http://www.mozilla5.com/2",
+    alternateURI: "https://www.mozilla5.com/2",
     protocolChange: true,
     keywordLookup: true,
     affectedByDNSForSingleWordHosts: true,
   },
   {
     input: "mozilla/foo",
     fixedURI: "http://mozilla/foo",
-    alternateURI: "http://www.mozilla.com/foo",
+    alternateURI: "https://www.mozilla.com/foo",
     protocolChange: true,
     keywordLookup: true,
     affectedByDNSForSingleWordHosts: true,
   },
   {
     input: "mozilla\\",
     fixedURI: "http://mozilla/",
-    alternateURI: "http://www.mozilla.com/",
+    alternateURI: "https://www.mozilla.com/",
     keywordLookup: true,
     protocolChange: true,
     affectedByDNSForSingleWordHosts: true,
   },
   {
     input: "localhost",
     fixedURI: "http://localhost/",
     keywordLookup: true,
@@ -583,81 +583,81 @@ var testcases = [
   {
     input: "plonk:8080#test",
     fixedURI: "http://plonk:8080/#test",
     protocolChange: true,
   },
   {
     input: "plonk/ #",
     fixedURI: "http://plonk/%20#",
-    alternateURI: "http://www.plonk.com/%20#",
+    alternateURI: "https://www.plonk.com/%20#",
     protocolChange: true,
     keywordLookup: false,
   },
   {
     input: "blah.com.",
     fixedURI: "http://blah.com./",
     protocolChange: true,
   },
   {
     input:
       "\u10E0\u10D4\u10D2\u10D8\u10E1\u10E2\u10E0\u10D0\u10EA\u10D8\u10D0.\u10D2\u10D4",
     fixedURI: "http://xn--lodaehvb5cdik4g.xn--node/",
-    alternateURI: "http://www.xn--lodaehvb5cdik4g.xn--node/",
+    alternateURI: "https://www.xn--lodaehvb5cdik4g.xn--node/",
     protocolChange: true,
   },
   {
     input: " \t mozilla.org/\t \t ",
     fixedURI: "http://mozilla.org/",
-    alternateURI: "http://www.mozilla.org/",
+    alternateURI: "https://www.mozilla.org/",
     protocolChange: true,
   },
   {
     input: " moz\ti\tlla.org ",
     keywordLookup: true,
   },
   {
     input: "mozilla/",
     fixedURI: "http://mozilla/",
-    alternateURI: "http://www.mozilla.com/",
+    alternateURI: "https://www.mozilla.com/",
     protocolChange: true,
   },
   {
     input: "mozilla/ test /",
     fixedURI: "http://mozilla/%20test%20/",
-    alternateURI: "http://www.mozilla.com/%20test%20/",
+    alternateURI: "https://www.mozilla.com/%20test%20/",
     protocolChange: true,
   },
   {
     input: "mozilla /test/",
     keywordLookup: true,
   },
   {
     input: "pserver:8080",
     fixedURI: "http://pserver:8080/",
     protocolChange: true,
   },
   {
     input: "http;mozilla",
     fixedURI: "http://http;mozilla/",
-    alternateURI: "http://www.http;mozilla.com/",
+    alternateURI: "https://www.http;mozilla.com/",
     keywordLookup: true,
     protocolChange: true,
     affectedByDNSForSingleWordHosts: true,
   },
   {
     input: "http//mozilla.org",
     fixedURI: "http://mozilla.org/",
     shouldRunTest: flags =>
       flags & Services.uriFixup.FIXUP_FLAG_FIX_SCHEME_TYPOS,
   },
   {
     input: "http//mozilla.org",
     fixedURI: "http://http//mozilla.org",
-    alternateURI: "http://www.http.com//mozilla.org",
+    alternateURI: "https://www.http.com//mozilla.org",
     keywordLookup: true,
     protocolChange: true,
     affectedByDNSForSingleWordHosts: true,
     shouldRunTest: flags =>
       !(flags & Services.uriFixup.FIXUP_FLAG_FIX_SCHEME_TYPOS),
   },
   {
     input: "www.mozilla",
@@ -670,23 +670,23 @@ if (AppConstants.platform == "win") {
   testcases.push({
     input: "C:\\some\\file.txt",
     fixedURI: "file:///C:/some/file.txt",
     protocolChange: true,
   });
   testcases.push({
     input: "//mozilla",
     fixedURI: "http://mozilla/",
-    alternateURI: "http://www.mozilla.com/",
+    alternateURI: "https://www.mozilla.com/",
     protocolChange: true,
   });
   testcases.push({
     input: "/a",
     fixedURI: "http://a/",
-    alternateURI: "http://www.a.com/",
+    alternateURI: "https://www.a.com/",
     keywordLookup: true,
     protocolChange: true,
     affectedByDNSForSingleWordHosts: true,
   });
 } else {
   testcases.push({
     input: "/some/file.txt",
     fixedURI: "file:///some/file.txt",
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -906,16 +906,17 @@ pref("nglayout.enable_drag_images", true
 // enable/disable paint flashing --- useful for debugging
 // the first one applies to everything, the second one only to chrome
 pref("nglayout.debug.paint_flashing", false);
 pref("nglayout.debug.paint_flashing_chrome", false);
 
 // URI fixup prefs
 pref("browser.fixup.alternate.enabled", true);
 pref("browser.fixup.alternate.prefix", "www.");
+pref("browser.fixup.alternate.protocol", "https");
 pref("browser.fixup.alternate.suffix", ".com");
 pref("browser.fixup.fallback-to-https", true);
 
 // NOTE: On most platforms we save print settins to prefs with the name of the
 // printer in the pref name (Android being the notable exception, where prefs
 // are saved "globally" without a printer name in the pref name).  For those
 // platforms, the prefs below simply act as default values for when we
 // encounter a printer for the first time, but only a subset of prefs will be