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

HtmlUnit failing on invalid javascript #64

Closed
skyhirider opened this issue Jul 31, 2019 · 11 comments
Closed

HtmlUnit failing on invalid javascript #64

skyhirider opened this issue Jul 31, 2019 · 11 comments

Comments

@skyhirider
Copy link

Opened a question at StackOverflow, opening issue here as per your suggestion.

I need to load the Discord login page but am failing on javascript exceptions.

Running Java 11 on Eclipse 2019-06 with HtmlUnit 2.35

My java code:

webClient = new WebClient();
webClient.getOptions().setDownloadImages(false);
webClient.getOptions().setCssEnabled(false);
webClient.getOptions().setJavaScriptEnabled(true);
webClient.getOptions().setHistorySizeLimit(5);
webClient.getOptions().setMaxInMemory(524288000);
webClient.getOptions().setThrowExceptionOnScriptError(false);
webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);

webClient.getPage("https://discordapp.com/login");

The full log:

Jul 30, 2019 3:30:39 PM com.gargoylesoftware.htmlunit.html.HtmlLink onAllChildrenAddedToPage
WARNING: Link type 'chrome-webstore-item' not supported.
Jul 30, 2019 3:30:39 PM com.gargoylesoftware.htmlunit.html.HtmlLink onAllChildrenAddedToPage
WARNING: Link type 'stylesheet' not supported.
Jul 30, 2019 3:30:39 PM com.gargoylesoftware.htmlunit.html.HtmlLink onAllChildrenAddedToPage
WARNING: Link type 'icon' not supported.
Jul 30, 2019 3:30:42 PM com.gargoylesoftware.htmlunit.javascript.DefaultJavaScriptErrorListener scriptException
SEVERE: Error during JavaScript execution
======= EXCEPTION START ========
EcmaError: lineNumber=[49] column=[0] lineSource=[<no source>] name=[TypeError] sourceName=[https://discordapp.com/assets/0765c293b8e5eac16193.js] message=[TypeError: Cannot find function setPrototypeOf in object function Object() { [native code] }. (https://discordapp.com/assets/0765c293b8e5eac16193.js#49)]
com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot find function setPrototypeOf in object function Object() { [native code] }. (https://discordapp.com/assets/0765c293b8e5eac16193.js#49)
	at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:885)
	at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:617)
	at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:534)
	at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.callSecured(HtmlUnitContextFactory.java:336)
	at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:765)
	at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:741)
	at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:104)
	at com.gargoylesoftware.htmlunit.html.HtmlPage.loadExternalJavaScriptFile(HtmlPage.java:997)
	at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded(HtmlScript.java:373)
	at com.gargoylesoftware.htmlunit.html.HtmlScript$2.execute(HtmlScript.java:247)
	at com.gargoylesoftware.htmlunit.html.HtmlScript.onAllChildrenAddedToPage(HtmlScript.java:268)
	at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:798)
	at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
	at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:754)
	at net.sourceforge.htmlunit.cyberneko.HTMLTagBalancer.callEndElement(HTMLTagBalancer.java:1175)
	at net.sourceforge.htmlunit.cyberneko.HTMLTagBalancer.endElement(HTMLTagBalancer.java:1115)
	at net.sourceforge.htmlunit.cyberneko.filters.DefaultFilter.endElement(DefaultFilter.java:219)
	at net.sourceforge.htmlunit.cyberneko.filters.NamespaceBinder.endElement(NamespaceBinder.java:303)
	at net.sourceforge.htmlunit.cyberneko.HTMLScanner$ContentScanner.scanEndElement(HTMLScanner.java:3126)
	at net.sourceforge.htmlunit.cyberneko.HTMLScanner$ContentScanner.scan(HTMLScanner.java:2075)
	at net.sourceforge.htmlunit.cyberneko.HTMLScanner.scanDocument(HTMLScanner.java:922)
	at net.sourceforge.htmlunit.cyberneko.HTMLConfiguration.parse(HTMLConfiguration.java:438)
	at net.sourceforge.htmlunit.cyberneko.HTMLConfiguration.parse(HTMLConfiguration.java:389)
	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
	at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.parse(HTMLParser.java:997)
	at com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:252)
	at com.gargoylesoftware.htmlunit.html.HTMLParser.parseHtml(HTMLParser.java:196)
	at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:268)
	at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:159)
	at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:531)
	at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:398)
	at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:315)
	at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:466)
	at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:448)
	at discordBot.DiscordWatcher.homePage(DiscordWatcher.java:33)
	at discordBot.MainForDiscordWatcher.main(MainForDiscordWatcher.java:8)
