tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bug120684.xhtml (2250B)


      1 <?xml version="1.0"?>
      2 <?xml-stylesheet type="text/css" href="chrome://global/skin"?>
      3 <?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
      4 <!--
      5 https://bugzilla.mozilla.org/show_bug.cgi?id=120684
      6 -->
      7 <window title="Mozilla Bug 120684"
      8        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
      9  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
     10 
     11  <!-- test results are displayed in the html:body -->
     12  <body xmlns="http://www.w3.org/1999/xhtml">
     13  <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=120684"
     14     target="_blank">Mozilla Bug 120684</a>
     15  </body>
     16 
     17  <!-- test code goes here -->
     18  <script type="application/javascript">
     19  <![CDATA[
     20  /** Test for Bug 120684 */
     21 
     22  var list = new ChromeNodeList();
     23  is(list.length, 0, "Length should be initially 0.");
     24 
     25  ok(NodeList.isInstance(list), "ChromeNodeList object should be an instance of NodeList.");
     26 
     27  try {
     28    list.append(document);
     29    ok(false, "should have throw!");
     30  } catch(ex) {
     31    ok(true, "ChromeNodeList supports only nsIContent objects for now.");
     32  }
     33 
     34  try {
     35    list.remove(document);
     36    ok(false, "should have throw!");
     37  } catch(ex) {
     38    ok(true, "ChromeNodeList supports only nsIContent objects for now.");
     39  }
     40  is(list.length, 0, "Length should be 0.");
     41 
     42  list.append(document.documentElement);
     43  is(list.length, 1, "Length should be 1.");
     44  is(list[0], document.documentElement);
     45  is(list[1], undefined);
     46 
     47  // Removing element which isn't in the list shouldn't do anything.
     48  list.remove(document.createXULElement("foo"));
     49  is(list.length, 1, "Length should be 1.");
     50  is(list[0], document.documentElement);
     51 
     52  list.remove(document.documentElement);
     53  is(list.length, 0, "Length should be 0.");
     54  is(list[0], undefined);
     55 
     56  var e1 = document.createXULElement("foo");
     57  var e2 = document.createXULElement("foo");
     58  var e3 = document.createXULElement("foo");
     59 
     60  list.append(e1);
     61  list.append(e2);
     62  list.append(e3);
     63 
     64  is(list[0], e1);
     65  is(list[1], e2);
     66  is(list[2], e3);
     67  is(list.length, 3);
     68 
     69  list.remove(e2);
     70  is(list[0], e1);
     71  is(list[1], e3);
     72  is(list[2], undefined);
     73  is(list.length, 2);
     74 
     75  // A leak test.
     76  list.expando = list;
     77 
     78  ]]>
     79  </script>
     80 </window>