Bug 1304752 - Check for null channel.loadInfo in NetworkMonitor r?ochameau
MozReview-Commit-ID: 129eLxSnmi1
--- 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.