Here's a little description of the program flow I'm trying to achieve:
mainPage->Button->onButtonClick()->window.open->PHPfile->EmbeddedJS->breakInEmbeddedJS
In words, I have a main page with a button. The button's onClick is a JavaScript function. The JavaScript function runs a window.open to a PHP file which dynamically generates JavaScript code. I want to be able to debug the dynamically generated JavaScript code.
I am able to get the JavaScript on the "main page" containing the "window.open function" button to break into the Komodo debugger, but I have NOT been able to get debugger time in the dynamic code in the new window.
I've tried using "debugger;" in several places in the dynamically-generated JS, and I've played with 'break on next JS' flag to no avail.
When the new window opens, it doesn't have a 'connection' to the JavaScript debugger, or at least the JS debugger icon doesn't say it has (it isn't depressed/active by default). I think the code may be running before I'm able to hit 'connect' in the new window.
Thing is, I run a JavaScript setTimeout() function loop in the dynamic code, which continually calls a function (just so happens to be an AJAX status query), but I would think that pressing 'connect to Komodo debugger' would hop right in and start handling running code.
Guidance would be appreciated...
Komodo IDE, version 4.1.0, build 278996, platform win32-x86.
Built on Thu May 10 17:53:20 2007.
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4
I created a web page that creates a new window, but the JS code is static:
<script LANGUAGE="JavaScript">
function doBookMarklet1() {
try {
var sel=getSelection();
var today=new Date();
var currURI=document.location;
var theWindow=open('', 'w' + today.getTime(),
'width=400,height=300');
debugger;
theWindow.document.write('
\n'
+ sel
+ '\n
<\/textarea><\/form><\/center>');
debugger;
theWindow.document.close();
} catch (ex) {
alert(ex + "");
}
return;
}
</script>
...
<a href="javascript?();">Open a window</a><br />
Are you generating the code at runtime in an eval() statement, or
does it look something like this?
My mistake: What I meant by dynamic is that the PHP assembled some JavaScript to be sent to the browser statically.
I am willing to forward a full-page verbatim copy of the content in question in a non-public area.
Will test the above in a moment.
I think perhaps the difference between my environment and your example is that my script begins running (function definitions, then calls into those functions) as soon as the page is loaded, and continues to run via setTimeout loops.
Admittedly I am having difficulty replicating my problem outside the live environment.
I might propose that it has something to do perhaps not with necessarily with a setTimeout() loop (which I have gotten to debug with a minimal mock-up) but with constantly(?) being busy in AJAX calls?
If your live system generates some code and then evals it to activate it,
which can happen with setTimeout calls, this might be the culprit.
I've un-nested the "non-debuggable" page from its own window and have begun pulling it up directly.
Oddly, Komodo DOES begin debugging one-of-several included .js files, but appears to utterly skip the "debugger;" statement embedded statically directly onto the page.
No JS or PHP eval()'ing is done. This use-case generates a known, trackable output for this module.
Okay, well.
Un-nested, and several tries later and now it's working as if it was never broken.
Maybe it wasn't.
I blame Venus, Pluto, and Alpha Centauri for aligning just-so and causing only my debugging experience to go awry.
Thanks for the quick responses, I think I'm okay now.
Maybe it's a good thing that Pluto was demoted from planethood.
It even works nested, too.
Punch 'connect' in Firefox for JS, press my button, and Komodo breaks in the code where it should on the 'far end' of the button press. Ie, exactly where I ask it to.
Pluto? Planet or not, it's still a troublemaker, I mean, obviously! :)
I'll endeavour to drink more coffee (and wait for various solar spacial-relationships to change) in the future to prevent reporting transient oddness and report REAL bugs.
~Miz