2 <?xml-stylesheet href=
"chrome://global/skin" type=
"text/css"?>
3 <?xml-stylesheet href=
"chrome://mochikit/content/tests/SimpleTest/test.css"
5 <window title=
"Test nodelists from chrome"
6 xmlns=
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
7 <script src=
"chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
9 <!-- test results are displayed in the html:body -->
10 <body xmlns=
"http://www.w3.org/1999/xhtml">
13 <!-- test code goes here -->
14 <script type=
"application/javascript"><![CDATA[
15 SimpleTest.waitForExplicitFinish();
18 var win = $('ifr').contentWindow;
19 var list = win.document.getElementsByTagName('p');
20 is(list.length,
3,
"can get the length");
21 ok(HTMLParagraphElement.isInstance(list[
0]),
"can get list[0]");
22 is(list[
0], list.item(
0),
"list.item works");
23 is(list.item, list.item,
"don't recreate functions for each get");
26 ok(HTMLParagraphElement.isInstance(list[
2]),
"list[2] exists");
27 ok(
"2" in list,
"in operator works");
29 is(win.document.body.removeChild(win.document.body.lastChild), list2,
"remove last paragraph element");
30 ok(!(
"2" in list),
"in operator doesn't see phantom element");
31 is(list[
2], undefined,
"no node there!");
33 var optionList = win.document.createElement(
"select").options;
34 var option = win.document.createElement(
"option");
35 optionList[
0] = option;
36 is(optionList.item(
0), option,
"Creators work");
38 option = win.document.createElement(
"option");
39 optionList[
0] = option;
40 is(optionList.item(
0), option,
"Setters work");
47 src=
"http://mochi.test:8888/tests/js/xpconnect/tests/mochitest/file_nodelists.html"