HtmlUnit (2.3, 2.4 and latest code) doesn't seem to handle YUI 2.6.0 XHR request.
Here is a simple test case:
import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
public class HtmlUnitTest
{
@Test
public void ajax() throws Exception
{
WebClient client = new WebClient(BrowserVersion.FIREFOX_2);
final HtmlPage page = (HtmlPage) client.getPage("http://developer.yahoo.com/yui/examples/datatable/dt_xhrjson_clean.html");
}
}
Here is the exception message:
com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot call method "appendChild" of null (http://yui.yahooapis.com/2.6.0/build/datatable/datatable-min.js#12)
======= EXCEPTION START ========
EcmaError: lineNumber=[12] column=[0] lineSource=[null] name=[TypeError] sourceName=[http://yui.yahooapis.com/2.6.0/build/datatable/datatable-min.js] message=[TypeError: Cannot call method "appendChild" of null (http://yui.yahooapis.com/2.6.0/build/datatable/datatable-min.js#12)]
com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot call method "appendChild" of null (http://yui.yahooapis.com/2.6.0/build/datatable/datatable-min.js#12)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:528)
at org.mozilla.javascript.Context.call(Context.java:502)
at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:511)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:437)
at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfPossible(HtmlPage.java:917)
at com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.executeEventListeners(EventListenersContainer.java:126)
at com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.executeBubblingListeners(EventListenersContainer.java:163)
at com.gargoylesoftware.htmlunit.javascript.host.Node.fireEvent(Node.java:560)
at com.gargoylesoftware.htmlunit.html.HtmlElement$2.run(HtmlElement.java:1251)
at org.mozilla.javascript.Context.call(Context.java:502)
at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:511)
at com.gargoylesoftware.htmlunit.html.HtmlElement.fireEvent(HtmlElement.java:1255)
at com.gargoylesoftware.htmlunit.html.HtmlPage.executeEventHandlersIfNeeded(HtmlPage.java:1154)
at com.gargoylesoftware.htmlunit.html.HtmlPage.initialize(HtmlPage.java:173)
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:456)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:331)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:388)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:373)
at au.com.suncorp.ffe.audit.htmlunit.HtmlUnitTest.ajax(HtmlUnitTest.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
at com.intellij.rt.junit4.Junit4ClassSuite.run(Junit4ClassSuite.java:99)
at com.intellij.rt.execution.junit.IdeaTestRunner.doRun(IdeaTestRunner.java:94)
at com.intellij.rt.execution.junit.IdeaTestRunner.startRunnerWithArgs(IdeaTestRunner.java:22)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:118)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
Caused by: org.mozilla.javascript.EcmaError: TypeError: Cannot call method "appendChild" of null (http://yui.yahooapis.com/2.6.0/build/datatable/datatable-min.js#12)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3558)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3536)
at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3564)
at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3583)
at org.mozilla.javascript.ScriptRuntime.undefCallError(ScriptRuntime.java:3602)
at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2161)
at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3170)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2484)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:401)
at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:170)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3004)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:162)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:465)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$6.doRun(JavaScriptEngine.java:430)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:522)
... 46 more
Enclosed exception:
org.mozilla.javascript.EcmaError: TypeError: Cannot call method "appendChild" of null (http://yui.yahooapis.com/2.6.0/build/datatable/datatable-min.js#12)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3558)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3536)
at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3564)
at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3583)
at org.mozilla.javascript.ScriptRuntime.undefCallError(ScriptRuntime.java:3602)
at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2161)
at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3170)
at script(http://yui.yahooapis.com/2.6.0/build/datatable/datatable-min.js:12)
at script(http://yui.yahooapis.com/2.6.0/build/datatable/datatable-min.js:11)
at script(http://yui.yahooapis.com/2.6.0/build/datatable/datatable-min.js:9)
at script(script in http://developer.yahoo.com/yui/examples/datatable/dt_xhrjson_clean.html from (48, 32) to (99, 10):70)
at script(script in http://developer.yahoo.com/yui/examples/datatable/dt_xhrjson_clean.html from (48, 32) to (99, 10):50)
at script(http://yui.yahooapis.com/2.6.0/build/yahoo-dom-event/yahoo-dom-event.js:8)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2484)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:401)
at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:170)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3004)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:162)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:465)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$6.doRun(JavaScriptEngine.java:430)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:522)
at org.mozilla.javascript.Context.call(Context.java:502)
at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:511)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:437)
at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfPossible(HtmlPage.java:917)
at com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.executeEventListeners(EventListenersContainer.java:126)
at com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.executeBubblingListeners(EventListenersContainer.java:163)
at com.gargoylesoftware.htmlunit.javascript.host.Node.fireEvent(Node.java:560)
at com.gargoylesoftware.htmlunit.html.HtmlElement$2.run(HtmlElement.java:1251)
at org.mozilla.javascript.Context.call(Context.java:502)
at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:511)
at com.gargoylesoftware.htmlunit.html.HtmlElement.fireEvent(HtmlElement.java:1255)
at com.gargoylesoftware.htmlunit.html.HtmlPage.executeEventHandlersIfNeeded(HtmlPage.java:1154)
at com.gargoylesoftware.htmlunit.html.HtmlPage.initialize(HtmlPage.java:173)
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:456)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:331)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:388)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:373)
at au.com.suncorp.ffe.audit.htmlunit.HtmlUnitTest.ajax(HtmlUnitTest.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
at com.intellij.rt.junit4.Junit4ClassSuite.run(Junit4ClassSuite.java:99)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
== CALLING JAVASCRIPT ==
function (c) {
return X.call(b, YAHOO.util.Event.getEvent(c, O), S);
}
======= EXCEPTION END ========
Thanks for reporting, fixed in SVN.