Bug 1304752 - Check for null channel.loadInfo in NetworkMonitor r=ochameau
authorJarda Snajdr <jsnajdr@gmail.com>
Fri, 25 Nov 2016 11:22:57 +0100
changeset 324298 f05afddd1179c674476af7db84e5714c5f81843a
parent 324297 37505199226108e7f8eb209407c49d611f01dd97
child 324299 e84ab1f4e44f266d0597c768414dfccd8b160b12
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersochameau
bugs1304752
milestone53.0a1
Bug 1304752 - Check for null channel.loadInfo in NetworkMonitor r=ochameau MozReview-Commit-ID: 129eLxSnmi1
devtools/shared/webconsole/network-monitor.js
--- a/devtools/shared/webconsole/network-monitor.js
+++ b/devtools/shared/webconsole/network-monitor.js
@@ -1074,29 +1074,37 @@ NetworkMonitor.prototype = {
     event.fromServiceWorker = fromServiceWorker;
     httpActivity.fromServiceWorker = fromServiceWorker;
 
     if (extraStringData) {
       event.headersSize = extraStringData.length;
     }
 
     // Determine the cause and if this is an XHR request.
-    let causeType = channel.loadInfo.externalContentPolicyType;
-    let loadingPrincipal = channel.loadInfo.loadingPrincipal;
-    let causeUri = loadingPrincipal ? loadingPrincipal.URI : null;
+    let causeType = Ci.nsIContentPolicy.TYPE_OTHER;
+    let causeUri = null;
     let stacktrace;
+
+    if (channel.loadInfo) {
+      causeType = channel.loadInfo.externalContentPolicyType;
+      const { loadingPrincipal } = channel.loadInfo;
+      if (loadingPrincipal && loadingPrincipal.URI) {
+        causeUri = loadingPrincipal.URI.spec;
+      }
+    }
+
     // If this is the parent process, there is no stackTraceCollector - the stack
     // trace will be added in NetworkMonitorChild._onNewEvent.
     if (this.owner.stackTraceCollector) {
       stacktrace = this.owner.stackTraceCollector.getStackTrace(event.channelId);
     }
 
     event.cause = {
       type: causeType,
-      loadingDocumentUri: causeUri ? causeUri.spec : null,
+      loadingDocumentUri: causeUri,
       stacktrace
     };
 
     httpActivity.isXHR = event.isXHR =
         (causeType === Ci.nsIContentPolicy.TYPE_XMLHTTPREQUEST ||
          causeType === Ci.nsIContentPolicy.TYPE_FETCH);
 
     // Determine the HTTP version.