Skip to content

Test with BootStrap meet JavaScript Error #1059

Open

Description

@kentyeh

HtmlTestRunner.zip

#Run HtmlUnit
mvn clean package
<!DOCTYPE html>
<html>
    <head>
        <script src="/webjars/jquery/3.7.1/dist/jquery.min.js"></script>
        <script src="/webjars/bootstrap/5.3.8/js/bootstrap.bundle.min.js"></script>
   </head>
<body>Hello World</body>
</html>

Runtime org.htmlunit.javascript.TimeoutError: Javascript execution takes too long (allowed: 100000, already elapsed: 1763363535177) happens.

If I reverse the order of JS

<!DOCTYPE html>
<html>
    <head>
        <script src="/webjars/bootstrap/5.3.8/js/bootstrap.bundle.js"></script>
        <script src="/webjars/jquery/3.7.1/dist/jquery.min.js"></script>
   </head>
<body>Hello World</body>
</html>

Script syntax error (http://localhost:8080/webjars/bootstrap/5.3.8/js/bootstrap.bundle.js#253)
raised

Activity

  1. rbri commented on Nov 17, 2025

    @rbri
    Member

    Hi @kentyeh,

    thanks for giving HtmlUnit at try.
    The 'Javascript execution takes too long' is a stupid bug a made in version 4.18.0 - you can use 4.17.0 or the latest snapshot build of 4.19.0 instead.
    Another option is simply remove the line webClient.setJavaScriptTimeout(10_0000); from your code.

    Regarding the Script syntax error i have to check. This is usually based of some missing feature in rhino. But Rhino moves fast these days... will have a look and come back to you later.

  2. kentyeh commented on Nov 18, 2025

    @kentyeh
    Author

    My test was failing due to an issue with the webClient.setJavaScriptTimeout method. It's working now, thank you for your help!

  3. rbri commented on Nov 18, 2025

    @rbri
    Member

    @kentyeh great and thanks for the feedback. Will let this open for some time to remind me of adding some unit tests for bootstrap

  4. rbri commented on Dec 23, 2025

    @rbri
    Member

    Have added a simple test for loading bootstrap.bundle.js. This fails because of some missing spread operator suppot. There is already a PR in rhino for this. Hopefully i can merge this soon.

  5. kentyeh commented on Jan 2, 2026

    @kentyeh
    Author

    I'm running another Bootstrap test.
    Everything works as expected when running via

    mvn jetty:run

    However, while index.jsp loads correctly, index2.jsp fails.
    Is this due to the same root cause as before, or is it a previously undiscovered bug?"

    HtmlRunner2.zip

  6. hantsy commented on Mar 20, 2026

    @hantsy

    I got a similar issue when upgrading Bootstrap from v4 to v5.

    My project is a Jakarta EE Faces project that uses Arquillian Drone to test web pages. I configured the Arquillian Drone to use Selenium HtmlUnit as the background webdriver.

    https://github.com/hantsy/jakartaee-faces-sample/blob/master/src/test/java/com/example/it/HomeScreenTest.java

    I filed an issue on SeleniumHQ GitHub issues before, SeleniumHQ/selenium#17150

  7. rbri commented on Mar 21, 2026

    @rbri
    Member

    Yes this is still a bug with HtmlUnit. We did many improvements over the last months in the js support area. The problem mentioned here is fixed (the ... operator in parameters) but there are still more. In this case it is the missing class support. There is some hope to have this during the next months but it is in really early stage. You can monitor this issue, will report here if some solution is available.

    Outside of this, you can try to use something like babel to transpile the js file to a rhino compatible version and then use a ScriptPreProcessor to replace the file on the fly.
    see https://www.htmlunit.org/faq.html#HowToModifyJavascriptCode and https://github.com/HtmlUnit/htmlunit/blob/master/src/main/java/org/htmlunit/javascript/preprocessor/HtmxTwoZeroSevenScriptPreProcessor.java for some more info

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions