Bug 1385696 - Fix retrieval of protocol flags. r=Gijs, a=gchang
authorShane Caraveo <scaraveo@mozilla.com>
Wed, 02 Aug 2017 14:03:37 -0700
changeset 421152 5ee15d0b8f882d0f34d4aebd88fdc8bc9fd1316d
parent 421151 5fbb7413a6d4ec3aba41acf456d3efaeed02ce24
child 421153 9aad906a960fc09af929d838d6fbce660f8f3c58
push id7611
push userryanvm@gmail.com
push dateMon, 14 Aug 2017 13:07:50 +0000
treeherdermozilla-beta@3d1029848041 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs, gchang
bugs1385696
milestone56.0
Bug 1385696 - Fix retrieval of protocol flags. r=Gijs, a=gchang MozReview-Commit-ID: 8zYVnvg0x21
browser/base/content/tabbrowser.xml
browser/base/content/utilityOverlay.js
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -2625,17 +2625,17 @@
             var evt = new CustomEvent("TabOpen", { bubbles: true, detail });
             t.dispatchEvent(evt);
 
             if (!usingPreloadedContent && aOriginPrincipal && aURI) {
               let {URI_INHERITS_SECURITY_CONTEXT} = Ci.nsIProtocolHandler;
               // Unless we know for sure we're not inheriting principals,
               // force the about:blank viewer to have the right principal:
               if (!aURIObject ||
-                  (Services.io.getProtocolFlags(aURIObject.scheme) & URI_INHERITS_SECURITY_CONTEXT)) {
+                  (doGetProtocolFlags(aURIObject) & URI_INHERITS_SECURITY_CONTEXT)) {
                 b.createAboutBlankContentViewer(aOriginPrincipal);
               }
             }
 
             // If we didn't swap docShells with a preloaded browser
             // then let's just continue loading the page normally.
             if (!usingPreloadedContent && (!uriIsAboutBlank || aDisallowInheritPrincipal)) {
               // pretend the user typed this so it'll be available till
--- a/browser/base/content/utilityOverlay.js
+++ b/browser/base/content/utilityOverlay.js
@@ -71,16 +71,24 @@ function openTopWin(url) {
 function getBoolPref(prefname, def) {
   try {
     return Services.prefs.getBoolPref(prefname);
   } catch (er) {
     return def;
   }
 }
 
+function doGetProtocolFlags(aURI) {
+  let handler = Services.io.getProtocolHandler(aURI.scheme);
+  // see DoGetProtocolFlags in nsIProtocolHandler.idl
+  return handler instanceof Ci.nsIProtocolHandlerWithDynamicFlags ?
+         handler.QueryInterface(Ci.nsIProtocolHandlerWithDynamicFlags).getFlagsForURI(aURI) :
+         handler.protocolFlags;
+}
+
 /* openUILink handles clicks on UI elements that cause URLs to load.
  *
  * As the third argument, you may pass an object with the same properties as
  * accepted by openUILinkIn, plus "ignoreButton" and "ignoreAlt".
  */
 function openUILink(url, event, aIgnoreButton, aIgnoreAlt, aAllowThirdPartyFixup,
                     aPostData, aReferrerURI) {
   let params;
@@ -424,17 +432,17 @@ function openLinkIn(url, where, params) 
     }
     if (aIndicateErrorPageLoad) {
       flags |= Ci.nsIWebNavigation.LOAD_FLAGS_ERROR_LOAD_CHANGES_RV;
     }
 
     let {URI_INHERITS_SECURITY_CONTEXT} = Ci.nsIProtocolHandler;
     if (aForceAboutBlankViewerInCurrent &&
         (!uriObj ||
-         (Services.io.getProtocolFlags(uriObj.scheme) & URI_INHERITS_SECURITY_CONTEXT))) {
+         (doGetProtocolFlags(uriObj) & URI_INHERITS_SECURITY_CONTEXT))) {
       // Unless we know for sure we're not inheriting principals,
       // force the about:blank viewer to have the right principal:
       targetBrowser.createAboutBlankContentViewer(aPrincipal);
     }
 
     targetBrowser.loadURIWithFlags(url, {
       triggeringPrincipal: aTriggeringPrincipal,
       flags,