use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI in project htmlunit by HtmlUnit.
the class XMLHttpRequestCORSTest method preflight_many_header_values.
/**
* @throws Exception if the test fails.
*/
@Test
@Alerts(DEFAULT = { "4", "200", "options_headers", "x-ping,x-pong" }, IE = { "4", "200", "options_headers", "x-ping, x-pong" })
@HtmlUnitNYI(IE = { "4", "200", "options_headers", "x-ping,x-pong" })
public void preflight_many_header_values() throws Exception {
expandExpectedAlertsVariables(new URL("http://localhost:" + PORT));
final String html = "<html><head>\n" + "<script>\n" + LOG_TITLE_FUNCTION + "var xhr = new XMLHttpRequest();\n" + "function test() {\n" + " try {\n" + " var url = 'http://' + window.location.hostname + ':" + PORT2 + "/preflight2';\n" + " xhr.open('GET', url, false);\n" + " xhr.setRequestHeader('X-PING', 'ping');\n" + " xhr.setRequestHeader('X-PONG', 'pong');\n" + " xhr.send();\n" + " } catch(e) { log('exception') }\n" + " log(xhr.readyState);\n" + " log(xhr.status);\n" + " log(xhr.responseXML.firstChild.childNodes[3].tagName);\n" + " log(xhr.responseXML.firstChild.childNodes[3].firstChild.nodeValue);\n" + "}\n" + "</script>\n" + "</head>\n" + "<body onload='test()'></body></html>";
PreflightServerServlet.ACCESS_CONTROL_ALLOW_ORIGIN_ = "http://localhost:" + PORT;
PreflightServerServlet.ACCESS_CONTROL_ALLOW_METHODS_ = "POST, GET, OPTIONS";
PreflightServerServlet.ACCESS_CONTROL_ALLOW_HEADERS_ = "X-PING, X-PONG";
final Map<String, Class<? extends Servlet>> servlets2 = new HashMap<>();
servlets2.put("/preflight2", PreflightServerServlet.class);
startWebServer2(".", null, servlets2);
loadPage2(html, new URL(URL_FIRST, "/preflight1"));
verifyTitle2(getWebDriver(), getExpectedAlerts());
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI in project htmlunit by HtmlUnit.
the class XMLHttpRequestTest method enctypeBlob.
/**
* @throws Exception if the test fails
*/
@Test
@Alerts(DEFAULT = "application/json", IE = "null")
@HtmlUnitNYI(IE = "application/x-www-form-urlencoded")
public void enctypeBlob() throws Exception {
final String html = "<html>\n" + "<head>\n" + "<script>\n" + LOG_TITLE_FUNCTION + "function doTest() {\n" + " try {\n" + " var debug = {hello: 'world'};\n" + " var blob = new Blob([JSON.stringify(debug, null, 2)], {type : 'application/json'});\n" + " var xhr = new XMLHttpRequest();\n" + " xhr.open('post', '/test2', false);\n" + " xhr.send(blob);\n" + " log('done');\n" + " } catch (e) {\n" + " log('error: ' + e.message);\n" + " }\n" + "}\n" + "</script>\n" + "</head>\n" + "<body onload='doTest()'>\n" + "</body>\n" + "</html>";
getMockWebConnection().setDefaultResponse("<html><title>Response</title></html>");
final WebDriver driver = loadPage2(html);
verifyTitle2(driver, new String[] { "done" });
String headerValue = getMockWebConnection().getLastWebRequest().getAdditionalHeaders().get(HttpHeader.CONTENT_TYPE);
// Can't test equality for multipart/form-data as it will have the form:
// multipart/form-data; boundary=---------------------------42937861433140731107235900
headerValue = StringUtils.substringBefore(headerValue, ";");
assertEquals(getExpectedAlerts()[0], "" + headerValue);
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI in project htmlunit by HtmlUnit.
the class XMLSerializerTest method htmlAttributes.
/**
* @throws Exception if the test fails
*/
@Test
@Alerts(DEFAULT = "<?xml32version=\"1.0\"32encoding=\"UTF-8\"?>1310<html32xmlns=\"http://www.w3.org/1999/xhtml\">" + "<head><title>html</title></head>" + "<body32id=\"bodyId\">" + "<span32class=\"spanClass\">foo</span>" + "</body>" + "</html>", CHROME = "<?xml32version=\"1.0\"32encoding=\"ISO-8859-1\"?><html32xmlns=\"http://www.w3.org/1999/xhtml\">" + "<head><title>html</title></head>" + "<body32id=\"bodyId\">" + "<span32class=\"spanClass\">foo</span>" + "</body>" + "</html>", EDGE = "<?xml32version=\"1.0\"32encoding=\"ISO-8859-1\"?><html32xmlns=\"http://www.w3.org/1999/xhtml\">" + "<head><title>html</title></head>" + "<body32id=\"bodyId\">" + "<span32class=\"spanClass\">foo</span>" + "</body>" + "</html>", IE = "<html32xmlns=\"http://www.w3.org/1999/xhtml\">" + "<head><title>html</title></head>" + "<body>" + "<span32class=\"spanClass\">foo</span>" + "</body>" + "</html>")
// IE omits the body's ID attribute
@HtmlUnitNYI(CHROME = "<html32xmlns=\"http://www.w3.org/1999/xhtml\">" + "<head><title>html</title></head>" + "<body32id=\"bodyId\">" + "<span32class=\"spanClass\">foo</span>" + "</body>" + "</html>", EDGE = "<html32xmlns=\"http://www.w3.org/1999/xhtml\">" + "<head><title>html</title></head>" + "<body32id=\"bodyId\">" + "<span32class=\"spanClass\">foo</span>" + "</body>" + "</html>", FF_ESR = "<html32xmlns=\"http://www.w3.org/1999/xhtml\">" + "<head><title>html</title></head>" + "<body32id=\"bodyId\">" + "<span32class=\"spanClass\">foo</span>" + "</body>" + "</html>", FF = "<html32xmlns=\"http://www.w3.org/1999/xhtml\">" + "<head><title>html</title></head>" + "<body32id=\"bodyId\">" + "<span32class=\"spanClass\">foo</span>" + "</body>" + "</html>", IE = "<html32xmlns=\"http://www.w3.org/1999/xhtml\">" + "<head><title>html</title></head>" + "<body32id=\"bodyId\">" + "<span32class=\"spanClass\">foo</span>" + "</body>" + "</html>")
public void htmlAttributes() throws Exception {
final String expectedString = getExpectedAlerts()[0];
setExpectedAlerts();
final String serializationText = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" + "<html xmlns=\"http://www.w3.org/1999/xhtml\">" + "<head><title>html</title></head>" + "<body id=\"bodyId\">" + "<span class=\"spanClass\">foo</span>" + "</body>" + "</html>";
final WebDriver driver = loadPageVerifyTitle2(constructPageContent(serializationText));
final WebElement textArea = driver.findElement(By.id("myTextArea"));
assertEquals(expectedString, textArea.getAttribute("value"));
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI in project htmlunit by HtmlUnit.
the class Window3Test method scrollByEvents.
/**
* @throws Exception if the test fails
*/
@Test
@Alerts(DEFAULT = { "document", "body" }, IE = "document")
@HtmlUnitNYI(IE = { "document", "body" })
public void scrollByEvents() throws Exception {
final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + "<html>\n" + "<head>\n" + "<script>\n" + " function log(msg) {\n" + " var ta = document.getElementById('myTextArea');\n" + " ta.value += msg + '; ';\n" + " }\n" + " function test() {\n" + " document.addEventListener('scroll', function(e) { log(\"document\") });\n" + " window.scrollBy(10, 20);\n" + " }\n" + "</script>\n" + "</head>\n" + "<body onload='test()' onscroll='log(\"body\")'>\n" + " <div onscroll='log(\"div\")' style='height: 1000px;'></div>\n" + " <textarea id='myTextArea' cols='80' rows='30'></textarea>\n" + "</body>\n" + "</html>";
final WebDriver driver = loadPage2(html);
final WebElement textArea = driver.findElement(By.id("myTextArea"));
assertEquals(String.join("; ", getExpectedAlerts()) + "; ", textArea.getAttribute("value"));
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI in project htmlunit by HtmlUnit.
the class Window3Test method scrollToEvents.
/**
* @throws Exception if the test fails
*/
@Test
@Alerts(DEFAULT = { "document", "body" }, IE = "document")
@HtmlUnitNYI(IE = { "document", "body" })
public void scrollToEvents() throws Exception {
final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + "<html>\n" + "<head>\n" + "<script>\n" + " function log(msg) {\n" + " var ta = document.getElementById('myTextArea');\n" + " ta.value += msg + '; ';\n" + " }\n" + " function test() {\n" + " document.addEventListener('scroll', function(e) { log(\"document\") });\n" + " window.scrollTo(10, 20);\n" + " }\n" + "</script>\n" + "</head>\n" + "<body onload='test()' onscroll='log(\"body\")'>\n" + " <div onscroll='log(\"div\")' style='height: 1000px;'></div>\n" + " <textarea id='myTextArea' cols='80' rows='30'></textarea>\n" + "</body>\n" + "</html>";
final WebDriver driver = loadPage2(html);
final WebElement textArea = driver.findElement(By.id("myTextArea"));
assertEquals(String.join("; ", getExpectedAlerts()) + "; ", textArea.getAttribute("value"));
}
Aggregations