Reputation: 871
Normally, when I use the Console
tab of the developer tools in Chrome, I see a list of iFrames like the following:
However, after I installed a certain extension I see the extension ID below a number of iFrames in the Console
tab like following:
Can anybody tell me what does that mean? I suppose that those iFrames' parent is the extension but I am not sure. Can anyone please correct me if I am wrong?
Also, if those iFrames' parent is the extension is there any way to track them? By track them I mean that say I want to run the command window.open = function () { debugger; }
for all such frames, is it possible for me to do so?
Upvotes: 0
Views: 123
Reputation: 13495
What you are looking at are the extensions content scripts. They are actually loaded as a child of either each tab or (in the case of this extension) each iFrame.
If you select one in the console, and do:
> chrome.runtime.getManifest()
The most relevant output is:
{ ...
content_scripts: Array[1]
0: Object
all_frames: true
js: Array[#]
0: "content.js"
...
Here, the all_frames is the reason you see the extension repeated after each frame instead of once under the tab's main window.
(There may also be a background, which you can inspect from the extension's listing in settings.)
To debug content Scripts, there is actually a tab under the Developer Console->Sources. Here I have set a breakpoint on a specific line during the content scripts initialization (after expanding the code with the "{}" icon):
When changing an iFrame or reloading the entire window, each content script then pauses at this point while the developer tools are open.
There are some content script limits, so you should not be able to arbitrarily execute code in one iFrame from another though there is a message passing system which can achieve similar results if listeners are specifically setup.
Upvotes: 1