From e2c163dcf5fde2ce45ab87d40a49f0851c7fbd6e Mon Sep 17 00:00:00 2001 From: kohsuke Date: Thu, 13 Aug 2009 02:03:36 +0000 Subject: [PATCH] added support for interactive JavaScript debugger git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@20647 71c3de6d-444a-0410-be80-ed276b4c234a --- test/pom.xml | 9 +++++++-- .../org/jvnet/hudson/test/HudsonTestCase.java | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/test/pom.xml b/test/pom.xml index d52e701e4d..b3319fac84 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -129,14 +129,19 @@ THE SOFTWARE. xml-apis - + org.jvnet.hudson htmlunit-core-js 2.2-hudson-2 - + + + org.jvnet.hudson + embedded-rhino-debugger + 1.0 + org.jvnet.hudson diff --git a/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java b/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java index 5e467ac483..5690253cc2 100644 --- a/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java +++ b/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java @@ -120,6 +120,7 @@ import org.mortbay.jetty.webapp.WebAppContext; import org.mortbay.jetty.webapp.WebXmlConfiguration; import org.mozilla.javascript.Context; import org.mozilla.javascript.ContextFactory; +import org.mozilla.javascript.tools.shell.JSConsole; import org.w3c.css.sac.CSSException; import org.w3c.css.sac.CSSParseException; import org.w3c.css.sac.ErrorHandler; @@ -480,6 +481,22 @@ public abstract class HudsonTestCase extends TestCase { new BufferedReader(new InputStreamReader(System.in)).readLine(); } + /** + * Starts an interactive JavaScript debugger, and break at the next JavaScript execution. + * + *

+ * This is useful during debugging a test so that you can step execute and inspect state of JavaScript. + * This will launch a Swing GUI, and the method returns immediately. + * + *

+ * Note that installing a debugger appears to make an execution of JavaScript substantially slower. + */ + public void interactiveJavaScriptDebugger() { + org.mozilla.javascript.tools.debugger.Main.mainEmbedded("Rhino debugger: "+getName()); + // this can be too late, depending on when this method is invoked. + Functions.DEBUG_YUI = true; + } + /** * Returns the last item in the list. */