11

Chrome dev tools allow to change javascript execution context.

enter image description here

It's very handy and I use it a lot in the debugging process.

But I need to test my project in Firefox and I can't find UI to change the execution context.

Does the Firefox has this feature?

3
  • See workarounds in How to access add-on content script in Firefox console?
    – woxxom
    Commented Nov 22, 2018 at 8:51
  • Thanks for the link, but it doesn't helpful in my case. I want to execute a function in the extension's javascript context to trace current state. It seems impossible to do with Firefox dev tools. The only workaraound I see is to add a listener in the content to execute the required function and trigger the execution from the background scripts. Commented Nov 22, 2018 at 9:29
  • You should clarify in your question that you refer to extension development and not to website development. Commented Nov 23, 2018 at 7:41

1 Answer 1

13

The Firefox DevTools have the same feature.

When a page contains at least one iFrame, there is a new button at the upper right corner of the DevTools window:

Button to select an iframe

Clicking this button opens a menu, which allows you to select the iframe. Hovering over the different entries even highlights the iframe or main document within the page to make it easier to identify them:

Menu to select the iframe and highlighting the hovered iframe

In contrast to the Chrome DevTools, this feature changes the context in all the panels, e.g. the Inspector will also be restricted to the document of the selected iframe.

You may need to enable it first. To do so, open the Settings panel (e.g. by pressing F1), then check the option Select an iframe as the currently targeted document:

Option to toggle the feature to select an iframe

5
  • 1
    Thanks, Sebastian, for your detailed reply. If I get it correct, I can change js context for iFrames only. Is it possible to change js context for an add-on currently running in the browser? Commented Nov 23, 2018 at 5:22
  • 2
    I'm not much into Firefox add-on development these days, but if it doesn't work within the normal DevTools, it will probably work in the Browser Toolbox. That window looks basically the same as the normal DevTools but allows you to inspect everything within the browser context. Commented Nov 23, 2018 at 7:39
  • 1
    Seems like this is enabled by default right now, I'm using FF 84 Commented Jan 18, 2021 at 23:10
  • Right, the button is shown automatically when there is at least one iFrame on the page. I've updated the answer a bit to reflect that. Commented Jan 19, 2021 at 7:21
  • 1
    @SebastianZartner ; THANK YOU!!!! Just save me a ton of frustration. My iframe is in a different domain so I wasn't able to access the content by default. Used the button and, viola, there's the URL for the iframe. {many pluses} Commented May 23, 2021 at 21:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.