Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How much longer for HtmlUnit? #569

Open
basil opened this issue Apr 10, 2023 · 1 comment
Open

How much longer for HtmlUnit? #569

basil opened this issue Apr 10, 2023 · 1 comment

Comments

@basil
Copy link
Member

basil commented Apr 10, 2023

HtmlUnit is based on the venerable Rhino JavaScript engine, which does not support the optional chaining (?.) operator, spread (...) syntax, or rest parameter syntax (among other newer ECMAScript language features). The Web platform is evolving at a fast pace, and Rhino is increasingly falling behind mainstream browsers. It takes an exceptionally committed group of developers to keep up (cf. LibJS).

The status quo is that we simply avoid using these newer ECMAScript language features in Jenkins core in order to support JTH/HtmlUnit/Rhino in core and plugin integration tests (as opposed to ATH/Selenium). Plugins that use e.g. Bootstrap 5 (which uses the newer rest parameter syntax) cannot be tested with JTH/HtmlUnit/Rhino and must instead be tested with ATH/Selenium. This seems unsustainable.

The last version of ECMAScript that is fully supported by Rhino is 5.1. We could transpile our code to ECMAScript 5.1 to avoid any problems with JTH/HtmlUnit/Rhino, but this seems like an undesirable short-term measure that would negatively impact performance in the production use case for mainstream browsers.

Another solution would be to teach Can I use/Browserslist/Babel which features are (or are not) supported by HtmlUnit/Rhino. Then we could transpile our code to something that would run in JTH/HtmlUnit/Rhino with minimal modifications. This would be a modest amount of effort and would require upstream changes, but it seems relatively achievable in the medium term.

Yet another solution would be to rewrite usages of JTH/HtmlUnit/Rhino in core and plugin integration tests in favor of a mainstream browser using ATH/Selenium (keeping them in their existing repositories or moving them to jenkinsci/acceptance-test-harness being a related but somewhat orthogonal question). Recent versions of Selenium can automatically download the Selenium drivers needed for various browsers, and our Docker images used for CI jobs already have e.g. Chrome installed. For local builds, developers could be instructed to install a browser, or we could skip those tests when a browser is not available (relying on the CI builds instead).

The most challenging aspect of the above is that there are hundreds (if not thousands) of existing core and plugin integration tests, and porting them all from JTH/HtmlUnit/Rhino to ATH/Selenium seems prohibitively impractical. Perhaps the existing JenkinsRule.WebClient interface in JTH could be rewritten in terms of Selenium rather than in terms of HtmlUnit/Rhino? This might break binary (but not source?) compatibility with JTH, making the migration easier (though still not trivial). The interface could then be deprecated in favor of native ATH equivalents, with usages in core and plugin integration tests being gradually migrated to ATH over time.

What I described in the last paragraph seems fairly challenging at first glance. I have no idea whether this is feasible or not, but I think it is worth exploring. Let me know if you are interested in contributing code to this effort.

@basil
Copy link
Member Author

basil commented Apr 10, 2023

(Developer list thread)

MarkEWaite added a commit to MarkEWaite/pipeline-groovy-lib-plugin that referenced this issue Apr 14, 2023
jenkinsci/bom#1959 (comment)
explains that the modernization of hetero-list.js has inserted JavaScript
that the HTMLUnit JavaScript engine does not understand.  That causes
the test to fail with an HTTP 500 error when the specific assertion
is executed.

Do not execute the failing assertion on Jenkins 2.400 and
later.  Excluding the failing assertion is a simple short-term
workaround for the larger problem that is described by @basil in
jenkinsci/jenkins-test-harness#569 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant