Skip to content

Commit

Permalink
a bit more documentation about the two ways to disable the JavaScript…
Browse files Browse the repository at this point in the history
… engine added
  • Loading branch information
rbri committed Oct 10, 2023
1 parent 98d4125 commit b90dce4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

<body>
<release version="3.7.0" date="October xx, 2023" description="Firefox 118, Bugfixes">
<action type="update" dev="rbri">
A bit more documentation about the two ways to disable the JavaScript engine added.
</action>
<action type="fix" dev="rbri">
Remove proxy polyfill from the documentation because it is no longer available
(Proxy/Reflect support was added to core-js).
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/htmlunit/WebClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
9 changes: 4 additions & 5 deletions src/site/xdoc/index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,14 @@
<li>YUI 2.3.0: Good support (see unit test <a href="https://github.com/HtmlUnit/htmlunit/blob/master/src/test/java/org/htmlunit/libraries/YuiTest.java">here</a>)</li>
</ul>
</p>
<p>
Disabling JavaScript support: to disable JavaScript processing for one WebClient,
call <tt>webClient.getOptions().setJavaScriptEnabled(false)</tt>.
</p>
<p>
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).<br></br>
Refer to the <a href="javascript-howto.html">Use JavaScript</a> for more details.
</p>


<p>
Refer to the <a href="changes-report.html">changes document</a> for details on what is being added.
</p>
Expand Down
6 changes: 6 additions & 0 deletions src/site/xdoc/javascript-howto.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@
webClient.getOptions.setJavaScriptEnabled(true);
]]></source>
</subsection>

<p>
If you like to check the state of the JavaScript support from your code it is recommended to use
<a href="apidocs/org/htmlunit/WebClient.html#isJavaScriptEnabled--">WebClient#isJavaScriptEnabled()</a>
because this checks both ways of disabling Javascript.
</p>
</section>

<section name="Example: using Document.write()">
Expand Down

0 comments on commit b90dce4

Please sign in to comment.