Skip to content

Commit fa52e09

Browse files
committed
add test case for issue #966
1 parent 0edd5bf commit fa52e09

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/test/java/org/htmlunit/javascript/host/html/HTMLIFrameElementTest.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,16 @@
1616

1717
import java.util.List;
1818

19+
import javax.net.ssl.SSLHandshakeException;
20+
1921
import org.htmlunit.MockWebConnection;
2022
import org.htmlunit.SimpleWebTestCase;
2123
import org.htmlunit.WebClient;
2224
import org.htmlunit.html.FrameWindow;
2325
import org.htmlunit.html.HtmlInlineFrame;
2426
import org.htmlunit.html.HtmlPage;
2527
import org.htmlunit.junit.BrowserRunner;
28+
import org.htmlunit.junit.annotation.Alerts;
2629
import org.junit.Test;
2730
import org.junit.runner.RunWith;
2831

@@ -137,4 +140,33 @@ public void removeFrameWindow() throws Exception {
137140
frames = page.getFrames();
138141
assertTrue(frames.isEmpty());
139142
}
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+
}
140172
}

0 commit comments

Comments
 (0)