|
1 <?xml version="1.0"?> |
|
2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
|
3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> |
|
4 <!-- |
|
5 https://bugzilla.mozilla.org/show_bug.cgi?id=403868 |
|
6 --> |
|
7 <window title="Mozilla Bug 403868" |
|
8 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
|
9 <script type="application/javascript" 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=403868" |
|
14 target="_blank">Mozilla Bug 403868</a> |
|
15 <div id="content" style="display: none"/> |
|
16 </body> |
|
17 |
|
18 <!-- test code goes here --> |
|
19 <script type="application/javascript"><![CDATA[ |
|
20 |
|
21 /** Test for Bug 403868 **/ |
|
22 function createSpan(id, insertionPoint) { |
|
23 var s = document.createElementNS("http://www.w3.org/1999/xhtml", "span"); |
|
24 s.id = id; |
|
25 $("content").insertBefore(s, insertionPoint); |
|
26 return s; |
|
27 } |
|
28 |
|
29 var s1a = createSpan("test1", null); |
|
30 is(document.getElementById("test1"), s1a, |
|
31 "Only one span with id=test1 in the tree; should work!"); |
|
32 |
|
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"); |
|
36 |
|
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"); |
|
40 |
|
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"); |
|
44 |
|
45 s4a.parentNode.removeChild(s4a); |
|
46 is(document.getElementById("test1"), s1a, |
|
47 "First-created span with id=test1 is first again"); |
|
48 |
|
49 s1a.parentNode.removeChild(s1a); |
|
50 is(document.getElementById("test1"), s3a, |
|
51 "Third-created span with id=test1 is first now"); |
|
52 |
|
53 // Start the id hashtable |
|
54 for (var i = 0; i < 256; ++i) { |
|
55 document.getElementById("no-such-id-in-the-document" + i); |
|
56 } |
|
57 |
|
58 var s1b = createSpan("test2", null); |
|
59 is(document.getElementById("test2"), s1b, |
|
60 "Only one span with id=test2 in the tree; should work!"); |
|
61 |
|
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"); |
|
65 |
|
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"); |
|
69 |
|
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"); |
|
73 |
|
74 s4b.parentNode.removeChild(s4b); |
|
75 is(document.getElementById("test2"), s1b, |
|
76 "First-created span with id=test2 is first again"); |
|
77 |
|
78 s1b.parentNode.removeChild(s1b); |
|
79 is(document.getElementById("test2"), s3b, |
|
80 "Third-created span with id=test2 is first now"); |
|
81 |
|
82 ]]></script> |
|
83 </window> |