Change the console execution target to the selected document in the inspector
Categories
(DevTools :: Console, enhancement, P3)
Tracking
(Not tracked)
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.
Comment 1•6 years ago
|
||
Bugbug thinks this bug should belong to this component, but please revert this change in case of error.
Comment 2•6 years ago
|
||
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?
Comment 3•6 years ago
|
||
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.
Comment 5•6 years ago
|
||
Note that bug 1580165 might fix that, or the other way around.
Comment 6•6 years ago
|
||
Yes, definitely part of execution context work (implicit context switching)!
Comment 7•5 years ago
|
||
Bug 1605175 made that work, but only for third parties iframe, which can be confusing for users.
Updated•3 years ago
|
Updated•3 years ago
|
Comment 8•2 years ago
|
||
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
Description
•