1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/xpconnect/tests/chrome/test_nodelists.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,42 @@ 1.4 +<?xml version="1.0"?> 1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?> 1.6 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" 1.7 + type="text/css"?> 1.8 +<window title="Test nodelists from chrome" 1.9 + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 1.10 + <script type="application/javascript" 1.11 + src="chrome://mochikit/content/MochiKit/packed.js"></script> 1.12 + <script type="application/javascript" 1.13 + src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 1.14 + 1.15 + <!-- test results are displayed in the html:body --> 1.16 + <body xmlns="http://www.w3.org/1999/xhtml"> 1.17 + </body> 1.18 + 1.19 + <!-- test code goes here --> 1.20 + <script type="application/javascript"><![CDATA[ 1.21 + SimpleTest.waitForExplicitFinish(); 1.22 + 1.23 + function go() { 1.24 + var win = $('ifr').contentWindow; 1.25 + var list = win.document.getElementsByTagName('p'); 1.26 + is(list.length, 3, "can get the length"); 1.27 + ok(list[0].toString().indexOf("[object HTMLParagraphElement") >= 0, "can get list[0]"); 1.28 + is(list[0], list.item(0), "list.item works"); 1.29 + is(list.item, list.item, "don't recreate functions for each get"); 1.30 + 1.31 + var list2 = list[2]; 1.32 + ok(list[2].toString().indexOf("[object HTMLParagraphElement"), "list[2] exists"); 1.33 + ok("2" in list, "in operator works"); 1.34 + 1.35 + is(win.document.body.removeChild(win.document.body.lastChild), list2, "remove last paragraph element"); 1.36 + ok(!("2" in list), "in operator doesn't see phantom element"); 1.37 + is(list[2], undefined, "no node there!"); 1.38 + SimpleTest.finish(); 1.39 + } 1.40 + ]]></script> 1.41 + 1.42 + <iframe id="ifr" 1.43 + src="http://mochi.test:8888/tests/js/xpconnect/tests/mochitest/file_nodelists.html" 1.44 + onload="go()" /> 1.45 +</window>