Search in sources :

Example 21 with NotYetImplemented

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);
}
Also used : HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) NotYetImplemented(com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented) Test(org.junit.Test)

Example 22 with NotYetImplemented

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());
}
Also used : URL(java.net.URL) NotYetImplemented(com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented) Test(org.junit.Test)

Example 23 with NotYetImplemented

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);
}
Also used : WebDriver(org.openqa.selenium.WebDriver) URL(java.net.URL) NotYetImplemented(com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)

Example 24 with NotYetImplemented

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()));
}
Also used : WebDriver(org.openqa.selenium.WebDriver) URL(java.net.URL) NotYetImplemented(com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)

Example 25 with NotYetImplemented

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"));
}
Also used : WebDriver(org.openqa.selenium.WebDriver) WebElement(org.openqa.selenium.WebElement) NotYetImplemented(com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)

Aggregations

NotYetImplemented (com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented)66 Test (org.junit.Test)65 Alerts (com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)54 WebDriver (org.openqa.selenium.WebDriver)54 HtmlPageTest (com.gargoylesoftware.htmlunit.html.HtmlPageTest)16 URL (java.net.URL)15 BuggyWebDriver (com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver)12 WebElement (org.openqa.selenium.WebElement)11 ArrayList (java.util.ArrayList)6 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)5 HtmlUnitDriver (org.openqa.selenium.htmlunit.HtmlUnitDriver)5 MockWebConnection (com.gargoylesoftware.htmlunit.MockWebConnection)4 MSXMLTestHelper.callLoadXMLDOMDocumentFromString (com.gargoylesoftware.htmlunit.activex.javascript.msxml.MSXMLTestHelper.callLoadXMLDOMDocumentFromString)4 NameValuePair (com.gargoylesoftware.htmlunit.util.NameValuePair)4 WebClient (com.gargoylesoftware.htmlunit.WebClient)3 InputStream (java.io.InputStream)3 CollectingAlertHandler (com.gargoylesoftware.htmlunit.CollectingAlertHandler)2 MSXMLTestHelper.callSerializeXMLDOMDocumentToString (com.gargoylesoftware.htmlunit.activex.javascript.msxml.MSXMLTestHelper.callSerializeXMLDOMDocumentToString)2 HtmlElement (com.gargoylesoftware.htmlunit.html.HtmlElement)2 File (java.io.File)2