Caused by: net.sourceforge.htmlunit.corejs.javascript.EcmaError: TypeError: Cannot find function setPrototypeOf in object function Object() { [native code] }. (https://discordapp.com/assets/0765c293b8e5eac16193.js#49)
	at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:4334)
	at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:4312)
	at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError(ScriptRuntime.java:4345)
	at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:4364)
	at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:4440)
	at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getPropFunctionAndThisHelper(ScriptRuntime.java:2612)
	at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2594)
	at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1520)
	at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:1010)
	at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:111)
	at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:424)
	at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:322)
	at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3628)
	at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.exec(InterpretedFunction.java:123)
	at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$2.doRun(JavaScriptEngine.java:756)
	at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:870)
	... 35 more
Enclosed exception: 
net.sourceforge.htmlunit.corejs.javascript.EcmaError: TypeError: Cannot find function setPrototypeOf in object function Object() { [native code] }. (https://discordapp.com/assets/0765c293b8e5eac16193.js#49)
	at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:4334)
	at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:4312)
	at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError(ScriptRuntime.java:4345)
	at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:4364)
	at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:4440)
	at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getPropFunctionAndThisHelper(ScriptRuntime.java:2612)
	at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2594)
	at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1520)
	at script(https://discordapp.com/assets/0765c293b8e5eac16193.js:49)
	at script.r(https://discordapp.com/assets/e4c71e4c5b1f4c2b4d17.js:1)
	at script(https://discordapp.com/assets/0765c293b8e5eac16193.js:49)
	at script(https://discordapp.com/assets/0765c293b8e5eac16193.js:49)
	at script.r(https://discordapp.com/assets/e4c71e4c5b1f4c2b4d17.js:1)
	at script(https://discordapp.com/assets/0765c293b8e5eac16193.js:1)
	at script.r(https://discordapp.com/assets/e4c71e4c5b1f4c2b4d17.js:1)
	at script(https://discordapp.com/assets/0765c293b8e5eac16193.js:45)
	at script(https://discordapp.com/assets/0765c293b8e5eac16193.js:45)
	at script.r(https://discordapp.com/assets/e4c71e4c5b1f4c2b4d17.js:1)
	at script(https://discordapp.com/assets/0765c293b8e5eac16193.js:9)
	at script(https://discordapp.com/assets/0765c293b8e5eac16193.js:9)
	at script.r(https://discordapp.com/assets/e4c71e4c5b1f4c2b4d17.js:1)
	at script(https://discordapp.com/assets/0765c293b8e5eac16193.js:20)
	at script.r(https://discordapp.com/assets/e4c71e4c5b1f4c2b4d17.js:1)
	at script(https://discordapp.com/assets/0765c293b8e5eac16193.js:49)
	at script.r(https://discordapp.com/assets/e4c71e4c5b1f4c2b4d17.js:1)
	at script(https://discordapp.com/assets/0765c293b8e5eac16193.js:45)
	at script.r(https://discordapp.com/assets/e4c71e4c5b1f4c2b4d17.js:1)
	at script(https://discordapp.com/assets/0765c293b8e5eac16193.js:49)
	at script.r(https://discordapp.com/assets/e4c71e4c5b1f4c2b4d17.js:1)
	at script(https://discordapp.com/assets/0765c293b8e5eac16193.js:49)
	at script.r(https://discordapp.com/assets/e4c71e4c5b1f4c2b4d17.js:1)
	at script.d(https://discordapp.com/assets/e4c71e4c5b1f4c2b4d17.js:1)
	at script.c(https://discordapp.com/assets/e4c71e4c5b1f4c2b4d17.js:1)
	at script(https://discordapp.com/assets/0765c293b8e5eac16193.js:1)
	at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:1010)
	at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:111)
	at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:424)
	at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:322)
	at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3628)
	at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.exec(InterpretedFunction.java:123)
	at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$2.doRun(JavaScriptEngine.java:756)
	at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:870)
	at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:617)
	at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:534)
	at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.callSecured(HtmlUnitContextFactory.java:336)
	at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:765)
	at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:741)
	at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:104)
	at com.gargoylesoftware.htmlunit.html.HtmlPage.loadExternalJavaScriptFile(HtmlPage.java:997)
	at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded(HtmlScript.java:373)
	at com.gargoylesoftware.htmlunit.html.HtmlScript$2.execute(HtmlScript.java:247)
	at com.gargoylesoftware.htmlunit.html.HtmlScript.onAllChildrenAddedToPage(HtmlScript.java:268)
	at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:798)
	at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
	at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:754)
	at net.sourceforge.htmlunit.cyberneko.HTMLTagBalancer.callEndElement(HTMLTagBalancer.java:1175)
	at net.sourceforge.htmlunit.cyberneko.HTMLTagBalancer.endElement(HTMLTagBalancer.java:1115)
	at net.sourceforge.htmlunit.cyberneko.filters.DefaultFilter.endElement(DefaultFilter.java:219)
	at net.sourceforge.htmlunit.cyberneko.filters.NamespaceBinder.endElement(NamespaceBinder.java:303)
	at net.sourceforge.htmlunit.cyberneko.HTMLScanner$ContentScanner.scanEndElement(HTMLScanner.java:3126)
	at net.sourceforge.htmlunit.cyberneko.HTMLScanner$ContentScanner.scan(HTMLScanner.java:2075)
	at net.sourceforge.htmlunit.cyberneko.HTMLScanner.scanDocument(HTMLScanner.java:922)
	at net.sourceforge.htmlunit.cyberneko.HTMLConfiguration.parse(HTMLConfiguration.java:438)
	at net.sourceforge.htmlunit.cyberneko.HTMLConfiguration.parse(HTMLConfiguration.java:389)
	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
	at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.parse(HTMLParser.java:997)
	at com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:252)
	at com.gargoylesoftware.htmlunit.html.HTMLParser.parseHtml(HTMLParser.java:196)
	at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:268)
	at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:159)
	at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:531)
	at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:398)
	at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:315)
	at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:466)
	at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:448)
	at discordBot.DiscordWatcher.homePage(DiscordWatcher.java:33)
	at discordBot.MainForDiscordWatcher.main(MainForDiscordWatcher.java:8)
======= EXCEPTION END ========
@rbri
Copy link
Member

rbri commented Jul 31, 2019

just made a pull request for rhino - mozilla/rhino#588

@skyhirider
Copy link
Author

just made a pull request for rhino - mozilla/rhino#588

Much appreciated, you work fast. How do you approach updates, will you bump up the minor version and release a bugfix after the pull is accepted in rhino or wait for a feature release?

@rbri
Copy link
Member

rbri commented Aug 1, 2019

HtmlUnit maintains a Rhino fork, if the pull request is in Rhino i usually sync the changes to core-js and make a new snapshot build available. And from time to time i make new HtmlUnit releases.
You can follow the development on twitter https://twitter.com/htmlunit

@rbri
Copy link
Member

rbri commented Aug 9, 2019

Have you tested with the latest snapshot?

@skyhirider
Copy link
Author

Not yet, have attempted to clone rhino and build locally but failed.

Could you share an already built package that I can add to my dependencies and replace the old one to test?

@rbri
Copy link
Member

rbri commented Aug 12, 2019

There is no need to clone. If you are using maven/gradle, you can use the latest snapshot build. If not use the latest build from the ci server.

@skyhirider
Copy link
Author

Which ci server do you mean?

Do not have much experience with Maven apart from downloading existing packages, and I can't see a snapshot build in https://repo.maven.apache.org/maven2/org/mozilla/rhino/

@rbri
Copy link
Member

rbri commented Aug 18, 2019

The ci server mentioned at the HtmlUnit homepage.... http://167.86.92.69/job/HtmlUnit/

If you like to download you can download the htmlunit-2.36.0-SNAPSHOT-bin.zip file, it contains all jar files HtmlUnit requires.

If you use maven simply update your pom with

<dependency>
    <groupId>net.sourceforge.htmlunit</groupId>
    <artifactId>htmlunit</artifactId>
    <version>2.36.0-SNAPSHOT</version>
</dependency>

@skyhirider
Copy link
Author

It seems to be throwing a different exception now.

I have omitted adding the full debug log as it has 8k lines but can provide it if needed.

00:51:01.310 [main] ERROR com.gargoylesoftware.htmlunit.javascript.DefaultJavaScriptErrorListener - Error during JavaScript execution
com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot read property "prototype" from undefined (https://discordapp.com/assets/0876651cceb7496629b6.js#92)
	at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:883)
	at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:617)
	at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:534)
	at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.callSecured(HtmlUnitContextFactory.java:336)
	at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:763)
	at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:739)
	at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:103)
	at com.gargoylesoftware.htmlunit.html.HtmlPage.loadExternalJavaScriptFile(HtmlPage.java:1002)
	at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded(HtmlScript.java:362)
	at com.gargoylesoftware.htmlunit.html.HtmlScript$2.execute(HtmlScript.java:236)
	at com.gargoylesoftware.htmlunit.html.HtmlScript.onAllChildrenAddedToPage(HtmlScript.java:257)
	at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:792)
	at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
	at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:748)
	at net.sourceforge.htmlunit.cyberneko.HTMLTagBalancer.callEndElement(HTMLTagBalancer.java:1175)
	at net.sourceforge.htmlunit.cyberneko.HTMLTagBalancer.endElement(HTMLTagBalancer.java:1115)
	at net.sourceforge.htmlunit.cyberneko.filters.DefaultFilter.endElement(DefaultFilter.java:219)
	at net.sourceforge.htmlunit.cyberneko.filters.NamespaceBinder.endElement(NamespaceBinder.java:303)
	at net.sourceforge.htmlunit.cyberneko.HTMLScanner$ContentScanner.scanEndElement(HTMLScanner.java:3138)
	at net.sourceforge.htmlunit.cyberneko.HTMLScanner$ContentScanner.scan(HTMLScanner.java:2075)
	at net.sourceforge.htmlunit.cyberneko.HTMLScanner.scanDocument(HTMLScanner.java:922)
	at net.sourceforge.htmlunit.cyberneko.HTMLConfiguration.parse(HTMLConfiguration.java:438)
	at net.sourceforge.htmlunit.cyberneko.HTMLConfiguration.parse(HTMLConfiguration.java:389)
	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
	at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.parse(HTMLParser.java:991)
	at com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:246)
	at com.gargoylesoftware.htmlunit.html.HTMLParser.parseHtml(HTMLParser.java:190)
	at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:269)
	at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:160)
	at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:535)
	at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:401)
	at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:318)
	at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:470)
	at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:451)
	at discordBot.DiscordWatcher.homePage(DiscordWatcher.java:34)
	at discordBot.MainForDiscordWatcher.main(MainForDiscordWatcher.java:8)
