HtmlUnit / htmlunit

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

Cannot find function mergeHook in object [object] #631

Open basimons opened 1 year ago

basimons commented 1 year ago

Hi all,

We have html-unit to do some integration tests for our SAML flow. This all works great, thanks for that. Today I was updating some libraries, including htmlUnit. And I ran into this issue:

14:42:36.442 | ERROR | o.h.j.b.JavaScriptJobManagerImpl | Job run failed with unexpected RuntimeException: TypeError: Cannot find function mergeHook in object [object Object]. (https://ok12static.oktacdn.com/assets/js/sdk/okta-signin-widget/7.9.0/js/okta-sign-in.min.js#73)
org.htmlunit.ScriptException: TypeError: Cannot find function mergeHook in object [object Object]. (https://ok12static.oktacdn.com/assets/js/sdk/okta-signin-widget/7.9.0/js/okta-sign-in.min.js#73)
    at org.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:996)
    at org.htmlunit.corejs.javascript.Context.call(Context.java:590)
    at org.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:484)
    at org.htmlunit.javascript.HtmlUnitContextFactory.callSecured(HtmlUnitContextFactory.java:348)
    at org.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:923)
    at org.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:895)
    at org.htmlunit.html.HtmlPage.executeJavaScriptFunction(HtmlPage.java:2620)
    at org.htmlunit.html.HtmlPage.executeJavaScriptFunction(HtmlPage.java:2613)
    at org.htmlunit.javascript.background.JavaScriptFunctionJob.runJavaScript(JavaScriptFunctionJob.java:56)
    at org.htmlunit.javascript.background.JavaScriptExecutionJob.run(JavaScriptExecutionJob.java:100)
    at org.htmlunit.javascript.background.JavaScriptJobManagerImpl.runSingleJob(JavaScriptJobManagerImpl.java:433)
    at org.htmlunit.javascript.background.DefaultJavaScriptExecutor.run(DefaultJavaScriptExecutor.java:156)
    at java.base/java.lang.Thread.run(Thread.java:833)

The highest version to which I got it to work is 3.3.0. When going to 3.4.0 it starts to break.

I hope this is enough help to you, if not I'm happy to help out.

rbri commented 1 year ago

Hi @basimons, that sounds a bit strange, because usually the js support gets better with every version ;-) I can think about two reasons

Having a first look at https://ok12static.oktacdn.com/assets/js/sdk/okta-signin-widget/7.9.0/js/okta-sign-in.min.js shows some minified code - it will be really hard to understand the root cause of the problem. Maybe we can try together....

Is there any chance to simply reproduce the problem here? (If you like you can send me a private mail - see pom.xml)

basimons commented 1 year ago

Hi, I'm happy to set you up with a reproducible example.

The thing is I just don't know if it'd be super helpful. As the source that is throwing the error is not ours. We are using Okta, which is an identity provider in our SAML flow. This means that I don't have access to the original source and thus it'd be very hard to give you more than the minified version.

rbri commented 1 year ago

no prob you are not the first one having only the minified version :-D I only need a url and maybe a action that triggers the problem - then i can try to have a look.

basimons commented 1 year ago

Sure, I'll email you with some details on how to reproduce the problem. Then we can continue there if you need some more information. I rather not share the url here.

rbri commented 1 year ago

For the records, the version dependency is because the code contains a switch that checks for Reflect.construct like this

if ("undefined" == typeof Reflect || !Reflect.construct) return !1;

Reflect.construct method is available since 3.4.