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