Bug 1522989 - Only compare URI specs against parsed URI specs; r=mossop
authorEhsan Akhgari <ehsan@mozilla.com>
Sat, 26 Jan 2019 17:40:27 +0000
changeset 515560 29da27d7e834f0fbf2c30bf8de986c1a90f8cb90
parent 515559 4fb9d276e06322d4782507200c9536e23d7f8d37
child 515571 4a038a119dd39fcac171de346ffde7014771f8ec
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmossop
bugs1522989
milestone66.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 1522989 - Only compare URI specs against parsed URI specs; r=mossop Differential Revision: https://phabricator.services.mozilla.com/D17710
browser/components/shell/HeadlessShell.jsm
--- a/browser/components/shell/HeadlessShell.jsm
+++ b/browser/components/shell/HeadlessShell.jsm
@@ -8,38 +8,46 @@ var EXPORTED_SYMBOLS = ["HeadlessShell"]
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/osfile.jsm");
 
 // Refrences to the progress listeners to keep them from being gc'ed
 // before they are called.
 const progressListeners = new Map();
 
-function loadContentWindow(webNavigation, uri, principal) {
+function loadContentWindow(webNavigation, url, principal) {
+  let uri;
+  try {
+    uri = Services.io.newURI(url);
+  } catch (e) {
+    let msg = `Invalid URL passed to loadContentWindow(): ${url}`;
+    Cu.reportError(msg);
+    return Promise.reject(new Error(msg));
+  }
   return new Promise((resolve, reject) => {
     let loadURIOptions = {
       triggeringPrincipal: principal,
     };
-    webNavigation.loadURI(uri, loadURIOptions);
+    webNavigation.loadURI(uri.spec, loadURIOptions);
     let docShell = webNavigation.QueryInterface(Ci.nsIInterfaceRequestor)
                                 .getInterface(Ci.nsIDocShell);
     let webProgress = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
                               .getInterface(Ci.nsIWebProgress);
     let progressListener = {
       onLocationChange(progress, request, location, flags) {
         // Ignore inner-frame events
         if (progress != webProgress) {
           return;
         }
         // Ignore events that don't change the document
         if (flags & Ci.nsIWebProgressListener.LOCATION_CHANGE_SAME_DOCUMENT) {
           return;
         }
         // Ignore the initial about:blank
-        if (uri != location.spec) {
+        if (uri.spec != location.spec) {
           return;
         }
         let contentWindow = docShell.domWindow;
         progressListeners.delete(progressListener);
         webProgress.removeProgressListener(progressListener);
         contentWindow.addEventListener("load", (event) => {
           resolve(contentWindow);
         }, { once: true });