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.BrowserRunner;
21 import org.htmlunit.junit.annotation.Alerts;
22 import org.junit.Test;
23 import org.junit.runner.RunWith;
24
25
26
27
28
29
30
31 @RunWith(BrowserRunner.class)
32 public class Popup2Test extends WebDriverTestCase {
33
34
35
36
37
38 @Test
39 @Alerts("TypeError")
40 public void popup() throws Exception {
41 final String html = DOCTYPE_HTML
42 + "<html><head></title><body>\n"
43 + "<script>\n"
44 + LOG_TITLE_FUNCTION
45 + " try {\n"
46 + " var oPopup = window.createPopup();\n"
47 + " var oPopupBody = oPopup.document.body;\n"
48 + " oPopupBody.innerHTML = 'bla bla';\n"
49 + " oPopup.show(100, 100, 200, 50, document.body);\n"
50 + " log('done');\n"
51 + " } catch(e) { logEx(e); }\n"
52 + "</script>\n"
53 + "</body></html>";
54
55 loadPageVerifyTitle2(html);
56 }
57
58
59
60
61
62
63 @Test
64 @Alerts("TypeError")
65 public void popupBodyStyle() throws Exception {
66 final String html = DOCTYPE_HTML
67 + "<html><head><body>\n"
68 + "<script language='javascript'>\n"
69 + LOG_TITLE_FUNCTION
70 + " try {\n"
71 + " popup = window.createPopup();\n"
72 + " popupBody = popup.document.body;\n"
73 + " popupBody.style.backgroundColor = '#7f7fff';\n"
74 + " log('done');\n"
75 + " } catch(e) { logEx(e); }\n"
76 + "</script>\n"
77 + "</body></html>";
78
79 loadPageVerifyTitle2(html);
80 }
81 }