Break point not hitting on dynamic javascript

1,471 views
Skip to first unread message

Jay

unread,
Nov 23, 2011, 1:19:06 AM11/23/11
to Google Chrome Developer Tools
I am using the instructions on this post section: "Breakpoints in
Dynamic JavaScript"
http://code.google.com/chrome/devtools/docs/scripts-breakpoints.html

I am loading script dynamically using the eval function. Once the
script is loaded using eval, I display the script in the script window
using the name I set for it at the end of the file. I place a break
point inside a function that is only displaying an alert box. Once I
call the function I see the alert box but the break point does not
hit. Is there something I am missing?

pfeldman

unread,
Nov 23, 2011, 1:51:23 AM11/23/11
to Google Chrome Developer Tools
Does the tutorial work for you? It goes through this exact scenario
with the "dynamicScript.js". Could it be that you are evaluaing the
script more than once? Can you include the timestamp into the
sourceURL to check it?

Jay

unread,
Nov 23, 2011, 10:21:07 AM11/23/11
to Google Chrome Developer Tools
Nope, it's definitively not evaluating more than once. I tried also in
firefox using firebug and the break point hit. It's wired, I can set
the break point fine in chrome but it just wont hit.

Jay

unread,
Nov 23, 2011, 11:55:56 PM11/23/11
to Google Chrome Developer Tools
Here is more information and a new issue was spotted.

Script.js file:
function MyScripts() {
this.ShowMessage = function ShowMessage() {
debugger;
alert("Message");
};
}
o = new MyScripts();
//@ sourceURL=Script.js

program script:
<div>
<script type="text/javascript">
var o = null;
function GetScript () {
$.ajax({url: '../../Scripts/
Script.js', datatype: 'text', async: false, cache: false, success:
function (c) { eval(c); }});
}
</script>
</div>
</body>
</html>

I call GetScript() from console and it loads the script. Then I call
o.ShowMessage().
Network Cache setting in chrome is disabled and cache is disabled in
the ajax call.

I was able to make to break execution by putting "debugger;" on top of
the alert('Message') in Script.js
but break point doesn't work. Also...
When I change the script and comment out the debugger line, it doesn't
break execution but I don't see it commented it out
in the script view for Script.js so it's not refreshing the script
correctly. It only loads the script
after the first GetScript call. So in summary, break point is not
hitting and Script.js view is not refreshing in
in chrome.

Screen shots:
https://lh5.googleusercontent.com/-98z_bYX-SdA/Ts3LiKcfZTI/AAAAAAAAAf4/gfm5ItBar4A/w891-h433-k/Debug.jpg
https://lh6.googleusercontent.com/-YwGnMOYyZGI/Ts3LiB4gP6I/AAAAAAAAAf0/sKQ49pU03X8/w500-h265-k/NoRefreshDebug.jpg

Reply all
Reply to author
Forward
0 new messages