Skip to content

Commit

Permalink
improve test
Browse files Browse the repository at this point in the history
  • Loading branch information
rbri committed Jul 25, 2021
1 parent 0bf2dad commit ac7d97a
Show file tree
Hide file tree
Showing 80 changed files with 257 additions and 175 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ public void simpleScriptable() throws Exception {
final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_
+ "<html><head>\n"
+ "<script>\n"
+ LOG_TITLE_FUNCTION
+ " function test() {\n"
+ " alert(document.getElementById('myId'));\n"
+ " log(document.getElementById('myId'));\n"
+ " }\n"
+ "</script>\n"
+ "</head><body onload='test()'>\n"
Expand All @@ -53,7 +54,7 @@ public void simpleScriptable() throws Exception {
+ " </svg>\n"
+ "</body></html>";

final WebDriver driver = loadPageWithAlerts2(html);
final WebDriver driver = loadPageVerifyTitle2(html);
if (driver instanceof HtmlUnitDriver) {
final HtmlPage page = (HtmlPage) getWebWindowOf((HtmlUnitDriver) driver).getEnclosedPage();
assertTrue(SvgElement.class.isInstance(page.getElementById("myId")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ public void simpleScriptable() throws Exception {
final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_
+ "<html><head>\n"
+ "<script>\n"
+ LOG_TITLE_FUNCTION
+ " function test() {\n"
+ " alert(document.getElementById('myId'));\n"
+ " log(document.getElementById('myId'));\n"
+ " }\n"
+ "</script>\n"
+ "</head><body onload='test()'>\n"
Expand All @@ -53,7 +54,7 @@ public void simpleScriptable() throws Exception {
+ " </svg>\n"
+ "</body></html>";

final WebDriver driver = loadPageWithAlerts2(html);
final WebDriver driver = loadPageVerifyTitle2(html);
if (driver instanceof HtmlUnitDriver) {
final HtmlPage page = (HtmlPage) getWebWindowOf((HtmlUnitDriver) driver).getEnclosedPage();
assertTrue(SvgElement.class.isInstance(page.getElementById("myId")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ public void simpleScriptable() throws Exception {
final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_
+ "<html><head>\n"
+ "<script>\n"
+ LOG_TITLE_FUNCTION
+ " function test() {\n"
+ " alert(document.getElementById('myId'));\n"
+ " log(document.getElementById('myId'));\n"
+ " }\n"
+ "</script>\n"
+ "</head><body onload='test()'>\n"
Expand All @@ -53,7 +54,7 @@ public void simpleScriptable() throws Exception {
+ " </svg>\n"
+ "</body></html>";

final WebDriver driver = loadPageWithAlerts2(html);
final WebDriver driver = loadPageVerifyTitle2(html);
if (driver instanceof HtmlUnitDriver) {
final HtmlPage page = (HtmlPage) getWebWindowOf((HtmlUnitDriver) driver).getEnclosedPage();
if ("[object SVGAltGlyphElement]".equals(getExpectedAlerts()[0])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ public void simpleScriptable() throws Exception {
final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_
+ "<html><head>\n"
+ "<script>\n"
+ LOG_TITLE_FUNCTION
+ " function test() {\n"
+ " alert(document.getElementById('myId'));\n"
+ " log(document.getElementById('myId'));\n"
+ " }\n"
+ "</script>\n"
+ "</head><body onload='test()'>\n"
Expand All @@ -53,7 +54,7 @@ public void simpleScriptable() throws Exception {
+ " </svg>\n"
+ "</body></html>";

final WebDriver driver = loadPageWithAlerts2(html);
final WebDriver driver = loadPageVerifyTitle2(html);
if (driver instanceof HtmlUnitDriver) {
final HtmlPage page = (HtmlPage) getWebWindowOf((HtmlUnitDriver) driver).getEnclosedPage();
assertTrue(SvgAnchor.class.isInstance(page.getElementById("myId")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ public void simpleScriptable() throws Exception {
final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_
+ "<html><head>\n"
+ "<script>\n"
+ LOG_TITLE_FUNCTION
+ " function test() {\n"
+ " alert(document.getElementById('myId'));\n"
+ " log(document.getElementById('myId'));\n"
+ " }\n"
+ "</script>\n"
+ "</head><body onload='test()'>\n"
Expand All @@ -52,7 +53,7 @@ public void simpleScriptable() throws Exception {
+ " </svg>\n"
+ "</body></html>";

final WebDriver driver = loadPageWithAlerts2(html);
final WebDriver driver = loadPageVerifyTitle2(html);
if (driver instanceof HtmlUnitDriver) {
final HtmlPage page = (HtmlPage) getWebWindowOf((HtmlUnitDriver) driver).getEnclosedPage();
assertTrue(SvgElement.class.isInstance(page.getElementById("myId")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ public void simpleScriptable() throws Exception {
final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_
+ "<html><head>\n"
+ "<script>\n"
+ LOG_TITLE_FUNCTION
+ " function test() {\n"
+ " alert(document.getElementById('myId'));\n"
+ " log(document.getElementById('myId'));\n"
+ " }\n"
+ "</script>\n"
+ "</head><body onload='test()'>\n"
Expand All @@ -54,7 +55,7 @@ public void simpleScriptable() throws Exception {
+ " </svg>\n"
+ "</body></html>";

final WebDriver driver = loadPageWithAlerts2(html);
final WebDriver driver = loadPageVerifyTitle2(html);
if (driver instanceof HtmlUnitDriver) {
final HtmlPage page = (HtmlPage) getWebWindowOf((HtmlUnitDriver) driver).getEnclosedPage();
if ("[object SVGAnimateMotionElement]".equals(getExpectedAlerts()[0])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ public void simpleScriptable() throws Exception {
final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_
+ "<html><head>\n"
+ "<script>\n"
+ LOG_TITLE_FUNCTION
+ " function test() {\n"
+ " alert(document.getElementById('myId'));\n"
+ " log(document.getElementById('myId'));\n"
+ " }\n"
+ "</script>\n"
+ "</head><body onload='test()'>\n"
Expand All @@ -54,7 +55,7 @@ public void simpleScriptable() throws Exception {
+ " </svg>\n"
+ "</body></html>";

final WebDriver driver = loadPageWithAlerts2(html);
final WebDriver driver = loadPageVerifyTitle2(html);
if (driver instanceof HtmlUnitDriver) {
final HtmlPage page = (HtmlPage) getWebWindowOf((HtmlUnitDriver) driver).getEnclosedPage();
if ("[object SVGAnimateElement]".equals(getExpectedAlerts()[0])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ public void simpleScriptable() throws Exception {
final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_
+ "<html><head>\n"
+ "<script>\n"
+ LOG_TITLE_FUNCTION
+ " function test() {\n"
+ " alert(document.getElementById('myId'));\n"
+ " log(document.getElementById('myId'));\n"
+ " }\n"
+ "</script>\n"
+ "</head><body onload='test()'>\n"
Expand All @@ -54,7 +55,7 @@ public void simpleScriptable() throws Exception {
+ " </svg>\n"
+ "</body></html>";

final WebDriver driver = loadPageWithAlerts2(html);
final WebDriver driver = loadPageVerifyTitle2(html);
if (driver instanceof HtmlUnitDriver) {
final HtmlPage page = (HtmlPage) getWebWindowOf((HtmlUnitDriver) driver).getEnclosedPage();
if ("[object SVGAnimateTransformElement]".equals(getExpectedAlerts()[0])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ public void simpleScriptable() throws Exception {
final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_
+ "<html><head>\n"
+ "<script>\n"
+ LOG_TITLE_FUNCTION
+ " function test() {\n"
+ " alert(document.getElementById('myId'));\n"
+ " log(document.getElementById('myId'));\n"
+ " }\n"
+ "</script>\n"
+ "</head><body onload='test()'>\n"
Expand All @@ -53,7 +54,7 @@ public void simpleScriptable() throws Exception {
+ " </svg>\n"
+ "</body></html>";

final WebDriver driver = loadPageWithAlerts2(html);
final WebDriver driver = loadPageVerifyTitle2(html);
if (driver instanceof HtmlUnitDriver) {
final HtmlPage page = (HtmlPage) getWebWindowOf((HtmlUnitDriver) driver).getEnclosedPage();
assertTrue(SvgCircle.class.isInstance(page.getElementById("myId")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ public void simpleScriptable() throws Exception {
final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_
+ "<html><head>\n"
+ "<script>\n"
+ LOG_TITLE_FUNCTION
+ " function test() {\n"
+ " alert(document.getElementById('myId'));\n"
+ " log(document.getElementById('myId'));\n"
+ " }\n"
+ "</script>\n"
+ "</head><body onload='test()'>\n"
Expand All @@ -53,7 +54,7 @@ public void simpleScriptable() throws Exception {
+ " </svg>\n"
+ "</body></html>";

final WebDriver driver = loadPageWithAlerts2(html);
final WebDriver driver = loadPageVerifyTitle2(html);
if (driver instanceof HtmlUnitDriver) {
final HtmlPage page = (HtmlPage) getWebWindowOf((HtmlUnitDriver) driver).getEnclosedPage();
assertTrue(SvgClipPath.class.isInstance(page.getElementById("myId")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ public void simpleScriptable() throws Exception {
final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_
+ "<html><head>\n"
+ "<script>\n"
+ LOG_TITLE_FUNCTION
+ " function test() {\n"
+ " alert(document.getElementById('myId'));\n"
+ " log(document.getElementById('myId'));\n"
+ " }\n"
+ "</script>\n"
+ "</head><body onload='test()'>\n"
Expand All @@ -52,7 +53,7 @@ public void simpleScriptable() throws Exception {
+ " </svg>\n"
+ "</body></html>";

final WebDriver driver = loadPageWithAlerts2(html);
final WebDriver driver = loadPageVerifyTitle2(html);
if (driver instanceof HtmlUnitDriver) {
final HtmlPage page = (HtmlPage) getWebWindowOf((HtmlUnitDriver) driver).getEnclosedPage();
assertTrue(SvgElement.class.isInstance(page.getElementById("myId")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ public void simpleScriptable() throws Exception {
final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_
+ "<html><head>\n"
+ "<script>\n"
+ LOG_TITLE_FUNCTION
+ " function test() {\n"
+ " alert(document.getElementById('myId'));\n"
+ " log(document.getElementById('myId'));\n"
+ " }\n"
+ "</script>\n"
+ "</head><body onload='test()'>\n"
Expand All @@ -53,7 +54,7 @@ public void simpleScriptable() throws Exception {
+ " </svg>\n"
+ "</body></html>";

final WebDriver driver = loadPageWithAlerts2(html);
final WebDriver driver = loadPageVerifyTitle2(html);
if (driver instanceof HtmlUnitDriver) {
final HtmlPage page = (HtmlPage) getWebWindowOf((HtmlUnitDriver) driver).getEnclosedPage();
assertTrue(SvgElement.class.isInstance(page.getElementById("myId")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ public void simpleScriptable() throws Exception {
final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_
+ "<html><head>\n"
+ "<script>\n"
+ LOG_TITLE_FUNCTION
+ " function test() {\n"
+ " alert(document.getElementById('myId'));\n"
+ " log(document.getElementById('myId'));\n"
+ " }\n"
+ "</script>\n"
+ "</head><body onload='test()'>\n"
Expand All @@ -53,7 +54,7 @@ public void simpleScriptable() throws Exception {
+ " </svg>\n"
+ "</body></html>";

final WebDriver driver = loadPageWithAlerts2(html);
final WebDriver driver = loadPageVerifyTitle2(html);
if (driver instanceof HtmlUnitDriver) {
final HtmlPage page = (HtmlPage) getWebWindowOf((HtmlUnitDriver) driver).getEnclosedPage();
assertTrue(SvgDefs.class.isInstance(page.getElementById("myId")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ public void simpleScriptable() throws Exception {
final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_
+ "<html><head>\n"
+ "<script>\n"
+ LOG_TITLE_FUNCTION
+ " function test() {\n"
+ " alert(document.getElementById('myId'));\n"
+ " log(document.getElementById('myId'));\n"
+ " }\n"
+ "</script>\n"
+ "</head><body onload='test()'>\n"
Expand All @@ -53,7 +54,7 @@ public void simpleScriptable() throws Exception {
+ " </svg>\n"
+ "</body></html>";

final WebDriver driver = loadPageWithAlerts2(html);
final WebDriver driver = loadPageVerifyTitle2(html);
if (driver instanceof HtmlUnitDriver) {
final HtmlPage page = (HtmlPage) getWebWindowOf((HtmlUnitDriver) driver).getEnclosedPage();
assertTrue(SvgDesc.class.isInstance(page.getElementById("myId")));
Expand Down
30 changes: 16 additions & 14 deletions src/test/java/com/gargoylesoftware/htmlunit/svg/SvgElementTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ public void simpleScriptable() throws Exception {
final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_
+ "<html><head>\n"
+ "<script>\n"
+ LOG_TITLE_FUNCTION
+ " function test() {\n"
+ " alert(document.getElementById('myId'));\n"
+ " log(document.getElementById('myId'));\n"
+ " }\n"
+ "</script>\n"
+ "</head><body onload='test()'>\n"
Expand All @@ -56,7 +57,7 @@ public void simpleScriptable() throws Exception {
+ " </svg>\n"
+ "</body></html>";

final WebDriver driver = loadPageWithAlerts2(html);
final WebDriver driver = loadPageVerifyTitle2(html);
if (driver instanceof HtmlUnitDriver) {
final HtmlPage page = (HtmlPage) getWebWindowOf((HtmlUnitDriver) driver).getEnclosedPage();
if ("[object SVGElement]".equals(getExpectedAlerts()[0])) {
Expand All @@ -78,11 +79,11 @@ public void oninput() throws Exception {
HtmlPageTest.STANDARDS_MODE_PREFIX_
+ "<html>\n"
+ "<head>\n"
+ " <title>Test</title>\n"
+ " <script>\n"
+ LOG_TITLE_FUNCTION
+ " function test() {\n"
+ " var testNode = document.getElementById('myId');\n"
+ " alert('oninput' in document);\n"
+ " log('oninput' in document);\n"
+ " }\n"
+ " </script>\n"
+ "</head>\n"
Expand All @@ -93,7 +94,7 @@ public void oninput() throws Exception {
+ "</body>\n"
+ "</html>";

loadPageWithAlerts2(html);
loadPageVerifyTitle2(html);
}

/**
Expand All @@ -106,16 +107,16 @@ public void querySelectorAll() throws Exception {
HtmlPageTest.STANDARDS_MODE_PREFIX_
+ "<html>\n"
+ "<head>\n"
+ "<title>Test</title>\n"
+ "<style>\n"
+ " .red {color:#FF0000;}\n"
+ "</style>\n"
+ "<script>\n"
+ LOG_TITLE_FUNCTION
+ "function test() {\n"
+ " var testNode = document.getElementById('myId');\n"
+ " var redTags = testNode.querySelectorAll('.red');\n"
+ " alert(redTags.length);\n"
+ " alert(redTags.item(0).id);\n"
+ " log(redTags.length);\n"
+ " log(redTags.item(0).id);\n"
+ "}\n"
+ "</script>\n"
+ "</head>\n"
Expand All @@ -127,7 +128,7 @@ public void querySelectorAll() throws Exception {
+ " </svg>\n"
+ "</body></html>";

loadPageWithAlerts2(html);
loadPageVerifyTitle2(html);
}

/**
Expand All @@ -140,14 +141,14 @@ public void querySelector() throws Exception {
HtmlPageTest.STANDARDS_MODE_PREFIX_
+ "<html>\n"
+ "<head>\n"
+ "<title>Test</title>\n"
+ "<style>\n"
+ " .red {color:#FF0000;}\n"
+ "</style>\n"
+ "<script>\n"
+ LOG_TITLE_FUNCTION
+ "function test() {\n"
+ " var testNode = document.getElementById('myId');\n"
+ " alert(testNode.querySelector('.red'));\n"
+ " log(testNode.querySelector('.red'));\n"
+ "}\n"
+ "</script>\n"
+ "</head>\n"
Expand All @@ -159,7 +160,7 @@ public void querySelector() throws Exception {
+ " </svg>\n"
+ "</body></html>";

loadPageWithAlerts2(html);
loadPageVerifyTitle2(html);
}

/**
Expand All @@ -173,9 +174,10 @@ public void getBBox() throws Exception {
+ "<html>\n"
+ "<head>\n"
+ "<script>\n"
+ LOG_TITLE_FUNCTION
+ "function test() {\n"
+ " var testNode = document.getElementById('myId');\n"
+ " alert(testNode.getBBox());\n"
+ " log(testNode.getBBox());\n"
+ "}\n"
+ "</script>\n"
+ "</head>\n"
Expand All @@ -187,6 +189,6 @@ public void getBBox() throws Exception {
+ " </svg>\n"
+ "</body></html>";

loadPageWithAlerts2(html);
loadPageVerifyTitle2(html);
}
}
Loading

0 comments on commit ac7d97a

Please sign in to comment.