content/xul/document/test/test_bug403868.xul

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial