* 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()); + public Dim interactiveJavaScriptDebugger() { // this can be too late, depending on when this method is invoked. Functions.DEBUG_YUI = true; + + return org.mozilla.javascript.tools.debugger.Main.mainEmbedded("Rhino debugger: "+getName()); } /** @@ -581,8 +596,18 @@ public abstract class HudsonTestCase extends TestCase { public HtmlPage submit(HtmlForm form, String name) throws Exception { for( HtmlElement e : form.getHtmlElementsByTagName("button")) { HtmlElement p = (HtmlElement)e.getParentNode().getParentNode(); - if(p.getAttribute("name").equals(name)) + if(p.getAttribute("name").equals(name)) { + // To make YUI event handling work, this combo seems to be necessary + // the click will trigger _onClick in buton-*.js, but it doesn't submit the form + // (a comment alluding to this behavior can be seen in submitForm method) + // so to complete it, submit the form later. + // + // Just doing form.submit() doesn't work either, because it doesn't do + // the preparation work needed to pass along the name of the button that + // triggered a submission (more concretely, m_oSubmitTrigger is not set.) + ((HtmlButton)e).click(); return (HtmlPage)form.submit((HtmlButton)e); + } } throw new AssertionError("No such submit button with the name "+name); } diff --git a/test/src/test/java/hudson/diagnosis/HudsonHomeDiskUsageMonitorTest.java b/test/src/test/java/hudson/diagnosis/HudsonHomeDiskUsageMonitorTest.java index f55ba90dd89cc435991cca0b181569927fc821b2..79a3fcd17ea5d4c4490d01501fac4e0564a3a909 100644 --- a/test/src/test/java/hudson/diagnosis/HudsonHomeDiskUsageMonitorTest.java +++ b/test/src/test/java/hudson/diagnosis/HudsonHomeDiskUsageMonitorTest.java @@ -4,6 +4,7 @@ import org.jvnet.hudson.test.HudsonTestCase; import org.xml.sax.SAXException; import com.gargoylesoftware.htmlunit.html.HtmlPage; import com.gargoylesoftware.htmlunit.html.HtmlForm; +import com.gargoylesoftware.htmlunit.ElementNotFoundException; import java.io.IOException; @@ -19,13 +20,15 @@ public class HudsonHomeDiskUsageMonitorTest extends HudsonTestCase { // clikcing yes should take us to somewhere submit(getForm(mon),"yes"); - // TODO: the test doesn't work today because the submit button doesn't send the name in the form. - // this appears to be a bug in HTMLUnit. -// // now dismiss -// submit(getForm(mon),"no"); -// -// // and make sure it's gone -// assertNull(getForm(mon)); + // now dismiss + submit(getForm(mon),"no"); + + // and make sure it's gone + try { + fail(getForm(mon)+" shouldn't be there"); + } catch (ElementNotFoundException e) { + // as expected + } } /** diff --git a/test/src/test/java/hudson/tasks/AntTest.java b/test/src/test/java/hudson/tasks/AntTest.java index cafc75fec220670928550f1018aa1bc4db658e87..9c29516769f27ce26e619fd4c6bc94a7e182b08c 100644 --- a/test/src/test/java/hudson/tasks/AntTest.java +++ b/test/src/test/java/hudson/tasks/AntTest.java @@ -23,18 +23,16 @@ */ package hudson.tasks; +import com.gargoylesoftware.htmlunit.html.HtmlButton; import com.gargoylesoftware.htmlunit.html.HtmlForm; import com.gargoylesoftware.htmlunit.html.HtmlPage; -import com.gargoylesoftware.htmlunit.html.HtmlButton; -import com.gargoylesoftware.htmlunit.html.HtmlElement; -import com.gargoylesoftware.htmlunit.html.HtmlInput; import hudson.model.FreeStyleProject; import hudson.tasks.Ant.AntInstallation; -import hudson.tasks.Ant.AntInstaller; import hudson.tasks.Ant.AntInstallation.DescriptorImpl; +import hudson.tasks.Ant.AntInstaller; +import hudson.tools.InstallSourceProperty; import hudson.tools.ToolProperty; import hudson.tools.ToolPropertyDescriptor; -import hudson.tools.InstallSourceProperty; import hudson.util.DescribableList; import org.jvnet.hudson.test.HudsonTestCase;