use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented in project htmlunit by HtmlUnit.
the class WebClient2Test method serialization_withJSBackgroundTasks.
/**
* Background tasks that have been registered before the serialization should
* wake up and run normally after the deserialization.
* Until now (2.7-SNAPSHOT 17.09.09) HtmlUnit has probably never supported it.
* This is currently not requested and this test is just to document the current status.
* @throws Exception if an error occurs
*/
@Test
@NotYetImplemented
public void serialization_withJSBackgroundTasks() throws Exception {
final String html = "<html><head>\n" + "<script>\n" + " function foo() {\n" + " if (window.name == 'hello') {\n" + " alert('exiting');\n" + " clearInterval(intervalId);\n" + " }\n" + " }\n" + " var intervalId = setInterval(foo, 10);\n" + "</script></head>\n" + "<body></body></html>";
final HtmlPage page = loadPageWithAlerts(html);
// verify that 1 background job exists
assertEquals(1, page.getEnclosingWindow().getJobManager().getJobCount());
final byte[] bytes = SerializationUtils.serialize(page);
page.getWebClient().close();
// deserialize page and verify that 1 background job exists
final HtmlPage clonedPage = (HtmlPage) SerializationUtils.deserialize(bytes);
assertEquals(1, clonedPage.getEnclosingWindow().getJobManager().getJobCount());
// configure a new CollectingAlertHandler (in fact it has surely already one and we could get and cast it)
final List<String> collectedAlerts = Collections.synchronizedList(new ArrayList<String>());
final AlertHandler alertHandler = new CollectingAlertHandler(collectedAlerts);
clonedPage.getWebClient().setAlertHandler(alertHandler);
// make some change in the page on which background script reacts
clonedPage.getEnclosingWindow().setName("hello");
clonedPage.getWebClient().waitForBackgroundJavaScriptStartingBefore(100);
assertEquals(0, clonedPage.getEnclosingWindow().getJobManager().getJobCount());
final String[] expectedAlerts = { "exiting" };
assertEquals(expectedAlerts, collectedAlerts);
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented in project htmlunit by HtmlUnit.
the class WebClient3Test method escapeRequestQuery2a.
/**
* Was causing a "java.net.URISyntaxException: Malformed escape pair".
* HtmlUnit now escapes the "%%" to "%25%25" to build a valid URL but FF doesn't care
* and sends the invalid "%%" sequence as it.
* This will be quite difficult to simulate FF here as HttpClient's HttpRequestBase
* uses URI and "%%" can't be part of the query string for a URI.
* @throws Exception if the test fails
*/
@Test
@NotYetImplemented
public void escapeRequestQuery2a() throws Exception {
getMockWebConnection().setDefaultResponse("");
final URL url = new URL(URL_FIRST, "foo.png?cb=%%RANDOM_NUMBER%%");
loadPage2("", url);
// real browsers do not send this request
// 'Unable to parse URI query'
assertEquals(0, getMockWebConnection().getRequestCount());
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented in project htmlunit by HtmlUnit.
the class HtmlLink2Test method onLoadDynamicUnknown.
/**
* @throws Exception if an error occurs
*/
@Test
@Alerts(DEFAULT = "onError [object Event]", IE = "onLoad [object Event]")
@NotYetImplemented(IE)
public void onLoadDynamicUnknown() throws Exception {
getMockWebConnection().setResponse(new URL(URL_FIRST, "simple.css"), "");
final String html = "<html>\n" + "<head>\n" + " <script>\n" + " function test() {\n" + " var dynLink = document.createElement('link');\n" + " dynLink.rel = 'stylesheet';\n" + " dynLink.type = 'text/css';\n" + " dynLink.href = 'unknown.css';" + " dynLink.onload = function (e) { log(\"onLoad \" + e) };\n" + " dynLink.onerror = function (e) { log(\"onError \" + e) };\n" + " document.head.appendChild(dynLink);\n" + " }\n" + " function log(x) {\n" + " document.getElementById('log').value += x + '\\n';\n" + " }\n" + " </script>\n" + "</head>\n" + "<body onload='test()'></body>\n" + " <textarea id='log' cols='80' rows='40'></textarea>\n" + "</body>\n" + "</html>";
getMockWebConnection().setDefaultResponse("Error: not found", 404, "Not Found", MimeType.TEXT_HTML);
final WebDriver driver = loadPage2(html);
Thread.sleep(200);
final String text = driver.findElement(By.id("log")).getAttribute("value").trim().replaceAll("\r", "");
assertEquals(String.join("\n", getExpectedAlerts()), text);
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented in project htmlunit by HtmlUnit.
the class HtmlLink2Test method onLoadOrder.
/**
* @throws Exception if an error occurs
*/
@Test
@Alerts(DEFAULT = { "onLoad1", "onLoadJs1", "onLoad2", "body onLoad;" }, IE = { "onLoadJs1", "body onLoad", "onLoad1", "onLoad2;" })
@NotYetImplemented(IE)
public void onLoadOrder() throws Exception {
getMockWebConnection().setResponse(new URL(URL_FIRST, "simple1.css"), "");
getMockWebConnection().setResponse(new URL(URL_FIRST, "simple2.css"), "");
getMockWebConnection().setResponse(new URL(URL_FIRST, "simple1.js"), "var x=1;");
final String html = "<html>\n" + "<head>\n" + " <script>\n" + " function log(x) {\n" + " document.title += x + ';';\n" + " }\n" + " </script>\n" + " <link rel='stylesheet' href='simple1.css' onload='log(\"onLoad1\")'>\n" + " <script type='text/javascript' src='simple1.js' onload='log(\"onLoadJs1\")'></script>\n" + " <link rel='stylesheet' href='simple2.css' onload='log(\"onLoad2\")'>\n" + "</head>\n" + "<body onload='log(\"body onLoad\")'>\n" + "</body>\n" + "</html>";
final WebDriver driver = loadPage2(html);
assertTitle(driver, String.join(";", getExpectedAlerts()));
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented in project htmlunit by HtmlUnit.
the class HtmlMonthInputTest method typing.
/**
* @throws Exception if the test fails
*/
@Test
@Alerts(DEFAULT = "8", CHROME = "", EDGE = "")
@NotYetImplemented({ FF, FF_ESR, IE })
public void typing() throws Exception {
final String htmlContent = "<html><head><title>foo</title></head><body>\n" + "<form id='form1'>\n" + " <input type='month' id='foo'>\n" + "</form></body></html>";
final WebDriver driver = loadPage2(htmlContent);
final WebElement input = driver.findElement(By.id("foo"));
input.sendKeys("8");
assertEquals(getExpectedAlerts()[0], input.getAttribute("value"));
}
Aggregations