Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is the FireFox debugger not showing full source code?

I am trying to debug a web page in FireFox v42.0 Windows 10, where that web page goes through a proxy server and has code injected into it inline via <script>...</script> (not including a separate .js file) by the proxy server. When I right-click View Page Source, I see the original page plus the code I expect to see injected (and which is actually running). I also see the injected content in the DOM view of the Inspector tab. And it is also visible in the Network Tab in the Response section. However, when I view the same page in the debugger, the injected code is not visible, as if the page were not running through the proxy server.

Furthermore, if I insert a debugger; statement in the injected code, I do hit the breakpoint, but in the FireFox debugger tab it tells me I'm on line 550 of a file with only 173 lines in it according to FireFox. So I can not step through the code.

When I do the same thing in Chrome, I see what I'm expecting, which is the injected code in my page, and I am able to debug this code without problem.

I have cleared my cache to no effect. I looked at the Network tab and everything looks as expected there.

How and why is FireFox not showing me the actual page in the debugger tab (matching what's in View Source or the DOM view), and not letting my step through the injected code?

like image 273
Danger Avatar asked Jan 10 '16 01:01

Danger


People also ask

How do I use Firefox developer tools Debugger?

There are three ways to open the debugger: Select the Debugger panel in the Web Developer Tools, accessible from the Browser Tools submenu. Press Ctrl + Shift + Z on Windows and Linux, or Cmd + Opt + Z on macOS (starting in Firefox 71; prior to Firefox 66, the letter in this shortcut was S ). Press the menu button.

How do I add a breakpoint to Debugger in Firefox?

You can set an unconditional breakpoint using the context menu (see above), or by: Clicking on the line number for the line you want to break at in the source pane. Highlighting the line you want to break at in the source pane and pressing Ctrl + B (Windows/Linux) or Cmd + B (macOS).

Where is sources in Firefox developer tools?

To activate View Source: context-click in the page and select View Page Source. press Ctrl + U on Windows and Linux, or Cmd + U on macOS.


2 Answers

The below worked for me

  1. Copy url from address bar and close the tab.
  2. Open the url in private mode, the debugger shows the source.
  3. Close private window and open in default mode, the debugger shows the source now.
like image 80
Abhinav Atul Avatar answered Sep 19 '22 02:09

Abhinav Atul


There are a few bugs in Firefox that can cause this that I've encountered myself:

  • A local caching issue which can be solved by first closing the dev tools window, hard-reloading the page (Ctrl/Cmd + Shift + R), then opening the debugger again.
  • Trying to debug a tab in a container, but the source is showing the page as it would be outside a container. See bug 1375036). This particular case should now be fixed.
  • Similar to the previous point, the debugger source showing you a slighty/completely different document to the one that's actually currently rendered by the browser. This is due to the fact that the debugger does not have access to the original markup & inline script the browser used to render the current page! Apparently designed that way to be memory efficient, but seems to ignore the fact that a developer wants to use the memory for storing the source, because they want the actual source. See bugs such as 1060732, 1149835, and 1472581.

If this is happening to you try debugging in the default/no container, or just do it in Chrome 🙁. If you can't debug in another browser, at least try a fresh profile before you "refresh" (nuke) Firefox as others suggest. You can do this from the about:profiles page (address must be typed manually or bookmarked), or by opening Firefox with the -P flag and creating a new one. To use those flags, run firefox -P --no-remote from a *nix/Mac terminal or C:\Program Files\Firefox Developer Edition\firefox.exe -P --no-remote from the Windows Run dialogue; the --no-remote flag is not required but allows you to run the new profile alongside your main one, and disregard links clicked in other programs.

like image 22
Walf Avatar answered Sep 23 '22 02:09

Walf