|
16 | 16 |
|
17 | 17 | import java.util.List; |
18 | 18 |
|
| 19 | +import javax.net.ssl.SSLHandshakeException; |
| 20 | + |
19 | 21 | import org.htmlunit.MockWebConnection; |
20 | 22 | import org.htmlunit.SimpleWebTestCase; |
21 | 23 | import org.htmlunit.WebClient; |
22 | 24 | import org.htmlunit.html.FrameWindow; |
23 | 25 | import org.htmlunit.html.HtmlInlineFrame; |
24 | 26 | import org.htmlunit.html.HtmlPage; |
25 | 27 | import org.htmlunit.junit.BrowserRunner; |
| 28 | +import org.htmlunit.junit.annotation.Alerts; |
26 | 29 | import org.junit.Test; |
27 | 30 | import org.junit.runner.RunWith; |
28 | 31 |
|
@@ -137,4 +140,33 @@ public void removeFrameWindow() throws Exception { |
137 | 140 | frames = page.getFrames(); |
138 | 141 | assertTrue(frames.isEmpty()); |
139 | 142 | } |
| 143 | + |
| 144 | + /** |
| 145 | + * @throws Exception if the test fails |
| 146 | + */ |
| 147 | + @Test |
| 148 | + @Alerts({"", "2"}) |
| 149 | + public void iframeUrlInvalid() throws Exception { |
| 150 | + final String html = DOCTYPE_HTML |
| 151 | + + "<html>\n" |
| 152 | + + "<head>\n" |
| 153 | + + " <script>\n" |
| 154 | + + " function log(msg) { window.document.title += msg + '\\u00a7'; }\n" |
| 155 | + + " </script>\n" |
| 156 | + + "</head>\n" |
| 157 | + + "<body>\n" |
| 158 | + + " <iframe id='frame1' src='" + URL_SECOND + "' " |
| 159 | + + "onLoad='log(\"loaded\")' onError='log(\"error\")'></iframe>\n" |
| 160 | + + "</body>\n" |
| 161 | + + "</html>"; |
| 162 | + |
| 163 | + getMockWebConnection().setDefaultResponse(html); |
| 164 | + getMockWebConnection().setThrowable(URL_SECOND, new SSLHandshakeException("Test")); |
| 165 | + |
| 166 | + final String[] expectedAlerts = getExpectedAlerts(); |
| 167 | + final HtmlPage page = loadPage(html); |
| 168 | + assertEquals(expectedAlerts[0], page.getTitleText()); |
| 169 | + |
| 170 | + assertEquals(Integer.parseInt(expectedAlerts[1]), getMockWebConnection().getRequestCount()); |
| 171 | + } |
140 | 172 | } |
0 commit comments