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.htmlunit.util.MimeType;
20 import org.junit.jupiter.api.Test;
21
22
23
24
25
26
27
28
29
30 public class HTMLObjectElement2Test extends WebDriverTestCase {
31
32
33
34
35 @Test
36 @Alerts({"[object HTMLFormElement]", "null"})
37 public void form() throws Exception {
38 final String html = DOCTYPE_HTML
39 + "<html>\n"
40 + "<body>\n"
41 + " <form>\n"
42 + " <object id='o1'></object>\n"
43 + "</form>\n"
44 + "<object id='o2'></object>\n"
45 + "<script>\n"
46 + LOG_TITLE_FUNCTION
47 + " log(document.getElementById('o1').form);\n"
48 + " log(document.getElementById('o2').form);\n"
49 + "</script>\n"
50 + "</body></html>";
51
52 loadPageVerifyTitle2(html);
53 }
54
55
56
57
58
59 @Test
60 @Alerts("[object XMLDocument]")
61 public void responseXML_htmlObject() throws Exception {
62 final String html = DOCTYPE_HTML
63 + "<html><head><script>\n"
64 + LOG_TITLE_FUNCTION
65 + " function test() {\n"
66 + " var xhr = new XMLHttpRequest();\n"
67 + " xhr.open('GET', 'foo.xml', false);\n"
68 + " xhr.send('');\n"
69 + " try {\n"
70 + " log(xhr.responseXML);\n"
71 + " } catch(e) { logEx(e); }\n"
72 + " }\n"
73 + "</script></head><body onload='test()'>\n"
74 + "</body></html>";
75
76 final String xml = "<html xmlns='http://www.w3.org/1999/xhtml'>\n"
77 + "<object classid='CLSID:test'/>\n"
78 + "</html>";
79
80 getMockWebConnection().setDefaultResponse(xml, MimeType.TEXT_XML);
81 loadPage2(html);
82 verifyTitle2(DEFAULT_WAIT_TIME, getWebDriver(), getExpectedAlerts());
83 }
84 }