use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI in project htmlunit by HtmlUnit.
the class Window3Test method scrollEvents.
/**
* @throws Exception if the test fails
*/
@Test
@Alerts(DEFAULT = { "document", "body" }, IE = "document")
@HtmlUnitNYI(IE = { "document", "body" })
public void scrollEvents() 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.scroll(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 ElementOwnPropertiesTest method collectStatistics.
private static void collectStatistics(final BrowserVersion browserVersion, final DefaultCategoryDataset dataset, final StringBuilder html, final int[] counts) {
final Method[] methods = ElementOwnPropertiesTest.class.getMethods();
Arrays.sort(methods, Comparator.comparing(Method::getName));
for (final Method method : methods) {
if (method.isAnnotationPresent(Test.class)) {
final Alerts alerts = method.getAnnotation(Alerts.class);
String[] expectedAlerts = {};
if (BrowserVersionClassRunner.isDefined(alerts.value())) {
expectedAlerts = alerts.value();
}
if (browserVersion == BrowserVersion.INTERNET_EXPLORER) {
expectedAlerts = BrowserVersionClassRunner.firstDefinedOrGiven(expectedAlerts, alerts.IE(), alerts.DEFAULT());
} else if (browserVersion == BrowserVersion.EDGE) {
expectedAlerts = BrowserVersionClassRunner.firstDefinedOrGiven(expectedAlerts, alerts.EDGE(), alerts.DEFAULT());
} else if (browserVersion == BrowserVersion.FIREFOX_ESR) {
expectedAlerts = BrowserVersionClassRunner.firstDefinedOrGiven(expectedAlerts, alerts.FF_ESR(), alerts.DEFAULT());
} else if (browserVersion == BrowserVersion.FIREFOX) {
expectedAlerts = BrowserVersionClassRunner.firstDefinedOrGiven(expectedAlerts, alerts.FF(), alerts.DEFAULT());
} else if (browserVersion == BrowserVersion.CHROME) {
expectedAlerts = BrowserVersionClassRunner.firstDefinedOrGiven(expectedAlerts, alerts.CHROME(), alerts.DEFAULT());
}
final HtmlUnitNYI htmlUnitNYI = method.getAnnotation(HtmlUnitNYI.class);
String[] nyiAlerts = {};
if (htmlUnitNYI != null) {
if (browserVersion == BrowserVersion.INTERNET_EXPLORER) {
nyiAlerts = BrowserVersionClassRunner.firstDefinedOrGiven(expectedAlerts, htmlUnitNYI.IE());
} else if (browserVersion == BrowserVersion.EDGE) {
nyiAlerts = BrowserVersionClassRunner.firstDefinedOrGiven(expectedAlerts, htmlUnitNYI.EDGE());
} else if (browserVersion == BrowserVersion.FIREFOX_ESR) {
nyiAlerts = BrowserVersionClassRunner.firstDefinedOrGiven(expectedAlerts, htmlUnitNYI.FF_ESR());
} else if (browserVersion == BrowserVersion.FIREFOX) {
nyiAlerts = BrowserVersionClassRunner.firstDefinedOrGiven(expectedAlerts, htmlUnitNYI.FF());
} else if (browserVersion == BrowserVersion.CHROME) {
nyiAlerts = BrowserVersionClassRunner.firstDefinedOrGiven(expectedAlerts, htmlUnitNYI.CHROME());
}
}
final List<String> realProperties = stringAsArray(String.join(",", expectedAlerts));
final List<String> simulatedProperties = stringAsArray(String.join(",", nyiAlerts));
final List<String> erroredProperties = new ArrayList<>(simulatedProperties);
erroredProperties.removeAll(realProperties);
final List<String> implementedProperties = new ArrayList<>(simulatedProperties);
implementedProperties.retainAll(realProperties);
counts[1] += implementedProperties.size();
counts[0] += realProperties.size();
htmlDetails(method.getName(), html, realProperties, implementedProperties, erroredProperties);
dataset.addValue(implementedProperties.size(), "Implemented", method.getName());
dataset.addValue(realProperties.size(), browserVersion.getNickname().replace("FF", "Firefox ").replace("IE", "Internet Explorer "), method.getName());
dataset.addValue(erroredProperties.size(), "Should not be implemented", method.getName());
}
}
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI in project htmlunit by HtmlUnit.
the class ElementPropertiesTest method collectStatistics.
private static void collectStatistics(final BrowserVersion browserVersion, final DefaultCategoryDataset dataset, final StringBuilder html, final int[] counts) {
final Method[] methods = ElementPropertiesTest.class.getMethods();
Arrays.sort(methods, Comparator.comparing(Method::getName));
for (final Method method : methods) {
if (method.isAnnotationPresent(Test.class)) {
final Alerts alerts = method.getAnnotation(Alerts.class);
String[] expectedAlerts = {};
if (BrowserVersionClassRunner.isDefined(alerts.value())) {
expectedAlerts = alerts.value();
}
if (browserVersion == BrowserVersion.INTERNET_EXPLORER) {
expectedAlerts = BrowserVersionClassRunner.firstDefinedOrGiven(expectedAlerts, alerts.IE(), alerts.DEFAULT());
} else if (browserVersion == BrowserVersion.EDGE) {
expectedAlerts = BrowserVersionClassRunner.firstDefinedOrGiven(expectedAlerts, alerts.EDGE(), alerts.DEFAULT());
} else if (browserVersion == BrowserVersion.FIREFOX_ESR) {
expectedAlerts = BrowserVersionClassRunner.firstDefinedOrGiven(expectedAlerts, alerts.FF_ESR(), alerts.DEFAULT());
} else if (browserVersion == BrowserVersion.FIREFOX) {
expectedAlerts = BrowserVersionClassRunner.firstDefinedOrGiven(expectedAlerts, alerts.FF(), alerts.DEFAULT());
} else if (browserVersion == BrowserVersion.CHROME) {
expectedAlerts = BrowserVersionClassRunner.firstDefinedOrGiven(expectedAlerts, alerts.CHROME(), alerts.DEFAULT());
}
final HtmlUnitNYI htmlUnitNYI = method.getAnnotation(HtmlUnitNYI.class);
String[] nyiAlerts = {};
if (htmlUnitNYI != null) {
if (browserVersion == BrowserVersion.INTERNET_EXPLORER) {
nyiAlerts = BrowserVersionClassRunner.firstDefinedOrGiven(expectedAlerts, htmlUnitNYI.IE());
} else if (browserVersion == BrowserVersion.EDGE) {
nyiAlerts = BrowserVersionClassRunner.firstDefinedOrGiven(expectedAlerts, htmlUnitNYI.EDGE());
} else if (browserVersion == BrowserVersion.FIREFOX_ESR) {
nyiAlerts = BrowserVersionClassRunner.firstDefinedOrGiven(expectedAlerts, htmlUnitNYI.FF_ESR());
} else if (browserVersion == BrowserVersion.FIREFOX) {
nyiAlerts = BrowserVersionClassRunner.firstDefinedOrGiven(expectedAlerts, htmlUnitNYI.FF());
} else if (browserVersion == BrowserVersion.CHROME) {
nyiAlerts = BrowserVersionClassRunner.firstDefinedOrGiven(expectedAlerts, htmlUnitNYI.CHROME());
}
}
final List<String> realProperties = stringAsArray(String.join(",", expectedAlerts));
final List<String> simulatedProperties = stringAsArray(String.join(",", nyiAlerts));
final List<String> erroredProperties = new ArrayList<>(simulatedProperties);
erroredProperties.removeAll(realProperties);
final List<String> implementedProperties = new ArrayList<>(simulatedProperties);
implementedProperties.retainAll(realProperties);
counts[1] += implementedProperties.size();
counts[0] += realProperties.size();
htmlDetails(method.getName(), html, realProperties, implementedProperties, erroredProperties);
dataset.addValue(implementedProperties.size(), "Implemented", method.getName());
dataset.addValue(realProperties.size(), browserVersion.getNickname().replace("FF", "Firefox ").replace("IE", "Internet Explorer "), method.getName());
dataset.addValue(erroredProperties.size(), "Should not be implemented", method.getName());
}
}
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI in project htmlunit by HtmlUnit.
the class HtmlSubmitInputTest method onclickDisables.
/**
* @throws Exception if the test fails
*/
@Test
@Alerts(DEFAULT = "1", IE = "2")
@HtmlUnitNYI(IE = "1")
public void onclickDisables() throws Exception {
final String html = "<html>\n" + "<head>\n" + " <script type='text/javascript'>\n" + " function submitForm() {\n" + " document.deliveryChannelForm.submitBtn.disabled = true;\n" + " }\n" + " </script>\n" + "</head>\n" + "<body>\n" + " <form action='test' name='deliveryChannelForm'>\n" + " <input name='submitBtn' type='submit' value='Save' title='Save' onclick='submitForm();'>\n" + " </form>\n" + "</body>\n" + "</html>";
getMockWebConnection().setDefaultResponse("");
final WebDriver webDriver = loadPage2(html);
final WebElement input = webDriver.findElement(By.name("submitBtn"));
input.click();
assertEquals(Integer.parseInt(getExpectedAlerts()[0]), getMockWebConnection().getRequestCount());
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI in project htmlunit by HtmlUnit.
the class XMLHttpRequestTest method enctypeBufferSource.
/**
* @throws Exception if the test fails
*/
@Test
@Alerts("null")
@HtmlUnitNYI(CHROME = "text/plain", EDGE = "text/plain", FF = "text/plain", FF_ESR = "text/plain", IE = "text/plain")
public void enctypeBufferSource() throws Exception {
final String html = "<html>\n" + "<head>\n" + "<script>\n" + LOG_TITLE_FUNCTION + "function doTest() {\n" + " try {\n" + " var typedArray = new Int8Array(8);\n" + " var xhr = new XMLHttpRequest();\n" + " xhr.open('post', '/test2', false);\n" + " xhr.send(typedArray);\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);
}
Aggregations