0

I'm developing a WebExtension compatible with chrome and FF, but in firefox I'm not able to see the variables or functions of the content scripts in the console.

In chrome you can change the scope of the console to see what your extension sees.

Is there a workaround in firefox to be able to debug my content scripts and execute browser functions? I can only have access to the background scripts or popup, but I need to access the content scripts context.

Thanks

2 Answers2

0

You can use the developer tools for debugging content scripts. They are not visible in the "debugging UI" which is accessible by the debug button on about:debugging.

If you don't see the content scripts or your addon in the normal developer tools, reload the current tab.

Smile4ever
  • 3,491
  • 2
  • 26
  • 34
  • in the about:debugging I can only access the background scripts. In the tabs the content scripts runs and I see them loaded in the debug tab of the developer tools but I can't access their scope in the console in order to execute a function from ther – Haibrayn González Mar 04 '18 at 21:17
  • Try setting a breakpoint in the content script and see whether you reach it. Also check closely when loading the addon using about:debugging that there are no errors in the browser console relating to your addon. – Smile4ever Mar 05 '18 at 08:23
  • I was able to see the scope of the content scripts, when using a breakpoint inside a content script and stopping there – Haibrayn González Apr 19 '18 at 23:03
0

I found out that the console of the debugging tools switches scopes when you set a breakpoint in the content script, otherwise you can only see the normal page scope and not the content scripts scope, and when you hit a breakpoint, you will see the scope of what the break point sees.

In chrome you can just switch the scope of the console.