1 <html xmlns="http://www.w3.org/1999/xhtml">
3 https://bugzilla.mozilla.org/show_bug.cgi?id=403868
6 <title>Test for Bug 403868</title>
7 <script type="text/javascript" src="/MochiKit/packed.js"></script>
8 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=403868">Mozilla Bug 403868</a>
14 <div id="content" style="display: none">
18 <script class="testbody" type="text/javascript">
21 /** Test for Bug 403868 **/
22 function createSpan(id, insertionPoint) {
23 var s = document.createElementNS("http://www.w3.org/1999/xhtml", "span");
25 $("content").insertBefore(s, insertionPoint);
29 var s1a = createSpan("test1", null);
30 is(document.getElementById("test1"), s1a,
31 "Only one span with id=test1 in the tree; should work!");
33 var s2a = createSpan("test1", null);
34 is(document.getElementById("test1"), s1a,
35 "Appending span with id=test1 doesn't change which one comes first");
37 var s3a = createSpan("test1", s2a);
38 is(document.getElementById("test1"), s1a,
39 "Inserting span with id=test1 not at the beginning; doesn't matter");
41 var s4a = createSpan("test1", s1a);
42 is(document.getElementById("test1"), s4a,
43 "Inserting span with id=test1 at the beginning changes which one is first");
45 s4a.parentNode.removeChild(s4a);
46 is(document.getElementById("test1"), s1a,
47 "First-created span with id=test1 is first again");
49 s1a.parentNode.removeChild(s1a);
50 is(document.getElementById("test1"), s3a,
51 "Third-created span with id=test1 is first now");
53 // Start the id hashtable
54 for (var i = 0; i < 256; ++i) {
55 document.getElementById("no-such-id-in-the-document" + i);
58 var s1b = createSpan("test2", null);
59 is(document.getElementById("test2"), s1b,
60 "Only one span with id=test2 in the tree; should work!");
62 var s2b = createSpan("test2", null);
63 is(document.getElementById("test2"), s1b,
64 "Appending span with id=test2 doesn't change which one comes first");
66 var s3b = createSpan("test2", s2b);
67 is(document.getElementById("test2"), s1b,
68 "Inserting span with id=test2 not at the beginning; doesn't matter");
70 var s4b = createSpan("test2", s1b);
71 is(document.getElementById("test2"), s4b,
72 "Inserting span with id=test2 at the beginning changes which one is first");
74 s4b.parentNode.removeChild(s4b);
75 is(document.getElementById("test2"), s1b,
76 "First-created span with id=test2 is first again");
78 s1b.parentNode.removeChild(s1b);
79 is(document.getElementById("test2"), s3b,
80 "Third-created span with id=test2 is first now");