PageDataChild: Return null channelInfo on non-HTTP channel

Rather than throwing. Fixes requireSuccessfulStatus on file: (etc.)
URIs.
This commit is contained in:
Abe Jellinek 2024-05-06 13:21:26 -04:00 committed by Dan Stillman
parent 9b7d3edbb3
commit 5f8ea3af9c

View file

@ -31,17 +31,18 @@ class PageDataChild extends JSWindowActorChild {
case "channelInfo": {
let docShell = this.contentWindow.docShell;
let channel = (docShell.currentDocumentChannel || docShell.failedChannel)
?.QueryInterface(Ci.nsIHttpChannel);
if (channel) {
return {
responseStatus: channel.responseStatus,
responseStatusText: channel.responseStatusText
};
}
else {
return null;
try {
let channel = (docShell.currentDocumentChannel || docShell.failedChannel)
?.QueryInterface(Ci.nsIHttpChannel);
if (channel) {
return {
responseStatus: channel.responseStatus,
responseStatusText: channel.responseStatusText
};
}
}
catch (e) {}
return null;
}
}
}