From: <mgu...@us...> - 2013-01-28 09:06:36
|
Revision: 8041 http://sourceforge.net/p/htmlunit/code/8041 Author: mguillem Date: 2013-01-28 09:06:33 +0000 (Mon, 28 Jan 2013) Log Message: ----------- XHR.open allows empty URLs for FF17. Make XMLHttpRequest2Test working for FF17. Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLHttpRequest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLHttpRequest2Test.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2013-01-28 09:01:15 UTC (rev 8040) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2013-01-28 09:06:33 UTC (rev 8041) @@ -1255,6 +1255,10 @@ @BrowserFeature(@WebBrowser(FF)) XHR_ONREADYSTATECHANGE_WITH_EVENT_PARAM, + /** Indicates if an empty url is allowed as url param for the open method. */ + @BrowserFeature({ @WebBrowser(value = FF, minVersion = 10), @WebBrowser(CHROME) }) + XHR_OPEN_ALLOW_EMTPY_URL, + /** Indicates if a "Origin" header should be sent. */ @BrowserFeature({ @WebBrowser(FF), @WebBrowser(CHROME) }) XHR_ORIGIN_HEADER, Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLHttpRequest.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLHttpRequest.java 2013-01-28 09:01:15 UTC (rev 8040) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLHttpRequest.java 2013-01-28 09:06:33 UTC (rev 8041) @@ -22,6 +22,7 @@ import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.XHR_ONREADYSTATECANGE_SYNC_REQUESTS_COMPLETED; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.XHR_ONREADYSTATECANGE_SYNC_REQUESTS_NOT_TRIGGERED; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.XHR_ONREADYSTATECHANGE_WITH_EVENT_PARAM; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.XHR_OPEN_ALLOW_EMTPY_URL; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.XHR_ORIGIN_HEADER; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.XHR_TRIGGER_ONLOAD_ON_COMPLETED; import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.CHROME; @@ -441,7 +442,7 @@ @JsxFunction public void open(final String method, final Object urlParam, final boolean async, final Object user, final Object password) { - if (urlParam == null || "".equals(urlParam)) { + if ((urlParam == null || "".equals(urlParam)) && !getBrowserVersion().hasFeature(XHR_OPEN_ALLOW_EMTPY_URL)) { throw Context.reportRuntimeError("URL for XHR.open can't be empty!"); } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLHttpRequest2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLHttpRequest2Test.java 2013-01-28 09:01:15 UTC (rev 8040) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLHttpRequest2Test.java 2013-01-28 09:06:33 UTC (rev 8041) @@ -28,14 +28,12 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import com.gargoylesoftware.htmlunit.BrowserRunner; import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; import com.gargoylesoftware.htmlunit.BrowserRunner.NotYetImplemented; -import com.gargoylesoftware.htmlunit.BrowserVersion; import com.gargoylesoftware.htmlunit.WebDriverTestCase; import com.gargoylesoftware.htmlunit.WebRequest; import com.gargoylesoftware.htmlunit.util.NameValuePair; @@ -61,10 +59,13 @@ * Strangely, this test seem to fail even without the implementation of the "/setStateXX" handling * on the "server side". * Strange thing. + * + * Update 28.01.2013: + * no deadlock occur anymore (we use a single JS execution thread for a while). Activating the test as it may help. + * * @throws Exception if the test fails */ @Test - @NotYetImplemented public void deadlock() throws Exception { final String jsCallSynchXHR = "function callSynchXHR(url) {\n" + " var xhr = " + XHRInstantiation_ + ";\n" @@ -113,8 +114,7 @@ // just to avoid unused variable warning when the next line is commented getMockWebConnection().setResponse(getDefaultUrl(), html); - // loadPageWithAlerts2(html); - Assert.fail("didn't run the real test as it causes a deadlock"); + loadPage2(html); } /** @@ -179,9 +179,9 @@ * @throws Exception if an error occurs */ @Test - @Alerts(DEFAULT = { "exception", "exception", "pass", "pass" }, - FF10 = { "pass", "pass", "pass", "pass" }, - CHROME = { "pass", "pass", "pass", "pass" }) + @Alerts(DEFAULT = { "pass", "pass", "pass", "pass" }, + FF3_6 = { "exception", "exception", "pass", "pass" }, + IE = { "exception", "exception", "pass", "pass" }) public void openThrowOnEmptyUrl() throws Exception { final String html = "<html><head>\n" + "<script>\n" @@ -200,7 +200,7 @@ loadPageWithAlerts2(html); final int expectedRequests; - if (getBrowserVersion().isChrome() || BrowserVersion.FIREFOX_10 == getBrowserVersion()) { + if ("pass".equals(getExpectedAlerts()[0])) { expectedRequests = 5; } else { @@ -477,7 +477,7 @@ * @throws Exception if the test fails */ @Test - @Alerts(IE = { "1", "2", "3", "4" }, FF10 = "4", CHROME = "4") + @Alerts(DEFAULT = "4", IE = { "1", "2", "3", "4" }, FF3_6 = { }) public void testOnreadystatechange_sync() throws Exception { final String html = "<html>\n" @@ -516,7 +516,7 @@ * @throws Exception if the test fails */ @Test - @Alerts(FF10 = "[object Event]#[object XMLHttpRequest]", IE = "no param") + @Alerts(FF3_6 = { }, FF = "[object Event]#[object XMLHttpRequest]", IE = "no param") public void testOnreadystatechangeSyncWithParam() throws Exception { final String html = "<html>\n" |