content/xul/document/test/test_bug403868.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/xul/document/test/test_bug403868.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,83 @@
     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" type="text/css"?>
     1.7 +<!--
     1.8 +https://bugzilla.mozilla.org/show_bug.cgi?id=403868
     1.9 +-->
    1.10 +<window title="Mozilla Bug 403868"
    1.11 +  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    1.12 +  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
    1.13 +
    1.14 +  <!-- test results are displayed in the html:body -->
    1.15 +  <body xmlns="http://www.w3.org/1999/xhtml">
    1.16 +  <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=403868"
    1.17 +     target="_blank">Mozilla Bug 403868</a>
    1.18 +    <div id="content" style="display: none"/>
    1.19 +  </body>
    1.20 +
    1.21 +  <!-- test code goes here -->
    1.22 +  <script type="application/javascript"><![CDATA[
    1.23 +
    1.24 +    /** Test for Bug 403868 **/
    1.25 +function createSpan(id, insertionPoint) {
    1.26 +  var s = document.createElementNS("http://www.w3.org/1999/xhtml", "span");
    1.27 +  s.id = id;
    1.28 +  $("content").insertBefore(s, insertionPoint);
    1.29 +  return s;
    1.30 +}
    1.31 +
    1.32 +var s1a = createSpan("test1", null);
    1.33 +is(document.getElementById("test1"), s1a,
    1.34 +   "Only one span with id=test1 in the tree; should work!");
    1.35 +
    1.36 +var s2a = createSpan("test1", null);
    1.37 +is(document.getElementById("test1"), s1a,
    1.38 +   "Appending span with id=test1 doesn't change which one comes first");
    1.39 +
    1.40 +var s3a = createSpan("test1", s2a);
    1.41 +is(document.getElementById("test1"), s1a,
    1.42 +   "Inserting span with id=test1 not at the beginning; doesn't matter");
    1.43 +
    1.44 +var s4a = createSpan("test1", s1a);
    1.45 +is(document.getElementById("test1"), s4a,
    1.46 +   "Inserting span with id=test1 at the beginning changes which one is first");
    1.47 +
    1.48 +s4a.parentNode.removeChild(s4a);
    1.49 +is(document.getElementById("test1"), s1a,
    1.50 +   "First-created span with id=test1 is first again");
    1.51 +
    1.52 +s1a.parentNode.removeChild(s1a);
    1.53 +is(document.getElementById("test1"), s3a,
    1.54 +   "Third-created span with id=test1 is first now");
    1.55 +
    1.56 +// Start the id hashtable
    1.57 +for (var i = 0; i < 256; ++i) {
    1.58 +  document.getElementById("no-such-id-in-the-document" + i);
    1.59 +}
    1.60 +
    1.61 +var s1b = createSpan("test2", null);
    1.62 +is(document.getElementById("test2"), s1b,
    1.63 +   "Only one span with id=test2 in the tree; should work!");
    1.64 +
    1.65 +var s2b = createSpan("test2", null);
    1.66 +is(document.getElementById("test2"), s1b,
    1.67 +   "Appending span with id=test2 doesn't change which one comes first");
    1.68 +
    1.69 +var s3b = createSpan("test2", s2b);
    1.70 +is(document.getElementById("test2"), s1b,
    1.71 +   "Inserting span with id=test2 not at the beginning; doesn't matter");
    1.72 +
    1.73 +var s4b = createSpan("test2", s1b);
    1.74 +is(document.getElementById("test2"), s4b,
    1.75 +   "Inserting span with id=test2 at the beginning changes which one is first");
    1.76 +
    1.77 +s4b.parentNode.removeChild(s4b);
    1.78 +is(document.getElementById("test2"), s1b,
    1.79 +   "First-created span with id=test2 is first again");
    1.80 +
    1.81 +s1b.parentNode.removeChild(s1b);
    1.82 +is(document.getElementById("test2"), s3b,
    1.83 +   "Third-created span with id=test2 is first now");
    1.84 +
    1.85 +  ]]></script>
    1.86 +</window>

mercurial