|
| 1 | +/* |
| 2 | + * Copyright (c) 2002-2026 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 whether the various {@code BrowserVersion}s still need dedicated |
| 23 | + * support for the legacy tags. |
| 24 | + * |
| 25 | + * @author Ronald Brill |
| 26 | + */ |
| 27 | +public class HtmlTagSupportTest extends WebDriverTestCase { |
| 28 | + |
| 29 | + /** |
| 30 | + * @throws Exception if the test fails |
| 31 | + */ |
| 32 | + @Test |
| 33 | + @Alerts({"BLINK - HTMLUnknownElement", "BLINK - HTMLUnknownElement"}) |
| 34 | + public void blink() throws Exception { |
| 35 | + tagSupport("blink"); |
| 36 | + } |
| 37 | + |
| 38 | + /** |
| 39 | + * @throws Exception if the test fails |
| 40 | + */ |
| 41 | + @Test |
| 42 | + @Alerts({"COMMENT - HTMLUnknownElement", "COMMENT - HTMLUnknownElement"}) |
| 43 | + public void comment() throws Exception { |
| 44 | + tagSupport("comment"); |
| 45 | + } |
| 46 | + |
| 47 | + /** |
| 48 | + * @throws Exception if the test fails |
| 49 | + */ |
| 50 | + @Test |
| 51 | + @Alerts({"DIV - HTMLDivElement", "DIV - HTMLDivElement"}) |
| 52 | + public void div() throws Exception { |
| 53 | + tagSupport("div"); |
| 54 | + } |
| 55 | + |
| 56 | + /** |
| 57 | + * The tag actually in question. |
| 58 | + * |
| 59 | + * @throws Exception if the test fails |
| 60 | + */ |
| 61 | + @Test |
| 62 | + @Alerts(DEFAULT = {"LAYER - HTMLElement", "LAYER - HTMLElement"}, |
| 63 | + FF = {"LAYER - HTMLUnknownElement", "LAYER - HTMLUnknownElement"}, |
| 64 | + FF_ESR = {"LAYER - HTMLUnknownElement", "LAYER - HTMLUnknownElement"}) |
| 65 | + public void layer() throws Exception { |
| 66 | + tagSupport("layer"); |
| 67 | + } |
| 68 | + |
| 69 | + /** |
| 70 | + * @throws Exception if the test fails |
| 71 | + */ |
| 72 | + @Test |
| 73 | + @Alerts({"ILAYER - HTMLUnknownElement", "ILAYER - HTMLUnknownElement"}) |
| 74 | + public void ilayer() throws Exception { |
| 75 | + tagSupport("ilayer"); |
| 76 | + } |
| 77 | + |
| 78 | + /** |
| 79 | + * @throws Exception if the test fails |
| 80 | + */ |
| 81 | + @Test |
| 82 | + @Alerts({"LISTING - HTMLPreElement", "LISTING - HTMLPreElement"}) |
| 83 | + public void listing() throws Exception { |
| 84 | + tagSupport("listing"); |
| 85 | + } |
| 86 | + |
| 87 | + /** |
| 88 | + * @throws Exception if the test fails |
| 89 | + */ |
| 90 | + @Test |
| 91 | + @Alerts({"MULTICOL - HTMLUnknownElement", "MULTICOL - HTMLUnknownElement"}) |
| 92 | + public void multicol() throws Exception { |
| 93 | + tagSupport("multicol"); |
| 94 | + } |
| 95 | + |
| 96 | + /** |
| 97 | + * @throws Exception if the test fails |
| 98 | + */ |
| 99 | + @Test |
| 100 | + @Alerts({"NEXTID - HTMLUnknownElement", "NEXTID - HTMLUnknownElement"}) |
| 101 | + public void nextid() throws Exception { |
| 102 | + tagSupport("nextid"); |
| 103 | + } |
| 104 | + |
| 105 | + /** |
| 106 | + * @throws Exception if the test fails |
| 107 | + */ |
| 108 | + @Test |
| 109 | + @Alerts(DEFAULT = {"NOLAYER - HTMLElement", "NOLAYER - HTMLElement"}, |
| 110 | + FF = {"NOLAYER - HTMLUnknownElement", "NOLAYER - HTMLUnknownElement"}, |
| 111 | + FF_ESR = {"NOLAYER - HTMLUnknownElement", "NOLAYER - HTMLUnknownElement"}) |
| 112 | + public void nolayer() throws Exception { |
| 113 | + tagSupport("nolayer"); |
| 114 | + } |
| 115 | + |
| 116 | + /** |
| 117 | + * @throws Exception if the test fails |
| 118 | + */ |
| 119 | + @Test |
| 120 | + @Alerts({"PLAINTEXT - HTMLElement", "PLAINTEXT - HTMLElement"}) |
| 121 | + public void plaintext() throws Exception { |
| 122 | + tagSupport("plaintext"); |
| 123 | + } |
| 124 | + |
| 125 | + /** |
| 126 | + * @throws Exception if the test fails |
| 127 | + */ |
| 128 | + @Test |
| 129 | + @Alerts({"SOUND - HTMLUnknownElement", "SOUND - HTMLUnknownElement"}) |
| 130 | + public void sound() throws Exception { |
| 131 | + tagSupport("sound"); |
| 132 | + } |
| 133 | + |
| 134 | + /** |
| 135 | + * @throws Exception if the test fails |
| 136 | + */ |
| 137 | + @Test |
| 138 | + @Alerts({"SPACER - HTMLUnknownElement", "SPACER - HTMLUnknownElement"}) |
| 139 | + public void spacer() throws Exception { |
| 140 | + tagSupport("spacer"); |
| 141 | + } |
| 142 | + |
| 143 | + /** |
| 144 | + * @throws Exception if the test fails |
| 145 | + */ |
| 146 | + @Test |
| 147 | + @Alerts({"XMP - HTMLPreElement", "XMP - HTMLPreElement"}) |
| 148 | + public void xmp() throws Exception { |
| 149 | + tagSupport("xmp"); |
| 150 | + } |
| 151 | + |
| 152 | + private void tagSupport(final String tagName) throws Exception { |
| 153 | + final String html = DOCTYPE_HTML |
| 154 | + + "<html>\n" |
| 155 | + + "<script>\n" |
| 156 | + + LOG_TITLE_FUNCTION |
| 157 | + + " function test() {\n" |
| 158 | + + " let el = document.getElementById('t');\n" |
| 159 | + + " log(el.tagName + ' - ' + el.constructor.name);\n" |
| 160 | + |
| 161 | + + " el = document.createElement('" + tagName + "');\n" |
| 162 | + + " log(el.tagName + ' - ' + el.constructor.name);\n" |
| 163 | + + " }\n" |
| 164 | + + "</script>\n" |
| 165 | + + "</head><body onload='test()'>\n" |
| 166 | + + "<" + tagName + " id='t'></" + tagName + ">" |
| 167 | + + "</body></html>"; |
| 168 | + |
| 169 | + loadPageVerifyTitle2(html); |
| 170 | + } |
| 171 | +} |
0 commit comments