vscode-js-debug icon indicating copy to clipboard operation
vscode-js-debug copied to clipboard

iframes are not listed as session

Open hediet opened this issue 2 years ago • 3 comments

When debugging a webpage with an iframe, iframes are not listed as session in VS Code:

Image

However, chrome lists them as sessions:

Image

Which is also convenient in the dev console:

Image

In VS Code I cannot select the iframe as my target element in the dev console. This is especially problematic when the iframe has a different origin and is inaccessible from the main window - in that case there is no way to inspect global variables of the iframe while the execution is not paused in it.

Probably https://github.com/microsoft/vscode-js-debug/issues/1432 is related.

demo.zip

hediet avatar Sep 26 '23 13:09 hediet

You can use the cd command to do this

image

It's not super discoverable.

I'm not actually sure why we don't have iframes be different debug sessions, but do for workers. (This was done in the prototype version of js-debug that I took over years ago.) Making them their own sessions would reduce complexity and allow a more natural target switching.

connor4312 avatar Oct 03 '23 21:10 connor4312

How can extensions send an eval request for those sessions?

Making them their own sessions would reduce complexity and allow a more natural target switching.

It would also better align with what chrome and edge does.

hediet avatar Oct 04 '23 13:10 hediet

Looking more: in chrome iframes are not really separate sessions, just separate execution contexts. While some things are separate, other things are the same. For example, the state of the debugger (paused/resumed) is shared across all execution contexts, and therefore iframes. In DAP we don't have a way to represent this very well.

The fact the the CDP debugger is the same for all frames in the frame tree makes this hard to map to the current js-debug architecture which is 1:1 between CDP debuggers and debug session.

connor4312 avatar Oct 05 '23 22:10 connor4312