From b90dce45f580420b168e6cdb84fc4f876d72b2b5 Mon Sep 17 00:00:00 2001 From: Ronald Brill Date: Tue, 10 Oct 2023 19:03:52 +0200 Subject: [PATCH] a bit more documentation about the two ways to disable the JavaScript engine added --- src/changes/changes.xml | 3 +++ src/main/java/org/htmlunit/WebClient.java | 1 + src/site/xdoc/index.xml | 9 ++++----- src/site/xdoc/javascript-howto.xml | 6 ++++++ 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 7f907a4a55c..ce4a980c8fa 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -8,6 +8,9 @@ + + A bit more documentation about the two ways to disable the JavaScript engine added. + Remove proxy polyfill from the documentation because it is no longer available (Proxy/Reflect support was added to core-js). diff --git a/src/main/java/org/htmlunit/WebClient.java b/src/main/java/org/htmlunit/WebClient.java index 01772525481..3f8a0578904 100644 --- a/src/main/java/org/htmlunit/WebClient.java +++ b/src/main/java/org/htmlunit/WebClient.java @@ -2867,6 +2867,7 @@ public void addCookie(final String cookieString, final URL pageUrl, final Object * To disable the javascript support (eg. temporary) * you have to use the {@link WebClientOptions#setJavaScriptEnabled(boolean)} setter. * @see #isJavaScriptEngineEnabled() + * @see WebClientOptions#isJavaScriptEnabled() * @return true if the javaScript engine and the javaScript support is enabled. */ public boolean isJavaScriptEnabled() { diff --git a/src/site/xdoc/index.xml b/src/site/xdoc/index.xml index 77e2f46653c..35a4ce4a4ba 100644 --- a/src/site/xdoc/index.xml +++ b/src/site/xdoc/index.xml @@ -231,15 +231,14 @@
  • YUI 2.3.0: Good support (see unit test here)
  • -

    - Disabling JavaScript support: to disable JavaScript processing for one WebClient, - call webClient.getOptions().setJavaScriptEnabled(false). -

    JavaScript code is executed just like in normal browsers when the page loads or when an handler is triggered. Additionally HtmlUnit provides the ability to inject code into an existing page via - HtmlPage.executeJavascript(String yourJsCode). + HtmlPage.executeJavascript(String yourJsCode).

    + Refer to the Use JavaScript for more details.

    + +

    Refer to the changes document for details on what is being added.

    diff --git a/src/site/xdoc/javascript-howto.xml b/src/site/xdoc/javascript-howto.xml index df6d373c1f6..6f334e4c76a 100644 --- a/src/site/xdoc/javascript-howto.xml +++ b/src/site/xdoc/javascript-howto.xml @@ -79,6 +79,12 @@ webClient.getOptions.setJavaScriptEnabled(true); ]]> + +

    + If you like to check the state of the JavaScript support from your code it is recommended to use + WebClient#isJavaScriptEnabled() + because this checks both ways of disabling Javascript. +