firefox/D177902.diff
2023-05-24 11:08:25 +02:00

33 lines
1.6 KiB
Diff

diff --git a/devtools/server/actors/resources/console-messages.js b/devtools/server/actors/resources/console-messages.js
--- a/devtools/server/actors/resources/console-messages.js
+++ b/devtools/server/actors/resources/console-messages.js
@@ -64,16 +64,23 @@
// that process (window and window-less).
// To do that we pass a null window and ConsoleAPIListener will catch everything.
// And also ignore WebExtension as we will filter out only by addonId, which is
// passed via consoleAPIListenerOptions. WebExtension may have multiple windows/documents
// but all of them will be flagged with the same addon ID.
- const window =
+ const messagesShouldMatchWindow =
targetActor.targetType === Targets.TYPES.FRAME &&
targetActor.typeName != "parentProcessTarget" &&
- targetActor.typeName != "webExtensionTarget"
- ? targetActor.window
- : null;
+ targetActor.typeName != "webExtensionTarget";
+ const window = messagesShouldMatchWindow ? targetActor.window : null;
+
+ // If we should match messages for a given window but for some reason, targetActor.window
+ // did not return a window, bail out. Otherwise we wouldn't have anything to match against
+ // and would consume all the messages, which could lead to issue (e.g. infinite loop,
+ // see Bug 1828026).
+ if (messagesShouldMatchWindow && !window) {
+ return;
+ }
const listener = new ConsoleAPIListener(window, onConsoleAPICall, {
excludeMessagesBoundToWindow: isTargetActorContentProcess,
matchExactWindow: targetActor.ignoreSubFrames,
...(targetActor.consoleAPIListenerOptions || {}),