Bug 31043 - Web Inspector: REGRESSION: breakpoints set in code run during initial page load not honored during reload
Summary: Web Inspector: REGRESSION: breakpoints set in code run during initial page lo...
Status: RESOLVED DUPLICATE of bug 28799
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (Deprecated) (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-11-02 21:33 PST by Patrick Mueller
Modified: 2010-03-09 11:27 PST (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Patrick Mueller 2009-11-02 21:33:57 PST
In Safari 4.0.3, you can set a breakpoint in JavaScript code that is run during the initial page load.  If the page is reloaded, the debugger will stop on these breakpoints during the initial page load.

In nightly r50423 (and earlier, but not sure when), I'm unable to get the debugger to stop in these "initial page load" breakpoints.

Note that the debugger WILL stop in "initial page load" code for "debugger" JavaScript statements, but not for breakpoints.
Comment 1 Patrick Mueller 2009-11-06 11:02:40 PST
Did a little more investigation on this.

Here's an HTML file to load:

----- snip -----
<p>hello

<script>
if (!true) debugger;
console.log(new Date().getTime() + ": user app starting");
document.title = new Date();
console.log(new Date().getTime() + ": user app finishing");
</script>
    
<p>world
----- snip -----

Augment ScriptsPanel.js's addScript() method to add the following line as the first line in the method:

----- snip -----
WebInspector.log(new Date().getTime() + ": ScriptPanel.addScript(" + sourceURL + ")");    
----- snip -----

Now, load the page, open inspector, go the Scripts panel, open the console, and reload the page.  You should see something like below:

----- snip -----
1257533565513: ScriptPanel.addScript(file:///Users/pmuellr/tmp/test_reload.html)
1257533565496: user app starting
1257533565497: user app finishing
1257533565534: ScriptPanel.addScript()
1257533565535: ScriptPanel.addScript()
----- snip -----

Note that the lines are out of order.  The "user app" messages are actually generated BEFORE the call to addScript(), but get added after it in the log; having the out of order messages isn't an issue (as far as I'm concerned).

The issue IS that there's no way the breakpoints could get hit if addScript() isn't run to reset the sourceIDs in the first place.  This out-of-order behavior happens if you have breakpoints set in the HTML file or not.

One last thing to try.  Change the "if (!true)" at the beginning of the HTML file to "if (true)".  This will cause the debugger statement to be executed.  In this case, during a reload. addScript() is actually run before the JavaScript is run, so you will actually stop at the debugger statement.
Comment 2 Pavel Feldman 2010-03-09 11:27:01 PST

*** This bug has been marked as a duplicate of bug 28799 ***