use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver in project htmlunit by HtmlUnit.
the class ConsoleTest method assertString.
/**
* @throws Exception if the test fails
*/
@Test
@BuggyWebDriver
public void assertString() throws Exception {
final String html = "<html>\n" + "<body>\n" + "<script>\n" + " number = 1;\n" + " console.assert(number % 2 === 0, 'the # is not even');\n" + "</script>\n" + "</body></html>";
final WebDriver driver = loadPage2(html);
final Logs logs = driver.manage().logs();
final LogEntries logEntries = logs.get(LogType.BROWSER);
final List<LogEntry> logEntryList = logEntries.getAll();
assertEquals(1, logEntryList.size());
final LogEntry logEntry = logEntryList.get(0);
assertTrue(logEntry.getMessage(), logEntry.getMessage().contains("Assertion failed: the # is not even"));
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver in project htmlunit by HtmlUnit.
the class ConsoleTest method errorCall.
/**
* @throws Exception if the test fails
*/
@Test
@BuggyWebDriver
public void errorCall() throws Exception {
final String html = "<html>\n" + "<body>\n" + "<script>\n" + " function foo() {\n" + " (undefined || console.error)('he ho');\n" + " }\n" + " foo();\n" + "</script>\n" + "</body></html>";
final WebDriver driver = loadPage2(html);
final Logs logs = driver.manage().logs();
final LogEntries logEntries = logs.get(LogType.BROWSER);
final List<LogEntry> logEntryList = logEntries.getAll();
assertEquals(1, logEntryList.size());
final LogEntry logEntry = logEntryList.get(0);
final String logMsg = logEntry.getMessage();
System.out.println(logMsg);
assertTrue(logMsg, logMsg.contains("he ho"));
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver in project htmlunit by HtmlUnit.
the class ConsoleTest method assertParams.
/**
* @throws Exception if the test fails
*/
@Test
@BuggyWebDriver
public void assertParams() throws Exception {
final String html = "<html>\n" + "<body>\n" + "<script>\n" + " console.assert(false, 'the word is %s', 'foo');\n" + "</script>\n" + "</body></html>";
final WebDriver driver = loadPage2(html);
final Logs logs = driver.manage().logs();
final LogEntries logEntries = logs.get(LogType.BROWSER);
final List<LogEntry> logEntryList = logEntries.getAll();
assertEquals(1, logEntryList.size());
final LogEntry logEntry = logEntryList.get(0);
assertTrue(logEntry.getMessage(), logEntry.getMessage().contains("Assertion failed: the word is foo"));
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver in project htmlunit by HtmlUnit.
the class XMLHttpRequest2Test method xhrCallbackBeforeTimeout.
/**
* Ensures that XHR callback is executed before a timeout, even if it is time
* to execute this one.
* @throws Exception if an error occurs
*/
@Test
@Alerts("hello in timeout")
@BuggyWebDriver(FF_ESR = "in timeouthello", FF = "in timeouthello", IE = "in timeouthello")
public // IEDriver catches "in timeout", "hello" but real IE gets the correct order
void xhrCallbackBeforeTimeout() throws Exception {
final String html = "<html><head><script>\n" + "function wait() {\n" + " var xhr = new XMLHttpRequest();\n" + " xhr.open('GET', '/delay200/foo.txt', false);\n" + " xhr.send('');\n" + "}\n" + "function doTest() {\n" + " setTimeout(function() { document.title += ' in timeout'; }, 5);\n" + " wait();\n" + " var xhr2 = new XMLHttpRequest();\n" + " var handler = function() {\n" + " if (xhr2.readyState == 4)\n" + " document.title += xhr2.responseText;\n" + " }\n" + " xhr2.onreadystatechange = handler;\n" + " xhr2.open('GET', '/foo.txt', true);\n" + " xhr2.send('');\n" + " wait();\n" + "}\n" + "setTimeout(doTest, 10);\n" + "</script></head><body></body></html>";
getMockWebConnection().setDefaultResponse("hello", MimeType.TEXT_PLAIN);
final WebDriver driver = loadPage2(html);
assertTitle(driver, getExpectedAlerts()[0]);
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver in project htmlunit by HtmlUnit.
the class Window3Test method opener.
/**
* @throws Exception if the test fails
*/
@Test
@Alerts({ "null", "one", "two", "three" })
@BuggyWebDriver(IE = { "undefined", "one", "two", "three" })
public void opener() throws Exception {
final URL urlThird = new URL(URL_FIRST, "third/");
final String firstContent = HtmlPageTest.STANDARDS_MODE_PREFIX_ + "<html><head><title>First</title><script>\n" + "function test() {\n" + " alert(window.opener);\n" + " alert('one');\n" + " open('" + URL_SECOND + "', 'foo');\n" + "}\n" + "function calllog(text) {\n" + " alert(text);\n" + "}\n" + "</script></head><body onload='test()'>\n" + "</body></html>";
final String secondContent = HtmlPageTest.STANDARDS_MODE_PREFIX_ + "<html><head><title>Second</title><script>\n" + "function test() {\n" + " opener.calllog('two');\n" + " document.form1.submit();\n" + "}\n" + "</script></head><body onload='test()'>\n" + "<form name='form1' action='" + urlThird + "' method='post'><input type='submit'></form>\n" + "</body></html>";
final String thirdContent = HtmlPageTest.STANDARDS_MODE_PREFIX_ + "<html><head><title>Third</title><script>\n" + "function test() {\n" + " opener.calllog('three');\n" + "}\n" + "</script></head><body onload='test()'>\n" + "</body></html>";
getMockWebConnection().setResponse(URL_SECOND, secondContent);
getMockWebConnection().setResponse(urlThird, thirdContent);
final WebDriver driver = loadPageWithAlerts2(firstContent);
assertTitle(driver, "First");
}
Aggregations