Closed Bug 1588682 Opened 6 years ago Closed 2 years ago

Change the console execution target to the selected document in the inspector

Categories

(DevTools :: Console, enhancement, P3)

69 Branch
enhancement

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: capz, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0

Steps to reproduce:

open https://m.es.aliexpress.com/login.html
open the console (Ctrl + Shift + K)
write document.getElementById('fm-login-id') and press Enter

Actual results:

'null' appeared

Expected results:

a DOM object should have been returned. This is the id of the object reported by the Inspector tool, and it does work in Chromium.

Bugbug thinks this bug should belong to this component, but please revert this change in case of error.

Component: Untriaged → Console
Product: Firefox → DevTools

Hello cplopez, thanks for filing the bug.

So what happen is that the input is in an iframe, and the console evaluation context is the top level document, so we can't target this element directly.

What Chrome is doing though is that it changes the execution context of the console if you select an element in an iframe in the inspector, making this "work".
We might want to do something similar, but we need to work on the UI to make sure we don't confuse the user.

Harald, do you think this could be part of the "target selection" work that we talked about?

Status: UNCONFIRMED → NEW
Type: defect → enhancement
Ever confirmed: true
Flags: needinfo?(hkirschner)
Priority: -- → P3
Summary: Some DOM objects cannot be found by the console → Change the console execution target to the selected document in the inspector
Attached image image.png

if that can help you cplopez, you can change the evaluation with the "select an iframe as the currently targeted document" dropdown (you can enable it in the settings menu), or by executing the following command in the console: cd(document.querySelector("iframe"))

Yes, that works for me, thank you very much, Nicolas.

The functionality you propose would be very useful too, if added in the future.

Thanks.

Note that bug 1580165 might fix that, or the other way around.

Yes, definitely part of execution context work (implicit context switching)!

Flags: needinfo?(hkirschner)

Bug 1605175 made that work, but only for third parties iframe, which can be confusing for users.

Severity: normal → S3
Severity: normal → S3

with EFT, we now show the context selectors for all frames and selecting a node in an iframe does set its document as the evaluation context

Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: