1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.htmlunit.javascript.host;
16
17 import javax.swing.Popup;
18
19 import org.htmlunit.WebDriverTestCase;
20 import org.htmlunit.junit.annotation.Alerts;
21 import org.junit.jupiter.api.Test;
22
23
24
25
26
27
28
29 public class Popup2Test extends WebDriverTestCase {
30
31
32
33
34
35 @Test
36 @Alerts("TypeError")
37 public void popup() throws Exception {
38 final String html = DOCTYPE_HTML
39 + "<html><head></title><body>\n"
40 + "<script>\n"
41 + LOG_TITLE_FUNCTION
42 + " try {\n"
43 + " var oPopup = window.createPopup();\n"
44 + " var oPopupBody = oPopup.document.body;\n"
45 + " oPopupBody.innerHTML = 'bla bla';\n"
46 + " oPopup.show(100, 100, 200, 50, document.body);\n"
47 + " log('done');\n"
48 + " } catch(e) { logEx(e); }\n"
49 + "</script>\n"
50 + "</body></html>";
51
52 loadPageVerifyTitle2(html);
53 }
54
55
56
57
58
59
60 @Test
61 @Alerts("TypeError")
62 public void popupBodyStyle() throws Exception {
63 final String html = DOCTYPE_HTML
64 + "<html><head><body>\n"
65 + "<script language='javascript'>\n"
66 + LOG_TITLE_FUNCTION
67 + " try {\n"
68 + " popup = window.createPopup();\n"
69 + " popupBody = popup.document.body;\n"
70 + " popupBody.style.backgroundColor = '#7f7fff';\n"
71 + " log('done');\n"
72 + " } catch(e) { logEx(e); }\n"
73 + "</script>\n"
74 + "</body></html>";
75
76 loadPageVerifyTitle2(html);
77 }
78 }