HtmlUnit / htmlunit

HtmlUnit is a "GUI-Less browser for Java programs".
https://www.htmlunit.org
Apache License 2.0
870 stars 172 forks source link

HtmlUnit fails to parse script faces.js from MyFaces 4.0.2 #732

Open tandraschko opened 7 months ago

tandraschko commented 7 months ago

I get following exception in my integration test environment:

org.htmlunit.corejs.javascript.EvaluatorException: missing formal parameter (http://..../jakarta.faces.resource/faces.js.xhtml?ln=jakarta.faces#2)
        at org.htmlunit.javascript.HtmlUnitContextFactory$HtmlUnitErrorReporter.error(HtmlUnitContextFactory.java:431)

Line Number: 2 Column Number: 864

The JS can be found here: https://repo1.maven.org/maven2/org/apache/myfaces/core/myfaces-api/4.0.2/myfaces-api-4.0.2.jar

extract it and you can find it here: \META-INF\resources\jakarta.faces\faces.js

the exception is there since v2.13 and still fails with 3.10.0

rbri commented 7 months ago

@tandraschko, thanks for the bug report. HtmlUnit (and Wetator) has a log history testing JSF/Myfaces/Richfaces app. Therefore i spend some time looking at this.

The problem here is (again) som js feature support in rhino. The faces.js implementation uses rest parameters (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters) e.g.

e.chain = function(e, t, ...n)

that are currently not supported by Rhino.

What to do?

Option 1: wait until Rhino moves forward here - in the past i have provided many updates to rhino but its getting harder because of the backward compatibility that rhino likes to manage

Option 2: I have a plan to replace the js engine by something more modern, but this is a huge effort and might not be available during the next months (you can of course ask your boss to sponsor my work (https://github.com/sponsors/rbri) to make this a bit faster). Please be a bit patient regarding this, i plan to announce the plan and more details soon

Option 3: Patch the faces.js file 'on the fly' and replace the problematic statements with some rhino compatible stuff. I did this already for Htmx and it is possible for this also. At least if you like to test bigger MyFaces projects (or many) this might be a good solution.

Please give me a sign, if you like to go with option 3 for some time and i will try to help you with this.

rbri commented 7 months ago

Looks like i have rhino support for function rest parameters ready... will release something during the next days

tandraschko commented 7 months ago

that sounds great! Thank you! :)

NOTE: i'm just working on another OS project, Apache DeltaSpike, and i'm trying to fix our integration tests for new JakartaEE 10

tandraschko commented 6 months ago

is there any expected release date yet? :)

rbri commented 6 months ago

@tandraschko sorry but the fix i made for rhino (https://github.com/mozilla/rhino/pull/1451) seems to be only the first required one. The js file not only uses rest paramters but also spread syntax support.

At the moment i like to focus on https://github.com/HtmlUnit/htmlunit/issues/755 - this will solve the problem at all. But there is no release date set - hope to know more in one week or so...