Bug 1207784 - skip permission hooks in createOffer when called from hiddenWindow (add-ons). r=mt a=sylvestre
authorJan-Ivar Bruaroey <jib@mozilla.com>
Fri, 16 Oct 2015 12:16:24 -0400
changeset 296510 c2d1c0fe2e8d9e661636696b7eca5bcf09d30d49
parent 296509 5e6f7c5bd45c08938fe088e6e058e32aaa7495c9
child 296511 ffa9e4184d55a68ffbc86d817e8764ddd81282cf
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 hiddenWindow (add-ons). r=mt a=sylvestre
browser/modules/ContentWebRTC.jsm
--- a/browser/modules/ContentWebRTC.jsm
+++ b/browser/modules/ContentWebRTC.jsm
@@ -90,30 +90,40 @@ this.ContentWebRTC = {
     }
   }
 };
 
 function handlePCRequest(aSubject, aTopic, aData) {
   let { windowID, innerWindowID, callID, isSecure } = aSubject;
   let contentWindow = Services.wm.getOuterWindowWithId(windowID);
 
+  let mm = getMessageManagerForWindow(contentWindow);
+  if (!mm) {
+    // Workaround for Bug 1207784. To use WebRTC, add-ons right now use
+    // hiddenWindow.mozRTCPeerConnection which is only privileged on OSX. Other
+    // platforms end up here without a message manager.
+    // TODO: Remove once there's a better way (1215591).
+
+    // Skip permission check in the absence of a message manager.
+    Services.obs.notifyObservers(null, "PeerConnection:response:allow", callID);
+    return;
+  }
+
   if (!contentWindow.pendingPeerConnectionRequests) {
     setupPendingListsInitially(contentWindow);
   }
   contentWindow.pendingPeerConnectionRequests.add(callID);
 
   let request = {
     windowID: windowID,
     innerWindowID: innerWindowID,
     callID: callID,
     documentURI: contentWindow.document.documentURI,
     secure: isSecure,
   };
-
-  let mm = getMessageManagerForWindow(contentWindow);
   mm.sendAsyncMessage("rtcpeer:Request", request);
 }
 
 function handleGUMRequest(aSubject, aTopic, aData) {
   let constraints = aSubject.getConstraints();
   let secure = aSubject.isSecure;
   let contentWindow = Services.wm.getOuterWindowWithId(aSubject.windowID);