2 <?xml-stylesheet href=
"chrome://global/skin" type=
"text/css"?>
3 <?xml-stylesheet href=
"chrome://mochikit/content/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 src=
"chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
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=403868"
14 target=
"_blank">Mozilla Bug
403868</a>
15 <div id=
"content" style=
"display: none"/>
18 <!-- test code goes here -->
19 <script type=
"application/javascript"><![CDATA[
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");
46 is(document.getElementById(
"test1"), s1a,
47 "First-created span with id=test1 is first again");
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");
75 is(document.getElementById(
"test2"), s1b,
76 "First-created span with id=test2 is first again");
79 is(document.getElementById(
"test2"), s3b,
80 "Third-created span with id=test2 is first now");