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 289584 dc552539eb77
parent 289583 c3daaf421fe6
child 289585 341d7a3d7320
push id5201
push userkwierso@gmail.com
push date2015-10-19 16:29 +0000
treeherdermozilla-beta@c5bd26c10432 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmt, sylvestre
bugs1207784
milestone42.0
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
@@ -75,30 +75,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);