Bug 1335807 - JavaScript Error: 'NS_NOINTERFACE: ' {file: 'resource:///modules/ContentWebRTC.jsm' line: 387}, r=felipe.
authorFlorian Quèze <florian@queze.net>
Thu, 16 Feb 2017 00:13:46 +0100
changeset 485043 d686f96840e6393400b06a54635a99f3477d2da8
parent 485042 8479323bb43cc15ecfa4983acdce56875b6d25a8
child 485044 4ea36a9c2dfdaa7dcc110de361cd20d22efb231f
push id45611
push userbmo:gasolin@mozilla.com
push dateThu, 16 Feb 2017 01:39:57 +0000
reviewersfelipe
bugs1335807
milestone54.0a1
Bug 1335807 - JavaScript Error: 'NS_NOINTERFACE: ' {file: 'resource:///modules/ContentWebRTC.jsm' line: 387}, r=felipe.
browser/modules/ContentWebRTC.jsm
--- a/browser/modules/ContentWebRTC.jsm
+++ b/browser/modules/ContentWebRTC.jsm
@@ -380,22 +380,33 @@ function getTabStateForContentWindow(aCo
 
 function getInnerWindowIDForWindow(aContentWindow) {
   return aContentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
                        .getInterface(Ci.nsIDOMWindowUtils)
                        .currentInnerWindowID;
 }
 
 function getMessageManagerForWindow(aContentWindow) {
-  let ir = aContentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
-                         .getInterface(Ci.nsIDocShell)
-                         .sameTypeRootTreeItem
-                         .QueryInterface(Ci.nsIInterfaceRequestor);
+  aContentWindow.QueryInterface(Ci.nsIInterfaceRequestor);
+
+  let docShell;
   try {
-    // If e10s is disabled, this throws NS_NOINTERFACE for closed tabs.
+    // This throws NS_NOINTERFACE for closed tabs.
+    docShell = aContentWindow.getInterface(Ci.nsIDocShell);
+  } catch (e) {
+    if (e.result == Cr.NS_NOINTERFACE) {
+      return null;
+    }
+    throw e;
+  }
+
+  let ir = docShell.sameTypeRootTreeItem
+                   .QueryInterface(Ci.nsIInterfaceRequestor);
+  try {
+    // This throws NS_NOINTERFACE for closed tabs (only with e10s enabled).
     return ir.getInterface(Ci.nsIContentFrameMessageManager);
   } catch (e) {
     if (e.result == Cr.NS_NOINTERFACE) {
       return null;
     }
     throw e;
   }
 }