From 7a49604788d582e6aad856b0975cba16ed8b129f Mon Sep 17 00:00:00 2001 From: Ronald Brill Date: Thu, 8 Jun 2023 11:38:26 +0200 Subject: [PATCH] release 4.10.0 --- owasp-suppressions.xml | 1 + pom.xml | 4 +- .../selenium/htmlunit/HtmlUnitDriver.java | 3 +- .../selenium/htmlunit/HtmlUnitDriverTest.java | 117 +++++++++--------- 4 files changed, 64 insertions(+), 61 deletions(-) diff --git a/owasp-suppressions.xml b/owasp-suppressions.xml index 7e364b3b..663c1a8c 100644 --- a/owasp-suppressions.xml +++ b/owasp-suppressions.xml @@ -45,6 +45,7 @@ .*guava-31\.1-jre\.jar CVE-2020-8908 + CVE-2023-2976 diff --git a/pom.xml b/pom.xml index 7f0f39b7..c819e75b 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.seleniumhq.selenium htmlunit-driver - 4.9.1 + 4.10.0 htmlunit-driver WebDriver compatible driver for HtmlUnit headless browser @@ -18,7 +18,7 @@ 8 8 - 4.9.1 + 4.10.0 2.70.0 9.4.50.v20221201 diff --git a/src/main/java/org/openqa/selenium/htmlunit/HtmlUnitDriver.java b/src/main/java/org/openqa/selenium/htmlunit/HtmlUnitDriver.java index 119318af..96f82ca4 100644 --- a/src/main/java/org/openqa/selenium/htmlunit/HtmlUnitDriver.java +++ b/src/main/java/org/openqa/selenium/htmlunit/HtmlUnitDriver.java @@ -609,8 +609,9 @@ public Capabilities getCapabilities() { final DesiredCapabilities capabilities = new DesiredCapabilities(HTMLUNIT.browserName(), "", Platform.ANY); capabilities.setPlatform(Platform.getCurrent()); - capabilities.setJavascriptEnabled(isJavascriptEnabled()); capabilities.setVersion(Version.getProductVersion()); + + capabilities.setCapability(HtmlUnitDriver.JAVASCRIPT_ENABLED, isJavascriptEnabled()); return capabilities; } diff --git a/src/test/java/org/openqa/selenium/htmlunit/HtmlUnitDriverTest.java b/src/test/java/org/openqa/selenium/htmlunit/HtmlUnitDriverTest.java index a6b939a5..a3f629de 100644 --- a/src/test/java/org/openqa/selenium/htmlunit/HtmlUnitDriverTest.java +++ b/src/test/java/org/openqa/selenium/htmlunit/HtmlUnitDriverTest.java @@ -243,48 +243,6 @@ protected WebClient modifyWebClient(final WebClient client) { }; } - @Test - public void ctorWebClientCapabilitiesJsTrue() { - final DesiredCapabilities capabilities = - new DesiredCapabilities(Browser.HTMLUNIT.browserName(), "", Platform.ANY); - capabilities.setCapability(CapabilityType.SUPPORTS_JAVASCRIPT, true); - - new HtmlUnitDriver(capabilities) { - @Override - protected WebClient modifyWebClient(final WebClient client) { - assertEquals(BrowserVersion.getDefault(), client.getBrowserVersion()); - - assertTrue("client.getOptions().isJavaScriptEnabled() is false", - client.getOptions().isJavaScriptEnabled()); - assertTrue("client.isJavaScriptEnabled() is false", client.isJavaScriptEnabled()); - assertTrue("client.isJavaScriptEngineEnabled() is false", client.isJavaScriptEngineEnabled()); - - return client; - } - }; - } - - @Test - public void ctorWebClientCapabilitiesJsFalse() { - final DesiredCapabilities capabilities = - new DesiredCapabilities(Browser.HTMLUNIT.browserName(), "", Platform.ANY); - capabilities.setCapability(CapabilityType.SUPPORTS_JAVASCRIPT, false); - - new HtmlUnitDriver(capabilities) { - @Override - protected WebClient modifyWebClient(final WebClient client) { - assertEquals(BrowserVersion.getDefault(), client.getBrowserVersion()); - - assertFalse("client.getOptions().isJavaScriptEnabled() is true", - client.getOptions().isJavaScriptEnabled()); - assertFalse("client.isJavaScriptEnabled() is true", client.isJavaScriptEnabled()); - assertTrue("client.isJavaScriptEngineEnabled() is false", client.isJavaScriptEngineEnabled()); - - return client; - } - }; - } - @Test public void ctorWebClientCapabilitiesVersionString() { DesiredCapabilities capabilities = new DesiredCapabilities(Browser.HTMLUNIT.browserName(), "firefox", @@ -450,10 +408,56 @@ protected WebClient modifyWebClient(final WebClient client) { } @Test - public void ctorWebClientCapabilitiesJsEnabledTrue() { + public void ctorWebClientJsEnabledTrue() { final DesiredCapabilities capabilities = new DesiredCapabilities(Browser.HTMLUNIT.browserName(), "", Platform.ANY); - capabilities.setJavascriptEnabled(true); + + final HtmlUnitDriver driver = new HtmlUnitDriver(capabilities); + assertTrue("client.getOptions().isJavaScriptEnabled() is false", driver.isJavascriptEnabled()); + assertTrue("client.getOptions().isJavaScriptEnabled() is true", + driver.getWebClient().getOptions().isJavaScriptEnabled()); + assertTrue("client.isJavaScriptEnabled() is true", driver.getWebClient().isJavaScriptEnabled()); + assertTrue("client.isJavaScriptEngineEnabled() is false", driver.getWebClient().isJavaScriptEngineEnabled()); + + driver.setJavascriptEnabled(false); + assertFalse("client.getOptions().isJavaScriptEnabled() is true", driver.isJavascriptEnabled()); + assertFalse("client.getOptions().isJavaScriptEnabled() is true", + driver.getWebClient().getOptions().isJavaScriptEnabled()); + assertFalse("client.isJavaScriptEnabled() is true", driver.getWebClient().isJavaScriptEnabled()); + assertTrue("client.isJavaScriptEngineEnabled() is false", driver.getWebClient().isJavaScriptEngineEnabled()); + } + + @Test + public void ctorWebClientJsEnabledFalse() { + final DesiredCapabilities capabilities = + new DesiredCapabilities(Browser.HTMLUNIT.browserName(), "", Platform.ANY); + + final HtmlUnitDriver driver = new HtmlUnitDriver(capabilities) { + @Override + protected WebClient modifyWebClient(final WebClient client) { + assertEquals(BrowserVersion.getDefault(), client.getBrowserVersion()); + + client.getOptions().setJavaScriptEnabled(false); + + return client; + } + }; + + assertFalse("client.getOptions().isJavaScriptEnabled() is true", driver.isJavascriptEnabled()); + assertFalse("client.getOptions().isJavaScriptEnabled() is true", + driver.getWebClient().getOptions().isJavaScriptEnabled()); + assertFalse("client.isJavaScriptEnabled() is true", driver.getWebClient().isJavaScriptEnabled()); + assertTrue("client.isJavaScriptEngineEnabled() is false", driver.getWebClient().isJavaScriptEngineEnabled()); + } + + @Test + public void ctorWebClientCapabilitiesProxy() { + final Proxy proxy = new Proxy(); + proxy.setHttpProxy("hostname:1234"); + + final DesiredCapabilities capabilities = + new DesiredCapabilities(Browser.HTMLUNIT.browserName(), "", Platform.ANY); + capabilities.setCapability(CapabilityType.PROXY, proxy); new HtmlUnitDriver(capabilities) { @Override @@ -465,25 +469,28 @@ protected WebClient modifyWebClient(final WebClient client) { assertTrue("client.isJavaScriptEnabled() is false", client.isJavaScriptEnabled()); assertTrue("client.isJavaScriptEngineEnabled() is false", client.isJavaScriptEngineEnabled()); + assertEquals("hostname", client.getOptions().getProxyConfig().getProxyHost()); + assertEquals(1234, client.getOptions().getProxyConfig().getProxyPort()); + return client; } }; } @Test - public void ctorWebClientCapabilitiesJsEnabledFalse() { + public void ctorWebClientCapabilitiesJsTrue() { final DesiredCapabilities capabilities = new DesiredCapabilities(Browser.HTMLUNIT.browserName(), "", Platform.ANY); - capabilities.setJavascriptEnabled(false); + capabilities.setCapability(HtmlUnitDriver.JAVASCRIPT_ENABLED, true); new HtmlUnitDriver(capabilities) { @Override protected WebClient modifyWebClient(final WebClient client) { assertEquals(BrowserVersion.getDefault(), client.getBrowserVersion()); - assertFalse("client.getOptions().isJavaScriptEnabled() is true", + assertTrue("client.getOptions().isJavaScriptEnabled() is false", client.getOptions().isJavaScriptEnabled()); - assertFalse("client.isJavaScriptEnabled() is true", client.isJavaScriptEnabled()); + assertTrue("client.isJavaScriptEnabled() is false", client.isJavaScriptEnabled()); assertTrue("client.isJavaScriptEngineEnabled() is false", client.isJavaScriptEngineEnabled()); return client; @@ -492,27 +499,21 @@ protected WebClient modifyWebClient(final WebClient client) { } @Test - public void ctorWebClientCapabilitiesProxy() { - final Proxy proxy = new Proxy(); - proxy.setHttpProxy("hostname:1234"); - + public void ctorWebClientCapabilitiesJsFalse() { final DesiredCapabilities capabilities = new DesiredCapabilities(Browser.HTMLUNIT.browserName(), "", Platform.ANY); - capabilities.setCapability(CapabilityType.PROXY, proxy); + capabilities.setCapability(HtmlUnitDriver.JAVASCRIPT_ENABLED, false); new HtmlUnitDriver(capabilities) { @Override protected WebClient modifyWebClient(final WebClient client) { assertEquals(BrowserVersion.getDefault(), client.getBrowserVersion()); - assertTrue("client.getOptions().isJavaScriptEnabled() is false", + assertFalse("client.getOptions().isJavaScriptEnabled() is true", client.getOptions().isJavaScriptEnabled()); - assertTrue("client.isJavaScriptEnabled() is false", client.isJavaScriptEnabled()); + assertFalse("client.isJavaScriptEnabled() is true", client.isJavaScriptEnabled()); assertTrue("client.isJavaScriptEngineEnabled() is false", client.isJavaScriptEngineEnabled()); - assertEquals("hostname", client.getOptions().getProxyConfig().getProxyHost()); - assertEquals(1234, client.getOptions().getProxyConfig().getProxyPort()); - return client; } };