-
-
Notifications
You must be signed in to change notification settings - Fork 184
Expand file tree
/
Copy pathHtmlHtmlTest.java
More file actions
66 lines (60 loc) · 2.4 KB
/
HtmlHtmlTest.java
File metadata and controls
66 lines (60 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
* Copyright (c) 2002-2026 Gargoyle Software Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.htmlunit.html;
import org.htmlunit.SimpleWebTestCase;
import org.junit.jupiter.api.Test;
/**
* Tests for {@link HtmlHtml}.
*
* @author Marc Guillemot
* @author Ahmed Ashour
* @author Ronald Brill
*/
public class HtmlHtmlTest extends SimpleWebTestCase {
/**
* @throws Exception if the test fails
*/
@Test
public void attributes() throws Exception {
final String htmlContent = "<?xml version=\"1.0\"?>\n"
+ "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" "
+ "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
+ "<html xmlns='http://www.w3.org/1999/xhtml' lang='en' xml:lang='en'>\n"
+ "<head><title>test</title></head>\n"
+ "<body></body></html>";
final HtmlPage page = loadPage(htmlContent);
final HtmlHtml root = (HtmlHtml) page.getDocumentElement();
assertEquals("en", root.getLangAttribute());
assertEquals("en", root.getXmlLangAttribute());
}
/**
* Regression test for bug #921
* canonical XPath for html element was computed to "/html[2]" where a doctype
* was present.
* @throws Exception if the test fails
*/
@Test
public void canonicalXPath() throws Exception {
final String htmlContent = "<?xml version=\"1.0\"?>\n"
+ "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" "
+ "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
+ "<html xmlns='http://www.w3.org/1999/xhtml' lang='en' xml:lang='en'>\n"
+ "<head><title>test</title></head>\n"
+ "<body></body></html>";
final HtmlPage page = loadPage(htmlContent);
final HtmlHtml root = (HtmlHtml) page.getDocumentElement();
assertEquals("/html", root.getCanonicalXPath());
}
}