Open Bug 1426736 Opened 7 years ago Updated 2 years ago

Console in browser content toolbox doesn't really work

Categories

(DevTools :: Console, defect, P3)

defect

Tracking

(Not tracked)

People

(Reporter: bzbarsky, Unassigned)

References

(Depends on 1 open bug)

Details

STEPS TO REPRODUCE: 1) Flip the various prefs you need to flip to enable the browser content toolbox (devtools.chrome.enabled, devtools.debugger.remote-enabled). 2) Load https://planet.mozilla.org/atom.xml 3) Open the browser content toolbox. 4) In the console in the toolbox, type "document.nodePrincipal" EXPECTED RESULTS: See the principal ACTUAL RESULTS: ReferenceError: document is not defined I would expect the toolbox to be evaluating in a sandbox attached to the page global, just like a normal console does. But with system privileges...
Currently, the Browser Content Toolbox represents all tabs for that content process. You _can_ access the page global, but it is currently indirect through an array of all the tabs: ``` tabs[0].content.document.nodePrincipal ``` At the moment, there's no great way to find the focused tab's global in the array. Exposing in some way would make common usage easier.
(The `tabs` getter mentioned in comment 1 appeared in 58 from bug 1401343.) I did attempt the more "direct" thing that comment 0 was hoping for here in bug 1346316, but some improvements were suggested and then I never had a chance to come back to it. Now that we do have `tabs`, another getter for `focusedTab` (or else providing the index into the `tabs` array at least) would be nice.
Ah, I see. Alright, just knowing what sort of environment I am in is actually good enough for my use cases (that mostly being testing Xrays).
(In reply to J. Ryan Stinnett [:jryans] (use ni?) from comment #1) > Currently, the Browser Content Toolbox represents all tabs for that content > process. You _can_ access the page global, but it is currently indirect > through an array of all the tabs: > > ``` > tabs[0].content.document.nodePrincipal > ``` > > At the moment, there's no great way to find the focused tab's global in the > array. Exposing in some way would make common usage easier. From cursory testing this seems to work at least: let focusedTab = tabs.reduce((a, t) => t.docShell.isActive ? t : a, undefined);
Product: Firefox → DevTools
Maybe we could log a message in the browser content toolbox to indicate how to retrieve the current focused tab ? It may be a bit noisy over time though
Depends on: 1346316
Priority: -- → P3
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.