[HtmlUnit] [htmlunit:bugs] #1835 Exception in JQuery 1.6.1 causing JQuery not to load
RBRi via HtmlUnit-develop <[email protected]> Fri, 27 Jul 2018 18:26:33 -0000
| Newsgroups | gmane.comp.java.htmlunit.devel |
|---|---|
| Message-ID | </p/htmlunit/bugs/1835/c4593cba4c813b56fbe3cb4f51f3523202e46ddb.bugs@htmlunit.p.sourceforge.net> |
At the moment we have no solution for this but you can use this work around:
* download the non minimized version of jQuery and place it on your machine
* use the FalsifyingWebConnection to replace the server respons with the content from your machine
~~~
webClient.setWebConnection(new FalsifyingWebConnection(webClient) {
@Override
public WebResponse getResponse(WebRequest webRequest) throws IOException {
System.out.println(webRequest.getUrl().toExternalForm());
if (webRequest.getUrl().getPath().endsWith("jquery-1.6.1.min.js")) {
String jQuery = FileUtils.readFileToString(new File("jquery-1.6.1.js"));
return createWebResponse(webRequest, jQuery, "application/javascript");
}
return super.getResponse(webRequest);
}
});
~~~
---
** [bugs:#1835] Exception in JQuery 1.6.1 causing JQuery not to load**
**Status:** accepted
**Group:** 2.23
**Created:** Wed Nov 16, 2016 10:32 PM UTC by Willie Owens
**Last Updated:** Mon Jun 19, 2017 12:23 PM UTC
**Owner:** nobody
To reproduce, here is a basic HTML file:
~~~
<html>
<head>
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js'></script>
</head>
<body>
Hello world!
</body>
</html>
~~~
which can be tested using the java program:
~~~
public class HtmlUnitJQuery1_6_1 {
public static void main(String[] args) throws Exception {
WebClient wc = new WebClient(BrowserVersion.CHROME);
wc.getPage("file:///home/wowens/Documents/jquery1.6.1.html");
}
}
~~~
You'll get an error that we cannot call the function "replace" on undefined:
~~~
Exception in thread "main" ======= EXCEPTION START ========
EcmaError: lineNumber=[18] column=[0] lineSource=[null] name=[TypeError] sourceName=[http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js] message=[TypeError: Cannot call method "replace" of undefined (http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js#18)]
com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot call method "replace" of undefined (http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js#18)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:883)
at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:628)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:513)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:815)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:787)
at com.gargoylesoftware.htmlunit.InteractivePage.executeJavaScriptFunctionIfPossible(InteractivePage.java:216)
at com.gargoylesoftware.htmlunit.javascript.host.event.EventListenersContainer.executeEventListeners(EventListenersContainer.java:258)
at com.gargoylesoftware.htmlunit.javascript.host.event.EventListenersContainer.executeBubblingListeners(EventListenersContainer.java:322)
at com.gargoylesoftware.htmlunit.javascript.host.event.EventTarget.fireEvent(EventTarget.java:192)
at com.gargoylesoftware.htmlunit.html.DomElement$2.run(DomElement.java:1167)
at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:628)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:513)
at com.gargoylesoftware.htmlunit.html.DomElement.fireEvent(DomElement.java:1172)
at com.gargoylesoftware.htmlunit.html.HtmlPage.executeEventHandlersIfNeeded(HtmlPage.java:1223)
at com.gargoylesoftware.htmlunit.html.HtmlPage.initialize(HtmlPage.java:254)
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:484)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:351)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:416)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:401)
at urjanet.pull.web.htmlunit.Anniston.main(Anniston.java:25)
Caused by: net.sourceforge.htmlunit.corejs.javascript.EcmaError: TypeError: Cannot call method "replace" of undefined (http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js#18)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3935)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3919)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3944)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3960)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.undefCallError(ScriptRuntime.java:3976)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getPropFunctionAndThisHelper(ScriptRuntime.java:2414)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2408)
at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1337)
at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:798)
at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:105)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:411)
at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:252)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3286)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$4.doRun(JavaScriptEngine.java:808)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:868)
... 19 more
Enclosed exception:
net.sourceforge.htmlunit.corejs.javascript.EcmaError: TypeError: Cannot call method "replace" of undefined (http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js#18)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3935)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3919)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3944)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3960)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.undefCallError(ScriptRuntime.java:3976)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getPropFunctionAndThisHelper(ScriptRuntime.java:2414)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2408)
at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1337)
at script(http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js:18)
at script(http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js:16)
at script(http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js:16)
at script(http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js:16)
at script(http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js:17)
at script(http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js:16)
at script(http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js:16)
at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:798)
at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:105)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:411)
at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:252)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3286)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$4.doRun(JavaScriptEngine.java:808)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:868)
at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:628)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:513)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:815)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:787)
at com.gargoylesoftware.htmlunit.InteractivePage.executeJavaScriptFunctionIfPossible(InteractivePage.java:216)
at com.gargoylesoftware.htmlunit.javascript.host.event.EventListenersContainer.executeEventListeners(EventListenersContainer.java:258)
at com.gargoylesoftware.htmlunit.javascript.host.event.EventListenersContainer.executeBubblingListeners(EventListenersContainer.java:322)
at com.gargoylesoftware.htmlunit.javascript.host.event.EventTarget.fireEvent(EventTarget.java:192)
at com.gargoylesoftware.htmlunit.html.DomElement$2.run(DomElement.java:1167)
at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:628)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:513)
at com.gargoylesoftware.htmlunit.html.DomElement.fireEvent(DomElement.java:1172)
at com.gargoylesoftware.htmlunit.html.HtmlPage.executeEventHandlersIfNeeded(HtmlPage.java:1223)
at com.gargoylesoftware.htmlunit.html.HtmlPage.initialize(HtmlPage.java:254)
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:484)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:351)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:416)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:401)
at urjanet.pull.web.htmlunit.Anniston.main(Anniston.java:25)
== CALLING JAVASCRIPT ==
function () {
c.removeEventListener("DOMContentLoaded", z, !1), e.ready();
}
======= EXCEPTION END ========
~~~
Using an later minor version of jquery works fine.
I'd found this issue: https://github.com/bfsc/reviewer/issues/27, but in my case I need JQuery to load and I cannot use another version.
Thanks,
Willie
---
Sent from sourceforge.net because [email protected] is subscribed to https://sourceforge.net/p/htmlunit/bugs/
To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/htmlunit/admin/bugs/options. Or, if this is a mailing list, you can unsubscribe from the mailing list.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
HtmlUnit-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop