Search in sources :

Example 41 with NotYetImplemented

use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented in project htmlunit by HtmlUnit.

the class HttpWebConnection3Test method loadJavascriptCharset.

/**
 * @throws Exception if the test fails
 */
@Test
@Alerts(CHROME = { "GET /script.js?x=%CE%D2%CA%C7%CE%D2%B5%C4%20?%20Abc HTTP/1.1", "Host: localhost:§§PORT§§", "Connection: keep-alive", "sec-ch-ua: §§SEC_USER_AGENT§§", "sec-ch-ua-mobile: ?0", "User-Agent: §§USER_AGENT§§", "sec-ch-ua-platform: \"Windows\"", "Accept: §§ACCEPT§§", "Sec-Fetch-Site: same-origin", "Sec-Fetch-Mode: no-cors", "Sec-Fetch-Dest: script", "Referer: http://localhost:§§PORT§§/", "Accept-Encoding: gzip, deflate, br", "Accept-Language: en-US,en;q=0.9" }, EDGE = { "GET /script.js?x=%CE%D2%CA%C7%CE%D2%B5%C4%20?%20Abc HTTP/1.1", "Host: localhost:§§PORT§§", "Connection: keep-alive", "sec-ch-ua: §§SEC_USER_AGENT§§", "sec-ch-ua-mobile: ?0", "User-Agent: §§USER_AGENT§§", "sec-ch-ua-platform: \"Windows\"", "Accept: §§ACCEPT§§", "Sec-Fetch-Site: same-origin", "Sec-Fetch-Mode: no-cors", "Sec-Fetch-Dest: script", "Referer: http://localhost:§§PORT§§/", "Accept-Encoding: gzip, deflate, br", "Accept-Language: en-US,en;q=0.9" }, FF = { "GET /script.js?x=%CE%D2%CA%C7%CE%D2%B5%C4%20?%20Abc HTTP/1.1", "Host: localhost:§§PORT§§", "User-Agent: §§USER_AGENT§§", "Accept: §§ACCEPT§§", "Accept-Language: en-US,en;q=0.5", "Accept-Encoding: gzip, deflate", "Connection: keep-alive", "Referer: http://localhost:§§PORT§§/", "Sec-Fetch-Dest: script", "Sec-Fetch-Mode: no-cors", "Sec-Fetch-Site: same-origin" }, FF_ESR = { "GET /script.js?x=%CE%D2%CA%C7%CE%D2%B5%C4%20?%20Abc HTTP/1.1", "Host: localhost:§§PORT§§", "User-Agent: §§USER_AGENT§§", "Accept: §§ACCEPT§§", "Accept-Language: en-US,en;q=0.5", "Accept-Encoding: gzip, deflate", "Connection: keep-alive", "Referer: http://localhost:§§PORT§§/", "Sec-Fetch-Dest: script", "Sec-Fetch-Mode: no-cors", "Sec-Fetch-Site: same-origin" }, IE = { "GET /script.js?x=%CE%D2%CA%C7%CE%D2%B5%C4%20?%20Abc HTTP/1.1", "Accept: §§ACCEPT§§", "Referer: http://localhost:§§PORT§§/", "Accept-Language: en-US,en;q=0.9", "User-Agent: §§USER_AGENT§§", "Accept-Encoding: gzip, deflate", "Host: localhost:§§PORT§§", "Connection: Keep-Alive" })
@HtmlUnitNYI(CHROME = { "GET /script.js?x=%CE%D2%CA%C7%CE%D2%B5%C4%20?%20Abc HTTP/1.1", "Host: localhost:§§PORT§§", "Connection: Keep-Alive", "sec-ch-ua: §§SEC_USER_AGENT§§", "sec-ch-ua-mobile: ?0", "sec-ch-ua-platform: \"Windows\"", // wrong
"Upgrade-Insecure-Requests: 1", "User-Agent: §§USER_AGENT§§", "Accept: §§ACCEPT§§", "Sec-Fetch-Site: same-origin", "Sec-Fetch-Mode: no-cors", // wrong
"Sec-Fetch-User: ?1", "Sec-Fetch-Dest: script", "Referer: http://localhost:§§PORT§§/", "Accept-Encoding: gzip, deflate, br", "Accept-Language: en-US,en;q=0.9" }, EDGE = { "GET /script.js?x=%CE%D2%CA%C7%CE%D2%B5%C4%20?%20Abc HTTP/1.1", "Host: localhost:§§PORT§§", "Connection: Keep-Alive", "sec-ch-ua: §§SEC_USER_AGENT§§", "sec-ch-ua-mobile: ?0", "sec-ch-ua-platform: \"Windows\"", // wrong
"Upgrade-Insecure-Requests: 1", "User-Agent: §§USER_AGENT§§", "Accept: §§ACCEPT§§", "Sec-Fetch-Site: same-origin", "Sec-Fetch-Mode: no-cors", // wrong
"Sec-Fetch-User: ?1", "Sec-Fetch-Dest: script", "Referer: http://localhost:§§PORT§§/", "Accept-Encoding: gzip, deflate, br", "Accept-Language: en-US,en;q=0.9" }, FF = { "GET /script.js?x=%CE%D2%CA%C7%CE%D2%B5%C4%20?%20Abc HTTP/1.1", "Host: localhost:§§PORT§§", "User-Agent: §§USER_AGENT§§", "Accept: §§ACCEPT§§", "Accept-Language: en-US,en;q=0.5", "Accept-Encoding: gzip, deflate", "Connection: Keep-Alive", "Referer: http://localhost:§§PORT§§/", // wrong
"Upgrade-Insecure-Requests: 1", "Sec-Fetch-Dest: script", "Sec-Fetch-Mode: no-cors", "Sec-Fetch-Site: same-origin", "Sec-Fetch-User: ?1" /* wrong */
}, FF_ESR = { "GET /script.js?x=%CE%D2%CA%C7%CE%D2%B5%C4%20?%20Abc HTTP/1.1", "Host: localhost:§§PORT§§", "User-Agent: §§USER_AGENT§§", "Accept: §§ACCEPT§§", "Accept-Language: en-US,en;q=0.5", "Accept-Encoding: gzip, deflate", "Connection: Keep-Alive", "Referer: http://localhost:§§PORT§§/", // wrong
"Upgrade-Insecure-Requests: 1", "Sec-Fetch-Dest: script", "Sec-Fetch-Mode: no-cors", "Sec-Fetch-Site: same-origin", "Sec-Fetch-User: ?1" /* wrong */
})
// PrimitiveWebServer
@NotYetImplemented(value = {}, os = OS.Linux)
public void loadJavascriptCharset() throws Exception {
    String html = "<html><head>" + "<meta http-equiv='Content-Type' content='text/html; charset=GB2312'>" + "<script src=\"script.js?x=\u6211\u662F\u6211\u7684 \u4eb8 Abc\"></script>" + "</head><body></body></html>";
    html = "HTTP/1.1 200 OK\r\n" + "Content-Length: " + (html.length()) + "\r\n" + "Content-Type: text/html\r\n" + "\r\n" + html;
    final String hi = "HTTP/1.1 200 OK\r\n" + "Content-Length: 0\r\n" + "Content-Type: text/javascript\r\n" + "\r\n" + "";
    shutDownAll();
    try (PrimitiveWebServer primitiveWebServer = new PrimitiveWebServer(Charset.forName("GB2312"), html, hi)) {
        final WebDriver driver = getWebDriver();
        driver.get("http://localhost:" + primitiveWebServer.getPort());
        final String[] expectedHeaders = getExpectedAlerts();
        for (int i = 0; i < expectedHeaders.length; i++) {
            expectedHeaders[i] = expectedHeaders[i].replaceAll("§§PORT§§", "" + primitiveWebServer.getPort());
            expectedHeaders[i] = expectedHeaders[i].replaceAll("§§USER_AGENT§§", getBrowserVersion().getUserAgent());
            expectedHeaders[i] = expectedHeaders[i].replaceAll("§§SEC_USER_AGENT§§", getBrowserVersion().getSecClientHintUserAgentHeader());
            expectedHeaders[i] = expectedHeaders[i].replaceAll("§§ACCEPT§§", getBrowserVersion().getScriptAcceptHeader());
        }
        final String request = primitiveWebServer.getRequests().get(1);
        final String[] headers = request.split("\\r\\n");
        assertEquals(Arrays.asList(expectedHeaders).toString(), Arrays.asList(headers).toString());
    }
}
Also used : WebDriver(org.openqa.selenium.WebDriver) NotYetImplemented(com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts) HtmlUnitNYI(com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI)

Example 42 with NotYetImplemented

use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented in project htmlunit by HtmlUnit.

the class HtmlImageInputTest method click_NoPosition_NoValue.

/**
 * @throws Exception if the test fails
 */
@Test
@Alerts(DEFAULT = "§§URL§§?button.x=0&button.y=0", CHROME = "§§URL§§?button.x=28&button.y=8", EDGE = "§§URL§§?button.x=28&button.y=8", IE = "§§URL§§?button.x=14&button.y=15")
@NotYetImplemented({ CHROME, EDGE, IE })
public void click_NoPosition_NoValue() throws Exception {
    final String html = "<html><head><title>foo</title></head><body>\n" + "<form id='form1'>\n" + "  <input type='image' name='button'>\n" + "</form></body></html>";
    final WebDriver webDriver = loadPage2(html);
    webDriver.findElement(By.name("button")).click();
    expandExpectedAlertsVariables(URL_FIRST);
    assertEquals(getExpectedAlerts()[0], webDriver.getCurrentUrl());
}
Also used : WebDriver(org.openqa.selenium.WebDriver) NotYetImplemented(com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)

Example 43 with NotYetImplemented

use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented in project htmlunit by HtmlUnit.

the class HtmlInlineFrame2Test method aboutSrc.

/**
 * Looks like url's with the about schema are always behave
 * like 'about:blank'.
 *
 * @throws Exception if the test fails
 */