Caused by: net.sourceforge.htmlunit.corejs.javascript.EcmaError: TypeError: Cannot read property "prototype" from undefined (https://discordapp.com/assets/0876651cceb7496629b6.js#92)
	at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:4334)
	at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:4312)
	at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError(ScriptRuntime.java:4345)
	at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:4364)
	at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.undefReadError(ScriptRuntime.java:4377)
	at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getObjectProp(ScriptRuntime.java:1588)
	at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1438)
	at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:1010)
	at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:111)
	at net.sourceforge.htmlunit.corejs.javascript.NativeArray.iterativeMethod(NativeArray.java:1934)
	at net.sourceforge.htmlunit.corejs.javascript.NativeArray.execIdCall(NativeArray.java:367)
	at net.sourceforge.htmlunit.corejs.javascript.IdFunctionObject.call(IdFunctionObject.java:100)
	at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1675)
	at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:1010)
	at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:111)
	at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:424)
	at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:322)
	at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3628)
	at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.exec(InterpretedFunction.java:123)
	at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$2.doRun(JavaScriptEngine.java:754)
	at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:868)
	... 35 common frames omitted

@rbri
Copy link
Member

rbri commented Aug 21, 2019

This code works here without your last error. Looks like the error only occurs if you simulate chrome.

public static void main(String[] args) throws Exception {
    String webUrl = "https://discordapp.com/login";

    try (final WebClient webClient = new WebClient(BrowserVersion.FIREFOX_60)) {
        webClient.setCssErrorHandler(new SilentCssErrorHandler());

        final HtmlPage page = webClient.getPage(webUrl);
        webClient.waitForBackgroundJavaScript(5_000);

        System.out.println(" ---- main page start ---- ");
        System.out.println(page.asXml());
        System.out.println(" ---- main page end ---- ");
        System.out.println();
    }
}

@skyhirider
Copy link
Author

You are right, did not try different browser versions, had the constructor empty which defaults to best supported.

@rbri rbri closed this as completed Jul 13, 2020
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

2 participants