diff --git a/test/pom.xml b/test/pom.xml index d52e701e4d4ff5b67de6f5efd80c6390b18137f4..b3319fac844b7f7781396b1de20e5b6ab12556c9 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 5e467ac483d0e696bf1835439f06a441e5b33a99..5690253cc278be9a3aaf4307403978b00673c8fb 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. */