test_bug403868.html (2517B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=403868 5 --> 6 <head> 7 <title>Test for Bug 403868</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 10 </head> 11 <body> 12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=403868">Mozilla Bug 403868</a> 13 <p id="display"></p> 14 <div id="content" style="display: none"> 15 16 </div> 17 <pre id="test"> 18 <script class="testbody" type="text/javascript"> 19 20 /** Test for Bug 403868 */ 21 function createSpan(id, insertionPoint) { 22 var s = document.createElement("span"); 23 s.id = id; 24 $("content").insertBefore(s, insertionPoint); 25 return s; 26 } 27 28 var s1a = createSpan("test1", null); 29 is(document.getElementById("test1"), s1a, 30 "Only one span with id=test1 in the tree; should work!"); 31 32 var s2a = createSpan("test1", null); 33 is(document.getElementById("test1"), s1a, 34 "Appending span with id=test1 doesn't change which one comes first"); 35 36 var s3a = createSpan("test1", s2a); 37 is(document.getElementById("test1"), s1a, 38 "Inserting span with id=test1 not at the beginning; doesn't matter"); 39 40 var s4a = createSpan("test1", s1a); 41 is(document.getElementById("test1"), s4a, 42 "Inserting span with id=test1 at the beginning changes which one is first"); 43 44 s4a.remove(); 45 is(document.getElementById("test1"), s1a, 46 "First-created span with id=test1 is first again"); 47 48 s1a.remove(); 49 is(document.getElementById("test1"), s3a, 50 "Third-created span with id=test1 is first now"); 51 52 // Start the id hashtable 53 for (var i = 0; i < 256; ++i) { 54 document.getElementById("no-such-id-in-the-document" + i); 55 } 56 57 var s1b = createSpan("test2", null); 58 is(document.getElementById("test2"), s1b, 59 "Only one span with id=test2 in the tree; should work!"); 60 61 var s2b = createSpan("test2", null); 62 is(document.getElementById("test2"), s1b, 63 "Appending span with id=test2 doesn't change which one comes first"); 64 65 var s3b = createSpan("test2", s2b); 66 is(document.getElementById("test2"), s1b, 67 "Inserting span with id=test2 not at the beginning; doesn't matter"); 68 69 var s4b = createSpan("test2", s1b); 70 is(document.getElementById("test2"), s4b, 71 "Inserting span with id=test2 at the beginning changes which one is first"); 72 73 s4b.remove(); 74 is(document.getElementById("test2"), s1b, 75 "First-created span with id=test2 is first again"); 76 77 s1b.remove(); 78 is(document.getElementById("test2"), s3b, 79 "Third-created span with id=test2 is first now"); 80 81 82 83 </script> 84 </pre> 85 </body> 86 </html>