Bug 1207784 - skip permission hooks in createOffer when called from privileged code (add-ons). r=mt, a=sylvestre
authorJan-Ivar Bruaroey <jib@mozilla.com>
Thu, 01 Oct 2015 15:49:01 -0400
changeset 296310 319cc68b36586e68c74fbe8f29f0b77f4f7d96a5
parent 296309 5ec1a05468a6d282e2801b8a34bf2a9a6565f907
child 296311 52a759d2958447f4bde3a882afe211b2bd7ba1d7
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmt, sylvestre
bugs1207784
milestone43.0a2
Bug 1207784 - skip permission hooks in createOffer when called from privileged code (add-ons). r=mt, a=sylvestre
dom/media/PeerConnection.js
--- a/dom/media/PeerConnection.js
+++ b/dom/media/PeerConnection.js
@@ -382,18 +382,19 @@ RTCPeerConnection.prototype = {
       }
     } else {
       // This gets executed in the typical case when iceServers
       // are passed in through the web page.
       this._mustValidateRTCConfiguration(rtcConfig,
         "RTCPeerConnection constructor passed invalid RTCConfiguration");
     }
     // Save the appId
-    this._appId = Cu.getWebIDLCallerPrincipal().appId;
-    this._https = this._win.document.documentURIObject.schemeIs("https");
+    var principal = Cu.getWebIDLCallerPrincipal();
+    this._appId = principal.appId;
+    this._isChrome = Services.scriptSecurityManager.isSystemPrincipal(principal);
 
     // Get the offline status for this appId
     let appOffline = false;
     if (this._appId != Ci.nsIScriptSecurityManager.NO_APP_ID &&
         this._appId != Ci.nsIScriptSecurityManager.UNKNOWN_APP_ID) {
       let ios = Cc['@mozilla.org/network/io-service;1'].getService(Ci.nsIIOService);
       appOffline = ios.isAppOffline(this._appId);
     }
@@ -773,17 +774,18 @@ RTCPeerConnection.prototype = {
       });
     });
   },
 
   getPermission: function() {
     if (this._havePermission) {
       return this._havePermission;
     }
-    if (AppConstants.MOZ_B2G ||
+    if (this._isChrome ||
+        AppConstants.MOZ_B2G ||
         Services.prefs.getBoolPref("media.navigator.permission.disabled")) {
       return this._havePermission = Promise.resolve();
     }
     return this._havePermission = new Promise((resolve, reject) => {
       this._settlePermission = { allow: resolve, deny: reject };
       let outerId = this._win.QueryInterface(Ci.nsIInterfaceRequestor).
           getInterface(Ci.nsIDOMWindowUtils).outerWindowID;