Bug 1268285 - E10SUtils shouldn't throw when passed invalid chrome: URIs, r?felipe
MozReview-Commit-ID: CYof4pGFHIk
--- 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:")) {