5 return external.ok(b, m);
8 function test_removeAttribute(e) {
9 ok(e.removeAttribute('nonexisting') === false,
"removeAttribute('nonexisting') didn't return false");
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");
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");
23 function test_select_index() {
24 var s = document.getElementById(
"sel");
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]);
34 function test_createDocumentFragment() {
35 var fragment = document.createDocumentFragment();
37 ok(typeof(fragment) ===
"object",
"typeof(fragmend) = " + typeof(fragment));
38 ok(fragment.nodeType ===
11,
"fragment.nodeType = " + fragment.nodeType);
39 ok(fragment.nodeName ===
"#document-fragment",
"fragment.nodeName = " + fragment.nodeName);
41 var cloned = fragment.cloneNode(true);
42 ok(cloned.nodeType ===
11,
"cloned.nodeType = " + cloned.nodeType);
43 ok(cloned.nodeName ===
"#document-fragment",
"cloned.nodeName = " + cloned.nodeName);
46 function test_document_name_as_index() {
47 document.body.innerHTML = '
<form name=
"formname"></form>';
48 var e = document.getElementById(
"formname");
51 ok(document.formname === e,
"document.formname != getElementById('formname')");
52 ok(
"formname" in document,
"formname' is not in document");
54 document.body.removeChild(e);
56 ok(document.formname === undefined,
"document.formname is not undefined");
57 ok(!(
"formname" in document),
"formname' is in document");
59 document.body.innerHTML = '
<form id=
"formid"></form>';
60 var e = document.getElementById(
"formid");
62 ok(!(
"formid" in document),
"formid is in document");
64 document.body.innerHTML = '
<form name=
"formname"></form>';
65 ok(
"formname" in window,
"formname' is not in window");
66 ok(typeof(window.formname) ===
"object",
"typeof(window.formname) = " + typeof(window.formname));
68 ok(window.formname ===
1,
"window.formname = " + window.formname);
70 ok(window.formname ===
2,
"window.formname = " + window.formname);
72 document.body.innerHTML = '
<iframe id=
"iframeid"></iframe>';
73 ok(
"iframeid" in window,
"iframeid is not in window");
74 e = document.getElementById(
"iframeid");
76 ok(iframeid != e,
"iframeid == e");
77 ok(iframeid.frameElement === e,
"frameid != e.contentWindow");
80 function test_remove_style_attribute() {
81 var s = document.body.style, b;
84 b = s.removeAttribute(
"somevar",
1);
85 ok(b,
"removeAttribute returned " + b +
" expected true");
86 b = s.removeAttribute(
"somevar",
1);
87 ok(b === false,
"removeAttribute returned " + b +
" expected false");
90 function test_clone_node() {
93 elem = document.getElementById(
"divid");
94 elem.style.filter =
"alpha(opacity=50)";
95 ok(elem.style.filter ===
"alpha(opacity=50)",
"elem.style.filter = " + elem.style.filter);
97 cloned = elem.cloneNode(true);
98 ok(cloned.style.filter ===
"alpha(opacity=50)",
"cloned.style.filter = " + cloned.style.filter);
101 function test_setAttribute() {
104 document.body.innerHTML = '
<input id=
"inputid"></input>';
105 input = document.getElementById(
"inputid");
106 ok(input.checked === false,
"input.checked = " + input.checked);
108 input.setAttribute(
"checked",
"test");
109 ok(input.checked === true,
"input.checked = " + input.checked);
111 input.setAttribute(
"checked",
0);
112 ok(input.checked === false,
"input.checked = " + input.checked);
114 input.setAttribute(
"checked",
"");
115 ok(input.checked === false,
"input.checked = " + input.checked);
118 function test_attribute_collection() {
121 document.body.innerHTML = '
<div id=
"divid" class=
"test"></div>';
122 div = document.getElementById(
"divid");
124 attr = div.attributes[
"dir"];
125 ok(attr === div.attributes[
"dir"],
"attr !== div.attributes['dir']");
128 function test_getter_call() {
129 document.body.innerHTML = '
<div id=
"divid"></div>';
131 var e = document.getElementById(
"divid");
133 e.myfunc = function(x) { this.myfunc_called = x; };
135 ok(e.myfunc_called ===
"test",
"e.myfunc_called = " + e.myfunc_called);
137 e.onmousedown = function(x) { this.onmousedown_called = x; };
138 e.onmousedown(
"test");
139 ok(e.onmousedown_called ===
"test",
"e.onmousedown_called = " + e.onmousedown_called);
142 function test_arg_conv() {
143 /* this call would throw if the argument wasn't converted by JScript */
144 window.clearInterval(
"");
146 navigator.javaEnabled();
149 function test_override_functions() {
150 function override_func() { return
"test"; }
152 ok(typeof(window.showModalDialog) ===
"object",
"typeof(window.showModalDialog) = " + typeof(window.showModalDialog));
153 window.showModalDialog = override_func;
154 ok(window.showModalDialog === override_func,
"window.showModalDialog != override_func");
155 ok(typeof(window.showModalDialog) ===
"function",
"typeof(window.showModalDialog) = " + typeof(window.showModalDialog));
157 document.body.innerHTML = '
<div id=
"divid"></div>';
158 var div = document.getElementById(
"divid");
159 ok(typeof(div.addBehavior) ===
"object",
"typeof(div.addBehavior) = " + typeof(div.addBehavior));
160 div.addBehavior = override_func;
161 ok(div.addBehavior === override_func,
"div.addBehavior != override_func");
162 ok(typeof(div.addBehavior) ===
"function",
"typeof(div.addBehavior) = " + typeof(div.addBehavior));
164 var tmp = div.addBehavior();
165 ok(tmp ===
"test",
"div.addBehavior() = " + tmp);
168 function test_forin() {
171 document.body.innerHTML = '
<a id=
"aid"></a>';
173 for(var x in document.getElementById(
"aid")) {
177 ok(cnt
> 100,
"cnt = " + cnt);
180 var globalVar = false;
182 function runTests() {
184 ok(obj === window.obj,
"obj !== window.obj");
186 ok(typeof(divid) ===
"object",
"typeof(divid) = " + typeof(divid));
188 test_removeAttribute(document.getElementById(
"divid"));
189 test_removeAttribute(document.body);
192 test_createDocumentFragment();
193 test_document_name_as_index();
194 test_remove_style_attribute();
197 test_attribute_collection();
199 test_override_functions();
202 var r = window.execScript(
"globalVar = true;");
203 ok(r === undefined,
"execScript returned " + r);
204 ok(globalVar === true,
"globalVar = " + globalVar);
211 ok(false,
"got exception");
214 external.reportSuccess();
217 <body onload=
"runTest();">
218 <div id=
"divid"></div>
220 <option>opt1
</option>
221 <option>opt2
</option>