Bug 1583117 - Markup view is blank if an error is thrown gathering event listeners r=pbro
authorMichael Ratcliffe <mratcliffe@mozilla.com>
Mon, 14 Oct 2019 12:23:13 +0000
changeset 497417 cbf93a9af5026f51e23069851ed5953b67be78f4
parent 497416 420cf92dd35cf9d43ce558a51cd0af67c2b48723
child 497418 54b7889d4457f4e94ba2dceb0de8f1a0e4fbfb41
push id36689
push userncsoregi@mozilla.com
push dateMon, 14 Oct 2019 21:30:51 +0000
treeherdermozilla-central@a212b426f665 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspbro
bugs1583117
milestone71.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1583117 - Markup view is blank if an error is thrown gathering event listeners r=pbro Differential Revision: https://phabricator.services.mozilla.com/D49134
devtools/server/actors/inspector/event-collector.js
--- a/devtools/server/actors/inspector/event-collector.js
+++ b/devtools/server/actors/inspector/event-collector.js
@@ -299,25 +299,32 @@ class MainEventCollector {
     return null;
   }
 
   unwrap(obj) {
     return Cu.isXrayWrapper(obj) ? obj.wrappedJSObject : obj;
   }
 
   isChromeHandler(handler) {
-    const handlerPrincipal = Cu.getObjectPrincipal(handler);
+    try {
+      const handlerPrincipal = Cu.getObjectPrincipal(handler);
 
-    // Chrome codebase may register listeners on the page from a frame script or
-    // JSM <video> tags may also report internal listeners, but they won't be
-    // coming from the system principal. Instead, they will be using an expanded
-    // principal.
-    return (
-      handlerPrincipal.isSystemPrincipal || handlerPrincipal.isExpandedPrincipal
-    );
+      // Chrome codebase may register listeners on the page from a frame script or
+      // JSM <video> tags may also report internal listeners, but they won't be
+      // coming from the system principal. Instead, they will be using an expanded
+      // principal.
+      return (
+        handlerPrincipal.isSystemPrincipal ||
+        handlerPrincipal.isExpandedPrincipal
+      );
+    } catch (e) {
+      // Anything from a dead object to a CSP error can leave us here so let's
+      // return false so that we can fail gracefully.
+      return false;
+    }
   }
 }
 
 /**
  * Get or detect DOM events. These may include DOM events created by libraries
  * that enable their custom events to work. At this point we are unable to
  * effectively filter them as they may be proxied or wrapped. Although we know
  * there is an event, we may not know the true contents until it goes