View Javadoc
1   /*
2    * Copyright (c) 2002-2025 Gargoyle Software Inc.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * https://www.apache.org/licenses/LICENSE-2.0
8    *
9    * Unless required by applicable law or agreed to in writing, software
10   * distributed under the License is distributed on an "AS IS" BASIS,
11   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12   * See the License for the specific language governing permissions and
13   * limitations under the License.
14   */
15  package org.htmlunit.html;
16  
17  import org.htmlunit.WebDriverTestCase;
18  import org.htmlunit.junit.annotation.Alerts;
19  import org.junit.jupiter.api.Test;
20  
21  /**
22   * Tests for {@link HtmlRt}.
23   *
24   * @author Ahmed Ashour
25   * @author Ronald Brill
26   */
27  public class HtmlRtTest extends WebDriverTestCase {
28  
29      /**
30       * @throws Exception if the test fails
31       */
32      @Test
33      @Alerts(DEFAULT = {"", "inline", "ruby-text"},
34              FF = {"", "ruby-text", "ruby-text"},
35              FF_ESR = {"", "ruby-text", "ruby-text"})
36      public void defaultStyle() throws Exception {
37          final String html = DOCTYPE_HTML
38              + "<html><head>\n"
39              + "<script>\n"
40              + LOG_TITLE_FUNCTION
41              + "  function test() {\n"
42              + "    var e = document.createElement('rt');\n"
43              + "    check(e);\n"
44              + "    document.body.appendChild(e);\n"
45              + "    check(e);\n"
46              + "    check(document.getElementById('myId'));\n"
47              + "  }\n"
48  
49              + "  function check(e) {\n"
50              + "    var cs = window.getComputedStyle(e, null);\n"
51              + "    var disp = cs ? cs.display : null;\n"
52              + "    log(disp);\n"
53              + "  }\n"
54              + "</script>\n"
55              + "</head><body onload='test()'>\n"
56              + "<ruby>\n"
57              + "  <rt id='myId'></rt>\n"
58              + "</ruby>\n"
59              + "</body></html>";
60  
61          loadPageVerifyTitle2(html);
62      }
63  
64      /**
65       * @throws Exception if the test fails
66       */
67      @Test
68      @Alerts(DEFAULT = {"", "inline", "ruby-text"},
69              FF = {"", "ruby-text", "ruby-text"},
70              FF_ESR = {"", "ruby-text", "ruby-text"})
71      public void defaultStyleStandards() throws Exception {
72          final String html = DOCTYPE_HTML
73              + "<html><head>\n"
74              + "<script>\n"
75              + LOG_TITLE_FUNCTION
76              + "  function test() {\n"
77              + "    var e = document.createElement('rt');\n"
78              + "    check(e);\n"
79              + "    document.body.appendChild(e);\n"
80              + "    check(e);\n"
81              + "    check(document.getElementById('myId'));\n"
82              + "  }\n"
83  
84              + "  function check(e) {\n"
85              + "    var cs = window.getComputedStyle(e, null);\n"
86              + "    var disp = cs ? cs.display : null;\n"
87              + "    log(disp);\n"
88              + "  }\n"
89              + "</script>\n"
90              + "</head><body onload='test()'>\n"
91              + "<ruby>\n"
92              + "  <rt id='myId'></rt>\n"
93              + "</ruby>\n"
94              + "</body></html>";
95  
96          loadPageVerifyTitle2(html);
97      }
98  }