Skip to content
New issue

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

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

Already on GitHub? # to your account

ScriptException (missing formal parameter) when trying to access a simple page #158

Open
LucasLaacerda opened this issue Apr 18, 2020 · 3 comments
Labels
js-engine Issues related to the js engine

Comments

@LucasLaacerda
Copy link

I need to load a page but it is returning failures

Code:
`import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.junit.Test;

import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlDivision;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.javascript.host.dom.NodeList;

public class WebCaptura {

 public static void main(String[] args){
	
	 //String url = "https://g1.globo.com/";
	
	
	try(final WebClient webClient = new WebClient()) {
         final HtmlPage page = webClient.getPage("https://g1.globo.com/");
         
	}catch (Exception e) {
		e.printStackTrace();
	}
	
}

}
`

log:

03:33:06.166 [main] ERROR com.gargoylesoftware.htmlunit.javascript.DefaultJavaScriptErrorListener - Error during JavaScript execution com.gargoylesoftware.htmlunit.ScriptException: missing formal parameter (script in https://g1.globo.com/ from (60, 66) to (77, 981)#60) 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.compile(JavaScriptEngine.java:714) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.compile(JavaScriptEngine.java:680) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:726) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScript(HtmlPage.java:922) at com.gargoylesoftware.htmlunit.html.HtmlScript.executeInlineScriptIfNeeded(HtmlScript.java:306) at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded(HtmlScript.java:396) 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:3146) at net.sourceforge.htmlunit.cyberneko.HTMLScanner$ContentScanner.scan(HTMLScanner.java:2074) 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:534) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:400) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:317) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:469) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:450) at br.com.noticias.g1.WebCaptura.main(WebCaptura.java:27) Caused by: net.sourceforge.htmlunit.corejs.javascript.EvaluatorException: missing formal parameter (script in https://g1.globo.com/ from (60, 66) to (77, 981)#60) at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory$HtmlUnitErrorReporter.error(HtmlUnitContextFactory.java:420) at net.sourceforge.htmlunit.corejs.javascript.Parser.addError(Parser.java:259) at net.sourceforge.htmlunit.corejs.javascript.Parser.reportError(Parser.java:327) at net.sourceforge.htmlunit.corejs.javascript.Parser.reportError(Parser.java:321) at net.sourceforge.htmlunit.corejs.javascript.Parser.arrowFunctionParams(Parser.java:1068) at net.sourceforge.htmlunit.corejs.javascript.Parser.arrowFunctionParams(Parser.java:1051) at net.sourceforge.htmlunit.corejs.javascript.Parser.arrowFunctionParams(Parser.java:1050) at net.sourceforge.htmlunit.corejs.javascript.Parser.arrowFunctionParams(Parser.java:1050) at net.sourceforge.htmlunit.corejs.javascript.Parser.arrowFunction(Parser.java:1005) at net.sourceforge.htmlunit.corejs.javascript.Parser.assignExpr(Parser.java:2379)

@rbri
Copy link
Member

rbri commented Apr 19, 2020

Hi Lucas,

looks like a problem with the js in the page. There is code like b=new Map([...o(e.ex),...o(e.im)]) in fact this uses the javascript rest operator and this is unfortunately not supported by rhino so far.

And btw: The page is not simple, is like any other news page a horrible monster filled with tons of js to confuse and track the user....

@twendelmuth
Copy link
Contributor

Issue on rhino side: mozilla/rhino#652

@rbri rbri changed the title ScriptException when trying to access a simple page ScriptException (missing formal parameter) when trying to access a simple page Sep 25, 2020
@rbri rbri added the js-engine Issues related to the js engine label Mar 27, 2024
@rbri
Copy link
Member

rbri commented Mar 27, 2024

see #755

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
js-engine Issues related to the js engine
Projects
None yet
Development

No branches or pull requests

3 participants