1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/base/test/test_bug403868.xml Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,85 @@ 1.4 +<html xmlns="http://www.w3.org/1999/xhtml"> 1.5 +<!-- 1.6 +https://bugzilla.mozilla.org/show_bug.cgi?id=403868 1.7 +--> 1.8 +<head> 1.9 + <title>Test for Bug 403868</title> 1.10 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.11 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.12 +</head> 1.13 +<body> 1.14 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=403868">Mozilla Bug 403868</a> 1.15 +<p id="display"></p> 1.16 +<div id="content" style="display: none"> 1.17 + 1.18 +</div> 1.19 +<pre id="test"> 1.20 +<script class="testbody" type="text/javascript"> 1.21 +<![CDATA[ 1.22 + 1.23 +/** Test for Bug 403868 **/ 1.24 +function createSpan(id, insertionPoint) { 1.25 + var s = document.createElementNS("http://www.w3.org/1999/xhtml", "span"); 1.26 + s.id = id; 1.27 + $("content").insertBefore(s, insertionPoint); 1.28 + return s; 1.29 +} 1.30 + 1.31 +var s1a = createSpan("test1", null); 1.32 +is(document.getElementById("test1"), s1a, 1.33 + "Only one span with id=test1 in the tree; should work!"); 1.34 + 1.35 +var s2a = createSpan("test1", null); 1.36 +is(document.getElementById("test1"), s1a, 1.37 + "Appending span with id=test1 doesn't change which one comes first"); 1.38 + 1.39 +var s3a = createSpan("test1", s2a); 1.40 +is(document.getElementById("test1"), s1a, 1.41 + "Inserting span with id=test1 not at the beginning; doesn't matter"); 1.42 + 1.43 +var s4a = createSpan("test1", s1a); 1.44 +is(document.getElementById("test1"), s4a, 1.45 + "Inserting span with id=test1 at the beginning changes which one is first"); 1.46 + 1.47 +s4a.parentNode.removeChild(s4a); 1.48 +is(document.getElementById("test1"), s1a, 1.49 + "First-created span with id=test1 is first again"); 1.50 + 1.51 +s1a.parentNode.removeChild(s1a); 1.52 +is(document.getElementById("test1"), s3a, 1.53 + "Third-created span with id=test1 is first now"); 1.54 + 1.55 +// Start the id hashtable 1.56 +for (var i = 0; i < 256; ++i) { 1.57 + document.getElementById("no-such-id-in-the-document" + i); 1.58 +} 1.59 + 1.60 +var s1b = createSpan("test2", null); 1.61 +is(document.getElementById("test2"), s1b, 1.62 + "Only one span with id=test2 in the tree; should work!"); 1.63 + 1.64 +var s2b = createSpan("test2", null); 1.65 +is(document.getElementById("test2"), s1b, 1.66 + "Appending span with id=test2 doesn't change which one comes first"); 1.67 + 1.68 +var s3b = createSpan("test2", s2b); 1.69 +is(document.getElementById("test2"), s1b, 1.70 + "Inserting span with id=test2 not at the beginning; doesn't matter"); 1.71 + 1.72 +var s4b = createSpan("test2", s1b); 1.73 +is(document.getElementById("test2"), s4b, 1.74 + "Inserting span with id=test2 at the beginning changes which one is first"); 1.75 + 1.76 +s4b.parentNode.removeChild(s4b); 1.77 +is(document.getElementById("test2"), s1b, 1.78 + "First-created span with id=test2 is first again"); 1.79 + 1.80 +s1b.parentNode.removeChild(s1b); 1.81 +is(document.getElementById("test2"), s3b, 1.82 + "Third-created span with id=test2 is first now"); 1.83 +]]> 1.84 +</script> 1.85 +</pre> 1.86 +</body> 1.87 +</html> 1.88 +