diff --git a/src/test/java/org/htmlunit/html/HtmlElementTest.java b/src/test/java/org/htmlunit/html/HtmlElementTest.java index 4159d7e2e7f..0c783da85cd 100644 --- a/src/test/java/org/htmlunit/html/HtmlElementTest.java +++ b/src/test/java/org/htmlunit/html/HtmlElementTest.java @@ -20,6 +20,7 @@ import java.util.List; import org.htmlunit.SimpleWebTestCase; +import org.htmlunit.WebClient; import org.htmlunit.junit.BrowserRunner; import org.htmlunit.junit.BrowserRunner.Alerts; import org.junit.Test; @@ -1185,18 +1186,42 @@ public void asXml() throws Exception { * @throws Exception if the test fails */ @Test - @Alerts("false") - public void isDisplayed() throws Exception { + @Alerts({"true", "false", "false"}) + public void isDisplayedJsDisabled() throws Exception { final String html = "\n" + "\n" + "\n" + "
hello
\n" + "\n" + + "\n" + ""; getWebClient().getOptions().setJavaScriptEnabled(false); final HtmlPage page = loadPage(html); - assertTrue(page.getElementById("d1").isDisplayed()); - assertEquals(Boolean.parseBoolean(getExpectedAlerts()[0]), page.getElementById("d2").isDisplayed()); + assertEquals(Boolean.parseBoolean(getExpectedAlerts()[0]), page.getElementById("d1").isDisplayed()); + assertEquals(Boolean.parseBoolean(getExpectedAlerts()[1]), page.getElementById("d2").isDisplayed()); + assertEquals(Boolean.parseBoolean(getExpectedAlerts()[2]), page.getElementById("d3").isDisplayed()); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({"true", "false", "false"}) + public void isDisplayedJsEngineDisabled() throws Exception { + final String html = "\n" + + "\n" + + "\n" + + "
hello
\n" + + "\n" + + "\n" + + ""; + + try (WebClient webClient = new WebClient(getBrowserVersion(), false, null, -1)) { + final HtmlPage page = loadPage(html); + assertEquals(Boolean.parseBoolean(getExpectedAlerts()[0]), page.getElementById("d1").isDisplayed()); + assertEquals(Boolean.parseBoolean(getExpectedAlerts()[1]), page.getElementById("d2").isDisplayed()); + assertEquals(Boolean.parseBoolean(getExpectedAlerts()[2]), page.getElementById("d3").isDisplayed()); + } } }