Bug 1268285 - E10SUtils shouldn't throw when passed invalid chrome: URIs, r=felipe, a=sylvestre
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Wed, 11 May 2016 10:42:21 +0100
changeset 333184 6f97167428c0e854c819cdac50f15191b7b44ce3
parent 333183 49da7aca28190d9e8a3b4dc7db62ebd5022edfb2
child 333185 5bc37d6d1faea0a8ddf602980aa2127c9526de1e
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfelipe, sylvestre
bugs1268285
milestone48.0a2
Bug 1268285 - E10SUtils shouldn't throw when passed invalid chrome: URIs, r=felipe, a=sylvestre MozReview-Commit-ID: CYof4pGFHIk
browser/modules/E10SUtils.jsm
--- a/browser/modules/E10SUtils.jsm
+++ b/browser/modules/E10SUtils.jsm
@@ -47,21 +47,31 @@ this.E10SUtils = {
       if (module) {
         let flags = module.getURIFlags(url);
         canLoadRemote = !!(flags & Ci.nsIAboutModule.URI_CAN_LOAD_IN_CHILD);
         mustLoadRemote = !!(flags & Ci.nsIAboutModule.URI_MUST_LOAD_IN_CHILD);
       }
     }
 
     if (aURL.startsWith("chrome:")) {
-      let url = Services.io.newURI(aURL, null, null);
-      let chromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"].
-                      getService(Ci.nsIXULChromeRegistry);
-      canLoadRemote = chromeReg.canLoadURLRemotely(url);
-      mustLoadRemote = chromeReg.mustLoadURLRemotely(url);
+      let url;
+      try {
+        // This can fail for invalid Chrome URIs, in which case we will end up
+        // not loading anything anyway.
+        url = Services.io.newURI(aURL, null, null);
+      } catch (ex) {
+        canLoadRemote = true;
+        mustLoadRemote = false;
+      }
+      if (url) {
+        let chromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"].
+                        getService(Ci.nsIXULChromeRegistry);
+        canLoadRemote = chromeReg.canLoadURLRemotely(url);
+        mustLoadRemote = chromeReg.mustLoadURLRemotely(url);
+      }
     }
 
     if (aURL.startsWith("moz-extension:")) {
       canLoadRemote = false;
       mustLoadRemote = false;
     }
 
     if (aURL.startsWith("view-source:")) {