2 <?xml-stylesheet href=
"chrome://global/skin" type=
"text/css"?>
3 <?xml-stylesheet href=
"/tests/SimpleTest/test.css" type=
"text/css"?>
5 https://bugzilla.mozilla.org/show_bug.cgi?id=403868
7 <window title=
"Mozilla Bug 403868"
8 xmlns=
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
9 <script type=
"application/javascript" src=
"/MochiKit/packed.js" />
10 <script type=
"application/javascript" src=
"/tests/SimpleTest/SimpleTest.js"/>
12 <!-- test results are displayed in the html:body -->
13 <body xmlns=
"http://www.w3.org/1999/xhtml">
14 <a href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=403868"
15 target=
"_blank">Mozilla Bug
403868</a>
16 <div id=
"content" style=
"display: none"/>
19 <!-- test code goes here -->
20 <script type=
"application/javascript"><![CDATA[
22 /** Test for Bug
403868 **/
23 function createSpan(id, insertionPoint) {
24 var s = document.createElementNS(
"http://www.w3.org/1999/xhtml",
"span");
26 $(
"content").insertBefore(s, insertionPoint);
30 var s1a = createSpan(
"test1", null);
31 is(document.getElementById(
"test1"), s1a,
32 "Only one span with id=test1 in the tree; should work!");
34 var s2a = createSpan(
"test1", null);
35 is(document.getElementById(
"test1"), s1a,
36 "Appending span with id=test1 doesn't change which one comes first");
38 var s3a = createSpan(
"test1", s2a);
39 is(document.getElementById(
"test1"), s1a,
40 "Inserting span with id=test1 not at the beginning; doesn't matter");
42 var s4a = createSpan(
"test1", s1a);
43 is(document.getElementById(
"test1"), s4a,
44 "Inserting span with id=test1 at the beginning changes which one is first");
46 s4a.parentNode.removeChild(s4a);
47 is(document.getElementById(
"test1"), s1a,
48 "First-created span with id=test1 is first again");
50 s1a.parentNode.removeChild(s1a);
51 is(document.getElementById(
"test1"), s3a,
52 "Third-created span with id=test1 is first now");
54 // Start the id hashtable
55 for (var i =
0; i <
256; ++i) {
56 document.getElementById(
"no-such-id-in-the-document" + i);
59 var s1b = createSpan(
"test2", null);
60 is(document.getElementById(
"test2"), s1b,
61 "Only one span with id=test2 in the tree; should work!");
63 var s2b = createSpan(
"test2", null);
64 is(document.getElementById(
"test2"), s1b,
65 "Appending span with id=test2 doesn't change which one comes first");
67 var s3b = createSpan(
"test2", s2b);
68 is(document.getElementById(
"test2"), s1b,
69 "Inserting span with id=test2 not at the beginning; doesn't matter");
71 var s4b = createSpan(
"test2", s1b);
72 is(document.getElementById(
"test2"), s4b,
73 "Inserting span with id=test2 at the beginning changes which one is first");
75 s4b.parentNode.removeChild(s4b);
76 is(document.getElementById(
"test2"), s1b,
77 "First-created span with id=test2 is first again");
79 s1b.parentNode.removeChild(s1b);
80 is(document.getElementById(
"test2"), s3b,
81 "Third-created span with id=test2 is first now");