@Test
@Alerts(DEFAULT = "about:blank", CHROME = "about://unsupported", EDGE = "about://unsupported", IE = "exception")
@NotYetImplemented({ CHROME, EDGE, IE })
public void aboutSrc() throws Exception {
    final String html = "<html><head>\n" + "<script>\n" + "  function test() {\n" + "    var frame = document.getElementById('tstFrame');\n" + "    try {" + "      alert(frame.contentWindow.location.href);\n" + "    } catch(e) { alert('exception'); }\n" + "  }\n" + "</script>\n" + "</head>\n" + "<body>\n" + "  <iframe id='tstFrame' src='about://unsupported'></iframe>\n" + "  <button id='test' onclick='test()'>Test</button>\n" + "</body></html>";
    final WebDriver driver = loadPage2(html);
    driver.findElement(By.id("test")).click();
    assertEquals(getExpectedAlerts(), getCollectedAlerts(driver));
}
Also used : WebDriver(org.openqa.selenium.WebDriver) NotYetImplemented(com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented) Test(org.junit.Test) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)

Example 44 with NotYetImplemented

use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented in project htmlunit by HtmlUnit.

the class HtmlFrameSetTest method onunload.

/**
 * @throws Exception if the test fails
 */
@Test
@NotYetImplemented
public void onunload() throws Exception {
    final String mainHtml = "<frameset onunload=\"document.location.href='3.html'\">\n" + "<frame name='f1' src='1.html'/>\n" + "</frameset>";
    final String frame1 = "<html><head><title>1</title></head>\n" + "<body><button id='myButton' onclick=\"top.location.href='2.html'\"/></body>\n" + "</html>";
    final String html2 = "<html><head><title>2</title></head>\n" + "<body>hello</body>\n" + "</html>";
    final String html3 = "<html><head><title>3</title></head>\n" + "<body>hello</body>\n" + "</html>";
    final WebClient webClient = getWebClientWithMockWebConnection();
    final List<String> collectedAlerts = new ArrayList<>();
    webClient.setAlertHandler(new CollectingAlertHandler(collectedAlerts));
    final MockWebConnection conn = getMockWebConnection();
    conn.setResponse(URL_FIRST, mainHtml);
    conn.setResponse(new URL(URL_FIRST, "1.html"), frame1);
    conn.setResponse(new URL(URL_FIRST, "2.html"), html2);
    conn.setResponse(new URL(URL_FIRST, "3.html"), html3);
    final HtmlPage mainPage = webClient.getPage(URL_FIRST);
    final HtmlPage framePage = (HtmlPage) mainPage.getFrameByName("f1").getEnclosedPage();
    final HtmlPage page = framePage.getHtmlElementById("myButton").click();
    assertEquals("3", page.getTitleText());
}
Also used : ArrayList(java.util.ArrayList) CollectingAlertHandler(com.gargoylesoftware.htmlunit.CollectingAlertHandler) MockWebConnection(com.gargoylesoftware.htmlunit.MockWebConnection) WebClient(com.gargoylesoftware.htmlunit.WebClient) URL(java.net.URL) NotYetImplemented(com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented) Test(org.junit.Test)

Example 45 with NotYetImplemented

use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented in project htmlunit by HtmlUnit.

the class HTMLFormElementTest method submitTriggersRequestNotParsed.

/**
 * @throws Exception if the test fails
 */
@Test
@Alerts(DEFAULT = { "", "foo4?foo=", "script4.js" }, IE = { "", "foo0?foo=", "foo4?foo=", "script4.js" })
@NotYetImplemented
public void submitTriggersRequestNotParsed() throws Exception {
    final String html = "<html><head><script>\n" + "function test() {\n" + "  var f = document.forms[0];\n" + "  for (var i = 0; i < 5; i++) {\n" + "    f.action = 'foo' + i;\n" + "    f.submit();\n" + "  }\n" + "}\n" + "</script></head>\n" + "<body onload='test()'>\n" + "  <form>\n" + "    <input name='foo'>\n" + "  </form>\n" + "</body></html>";
    final MockWebConnection connection = getMockWebConnection();
    for (int i = 0; i < 5; i++) {
        final String htmlX = "<html><head>\n" + "<title>Page " + i + "</title>\n" + "<script src='script" + i + ".js'></script>\n" + "<script>alert('page" + i + "');</script>\n" + "</head></html>";
        connection.setResponse(new URL(URL_FIRST, "foo" + i), htmlX);
        connection.setResponse(new URL(URL_FIRST, "script" + i + ".js"), "", MimeType.APPLICATION_JAVASCRIPT);
    }
    final String[] expectedRequests = getExpectedAlerts();
    setExpectedAlerts("page4");
    // forces to wait, what is needed for FFdriver
    final WebDriver driver = loadPageWithAlerts2(html);
    // NB: comparing the sequence order here is not 100% safe with a real browser
    assertEquals(expectedRequests, getMockWebConnection().getRequestedUrls(URL_FIRST));
    assertTitle(driver, "Page 4");
}
Also used : WebDriver(org.openqa.selenium.WebDriver) MockWebConnection(com.gargoylesoftware.htmlunit.MockWebConnection) URL(java.net.URL) 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