1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.htmlunit.javascript.host.html;
16
17 import org.htmlunit.WebDriverTestCase;
18 import org.htmlunit.junit.annotation.Alerts;
19 import org.junit.jupiter.api.Test;
20
21
22
23
24
25
26
27
28 public class HTMLFrameSetElementTest extends WebDriverTestCase {
29
30
31
32
33 @Test
34 @Alerts({"20%,*", "*,*"})
35 public void cols() throws Exception {
36 final String html = DOCTYPE_HTML
37 + "<html><head>\n"
38 + "<script>"
39 + LOG_TITLE_FUNCTION
40 + "function test() {\n"
41 + " log(document.getElementById('fs').cols);\n"
42 + " document.getElementById('fs').cols = '*,*';\n"
43 + " log(document.getElementById('fs').cols);\n"
44 + "}\n"
45 + "</script></head>\n"
46 + "<frameset id='fs' cols='20%,*' onload='test()'>\n"
47 + " <frame name='left' src='about:blank' />\n"
48 + " <frame name='right' src='about:blank' />\n"
49 + "</frameset>\n"
50 + "</html>";
51
52 loadPageVerifyTitle2(html);
53 }
54
55
56
57
58 @Test
59 @Alerts({"20%,*", "*,*"})
60 public void rows() throws Exception {
61 final String framesetContent = DOCTYPE_HTML
62 + "<html><head></head>\n"
63 + "<frameset id='fs' rows='20%,*'>\n"
64 + " <frame name='top' src='" + URL_SECOND + "' />\n"
65 + " <frame name='bottom' src='about:blank' />\n"
66 + "</frameset>\n"
67 + "</html>";
68
69 final String frameContent = DOCTYPE_HTML
70 + "<html><head><title>TopFrame</title>\n"
71 + "<script>\n"
72 + LOG_WINDOW_NAME_FUNCTION
73 + "function doTest() {\n"
74 + " log(parent.document.getElementById('fs').rows);\n"
75 + " parent.document.getElementById('fs').rows = '*,*';\n"
76 + " log(parent.document.getElementById('fs').rows);\n"
77 + "}</script>\n"
78 + "</head>\n"
79 + "<body onload='doTest()'></body></html>";
80
81 getMockWebConnection().setResponse(URL_SECOND, frameContent);
82
83 loadPage2(framesetContent);
84 verifyWindowName2(getWebDriver(), getExpectedAlerts());
85 }
86
87
88
89
90 @Test
91 @Alerts({"<frameset id=\"fs\" onload=\"test()\"> </frameset>", "new"})
92 public void outerHTML() throws Exception {
93 final String html = DOCTYPE_HTML
94 + "<html><head>\n"
95 + "<script>\n"
96 + LOG_TITLE_FUNCTION
97 + "function test() {\n"
98 + " log(document.getElementById('fs').outerHTML);\n"
99 + " document.getElementById('fs').outerHTML = '<div id=\"new\">text<div>';\n"
100 + " log(document.getElementById('new').id);\n"
101 + "}\n"
102 + "</script></head>\n"
103 + "<frameset id='fs' onload='test()'>\n"
104 + "</frameset>\n"
105 + "</html>";
106
107 loadPageVerifyTitle2(html);
108 }
109 }