mshtml: Added document fragment cloneNode implementation.
[wine] / dlls / mshtml / tests / jstest.html
1 <html>
2 <head>
3 <script>
4 function ok(b,m) {
5     return external.ok(b, m);
6 }
7
8 function test_removeAttribute(e) {
9     ok(e.removeAttribute('nonexisting') === false, "removeAttribute('nonexisting') didn't return false");
10
11     e.title = "title";
12     ok(e.removeAttribute('title') === true, "removeAttribute('title') didn't return true");
13     ok(e.title === "", "e.title = " + e.title);
14     ok(("title" in e) === true, "title is not in e");
15
16     e["myattr"] = "test";
17     ok(e.removeAttribute('myattr') === true, "removeAttribute('myattr') didn't return true");
18     ok(e["myattr"] === undefined, "e['myattr'] = " + e['myattr']);
19     ok(("myattr" in e) === false, "myattr is in e");
20
21 }
22
23 function test_select_index() {
24     var s = document.getElementById("sel");
25
26     ok("0" in s, "'0' is not in s");
27     ok(s[0].text === "opt1", "s[0].text = " + s[0].text);
28     ok("1" in s, "'1 is not in s");
29     ok(s[1].text === "opt2", "s[1].text = " + s[1].text);
30     ok("2" in s, "'2' is in s");
31     ok(s[2] === null, "s[2] = " + s[2]);
32 }
33
34 function test_createDocumentFragment() {
35     var fragment = document.createDocumentFragment();
36
37     ok(typeof(fragment) === "object", "typeof(fragmend) = " + typeof(fragment));
38     ok(fragment.parentWindow === window, "fragment.parentWindow != window");
39     ok(fragment.nodeType === 11, "fragment.nodeType = " + fragment.nodeType);
40     ok(fragment.nodeName === "#document-fragment", "fragment.nodeName = " + fragment.nodeName);
41
42     var cloned = fragment.cloneNode(true);
43     ok(cloned.parentWindow === window, "cloned.parentWindow != window");
44     ok(cloned.nodeType === 11, "cloned.nodeType = " + cloned.nodeType);
45     ok(cloned.nodeName === "#document-fragment", "cloned.nodeName = " + cloned.nodeName);
46 }
47
48 var globalVar = false;
49
50 function runTest() {
51     obj = new Object();
52     ok(obj === window.obj, "obj !== window.obj");
53
54     ok(typeof(divid) === "object", "typeof(divid) = " + typeof(divid));
55
56     test_removeAttribute(document.getElementById("divid"));
57     test_removeAttribute(document.body);
58     test_select_index();
59     test_createDocumentFragment();
60
61     var r = window.execScript("globalVar = true;");
62     ok(r === undefined, "execScript returned " + r);
63     ok(globalVar === true, "globalVar = " + globalVar);
64
65     external.reportSuccess();
66 }
67 </script>
68 <body onload="runTest();">
69 <div id="divid"></div>
70 <select id="sel">
71 <option>opt1</option>
72 <option>opt2</option>
73 </select>
74 </body>
75 </html>