WebConsoleActor fails to work when no window/evalWindow is available.

RESOLVED WONTFIX

Status

DevTools
General
RESOLVED WONTFIX
4 years ago
a month ago

People

(Reporter: markh, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

4 years ago
Created attachment 8523483 [details] [diff] [review]
0004-Bug-XXXXXXX-allow-the-ConsoleActor-to-work-without-a.patch

The WebConsoleActor seems to make some effort to work without a window/evalWindow, but doesn't.  This patch makes it work for me in bug 809561 by taking a short-cut when no window is available and just using the frame.
Attachment #8523483 - Flags: feedback?(past)
Comment on attachment 8523483 [details] [diff] [review]
0004-Bug-XXXXXXX-allow-the-ConsoleActor-to-work-without-a.patch

Review of attachment 8523483 [details] [diff] [review]:
-----------------------------------------------------------------

This doesn't seem right, if there is no evalWindow then something must've gone wrong earlier. We need to figure out why the xpcshell test global object wasn't used here.
Attachment #8523483 - Flags: feedback?(past) → feedback-
(Reporter)

Comment 2

4 years ago
(In reply to Panos Astithas [:past] (overloaded, please needinfo) from comment #1)
> This doesn't seem right, if there is no evalWindow then something must've
> gone wrong earlier. We need to figure out why the xpcshell test global
> object wasn't used here.

So the evalWindow getter is:

  get evalWindow() {
    return this._evalWindow || this.window;
  },

The window getter is:

  get window() {
    if (this.parentActor.isRootActor) {
      return this._getWindowForBrowserConsole();
    }
    return this.parentActor.window;
  },

In this case the parent is the root, so we call _getWindowForBrowserConsole() - but this code is looking for a *real* window, which doesn't exist in xpcshell.

So the only real option seems to be to call the actor.evalWindow setter - but this actor is created automagically by the root implementation.

Past, does that sound correct?  If so, how should I get a reference to the actor to make that call?  Or will I need to create a new webconsole actor impl which "derives" from the base one and get that hooked into the actor map?
Flags: needinfo?(past)
(In reply to Mark Hammond [:markh] from comment #0)
> This patch makes it work for me in bug
> 809561 by taking a short-cut when no window is available and just using the
> frame.

One problem with this approach is that we only have a frame available when the debugger has paused execution. If execution is not paused when evaluation takes place, the console backend will just throw.

(In reply to Mark Hammond [:markh] from comment #2)
> In this case the parent is the root, so we call
> _getWindowForBrowserConsole() - but this code is looking for a *real*
> window, which doesn't exist in xpcshell.

I think our best option here is to tweak _getWindowForBrowserConsole() to return the test global. Alternatively, we could also change the console actor's window getter to use parentActor.window in this case (even though the parent is a root actor) and have the root actor supply the right global.

> So the only real option seems to be to call the actor.evalWindow setter -
> but this actor is created automagically by the root implementation.

evalWindow appeared as a side-effect of handling evaluation in iframes, I believe |window| is the right thing to modify, as it is more broadly consulted.
Flags: needinfo?(past)
(Reporter)

Comment 4

4 years ago
We no longer need this for xpcshell debugging, so it can revisited at a later date when requirements are clearer.
Status: NEW → RESOLVED
Last Resolved: 4 years ago
Resolution: --- → WONTFIX

Updated

a month ago
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.