Skip to content

Commit ce4a6d1

Browse files
committed
migrate tests to WebDriver
1 parent df25371 commit ce4a6d1

2 files changed

Lines changed: 39 additions & 21 deletions

File tree

src/test/java/org/htmlunit/html/HtmlPage3Test.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,4 +720,43 @@ public void metaWithNamespace() throws Exception {
720720

721721
loadPageVerifyTitle2(content);
722722
}
723+
724+
/**
725+
* @throws Exception if an error occurs
726+
*/
727+
@Test
728+
@Alerts({"sync-executed", "async-executed"})
729+
public void asyncScriptExecuted() throws Exception {
730+
final String content = DOCTYPE_HTML
731+
+ "<html><head>\n"
732+
+ "<script async src='async.js'></script>\n"
733+
+ "<script>document.title += 'sync-executed§';</script>\n"
734+
+ "</head>"
735+
+ "<body></body>"
736+
+ "</html>";
737+
738+
getMockWebConnection().setResponse(new URL(URL_FIRST, "async.js"),
739+
"document.title += 'async-executed§';", MimeType.TEXT_JAVASCRIPT);
740+
741+
loadPageVerifyTitle2(content);
742+
}
743+
744+
/**
745+
* @throws Exception if an error occurs
746+
*/
747+
@Test
748+
@Alerts("async-executed")
749+
public void asyncScriptExecutedWithoutSyncScript() throws Exception {
750+
final String content = DOCTYPE_HTML
751+
+ "<html><head>\n"
752+
+ "<script async src='async.js'></script>\n"
753+
+ "</head>"
754+
+ "<body></body>"
755+
+ "</html>";
756+
757+
getMockWebConnection().setResponse(new URL(URL_FIRST, "async.js"),
758+
"document.title += 'async-executed§';", MimeType.TEXT_JAVASCRIPT);
759+
760+
loadPageVerifyTitle2(content);
761+
}
723762
}

src/test/java/org/htmlunit/html/HtmlPageTest.java

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1974,25 +1974,4 @@ public void getBaseUrl() throws Exception {
19741974
page = loadPage(getBrowserVersion(), html, null, new URL(URL_FIRST + path));
19751975
assertEquals(URL_FIRST.toExternalForm() + path, page.getBaseURL().toExternalForm());
19761976
}
1977-
1978-
/**
1979-
* @throws Exception if an error occurs
1980-
*/
1981-
@Test
1982-
public void asyncScriptExecutedWithoutEventHandlers() throws Exception {
1983-
final String html = DOCTYPE_HTML
1984-
+ "<html><head>\n"
1985-
+ "<script async src='async.js'></script>\n"
1986-
+ "</head><body></body></html>";
1987-
1988-
final WebClient client = getWebClient();
1989-
final MockWebConnection webConnection = new MockWebConnection();
1990-
webConnection.setDefaultResponse(html);
1991-
webConnection.setResponse(new URL(URL_FIRST, "async.js"),
1992-
"document.title = 'async-executed';", "text/javascript");
1993-
client.setWebConnection(webConnection);
1994-
1995-
final HtmlPage page = client.getPage(URL_FIRST);
1996-
assertEquals("async-executed", page.getTitleText());
1997-
}
19981977
}

0 commit comments

Comments
 (0)