Make getElementById in HTML always return the first node in document order.
Bug 403868, r+sr=sicking git-svn-id: svn://10.0.0.236/trunk@239811 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
695b90c436
commit
860025cdfa
@ -113,6 +113,7 @@ _TEST_FILES = test_bug5141.html \
|
|||||||
test_bug402150.html \
|
test_bug402150.html \
|
||||||
test_bug402150.html^headers^ \
|
test_bug402150.html^headers^ \
|
||||||
test_bug401662.html \
|
test_bug401662.html \
|
||||||
|
test_bug403868.xml \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
libs:: $(_TEST_FILES)
|
libs:: $(_TEST_FILES)
|
||||||
|
|||||||
@ -43,15 +43,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=311681
|
|||||||
newParent.appendChild(node);
|
newParent.appendChild(node);
|
||||||
|
|
||||||
// Check what getElementById returns, no flushing
|
// Check what getElementById returns, no flushing
|
||||||
todo(getCont() == testNode, "Should be getting orig node pre-flush 1");
|
is(getCont(), node, "Should be getting orig node pre-flush 1");
|
||||||
is(getCont(), node, "XML does it differently, for now");
|
|
||||||
|
|
||||||
// Trigger a layout flush, just in case.
|
// Trigger a layout flush, just in case.
|
||||||
var itemHeight = newParent.offsetHeight/10;
|
var itemHeight = newParent.offsetHeight/10;
|
||||||
|
|
||||||
// Check what getElementById returns now.
|
// Check what getElementById returns now.
|
||||||
todo(getCont() == testNode, "Should be getting orig node post-flush 1");
|
is(getCont(), node, "Should be getting new node post-flush 1");
|
||||||
is(getCont(), node, "XML does it differently, for now");
|
|
||||||
|
|
||||||
clear(newParent);
|
clear(newParent);
|
||||||
|
|
||||||
|
|||||||
86
mozilla/content/base/test/test_bug403868.xml
Normal file
86
mozilla/content/base/test/test_bug403868.xml
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<!--
|
||||||
|
https://bugzilla.mozilla.org/show_bug.cgi?id=403868
|
||||||
|
-->
|
||||||
|
<head>
|
||||||
|
<title>Test for Bug 403868</title>
|
||||||
|
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||||
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=403868">Mozilla Bug 403868</a>
|
||||||
|
<p id="display"></p>
|
||||||
|
<div id="content" style="display: none">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<pre id="test">
|
||||||
|
<script class="testbody" type="text/javascript">
|
||||||
|
<![CDATA[
|
||||||
|
|
||||||
|
/** Test for Bug 403868 **/
|
||||||
|
function createSpan(id, insertionPoint) {
|
||||||
|
var s = document.createElementNS("http://www.w3.org/1999/xhtml", "span");
|
||||||
|
s.id = id;
|
||||||
|
$("content").insertBefore(s, insertionPoint);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
var s1a = createSpan("test1", null);
|
||||||
|
is(document.getElementById("test1"), s1a,
|
||||||
|
"Only one span with id=test1 in the tree; should work!");
|
||||||
|
|
||||||
|
var s2a = createSpan("test1", null);
|
||||||
|
is(document.getElementById("test1"), s1a,
|
||||||
|
"Appending span with id=test1 doesn't change which one comes first");
|
||||||
|
|
||||||
|
var s3a = createSpan("test1", s2a);
|
||||||
|
is(document.getElementById("test1"), s1a,
|
||||||
|
"Inserting span with id=test1 not at the beginning; doesn't matter");
|
||||||
|
|
||||||
|
var s4a = createSpan("test1", s1a);
|
||||||
|
is(document.getElementById("test1"), s4a,
|
||||||
|
"Inserting span with id=test1 at the beginning changes which one is first");
|
||||||
|
|
||||||
|
s4a.parentNode.removeChild(s4a);
|
||||||
|
is(document.getElementById("test1"), s1a,
|
||||||
|
"First-created span with id=test1 is first again");
|
||||||
|
|
||||||
|
s1a.parentNode.removeChild(s1a);
|
||||||
|
is(document.getElementById("test1"), s3a,
|
||||||
|
"Third-created span with id=test1 is first now");
|
||||||
|
|
||||||
|
// Start the id hashtable
|
||||||
|
for (var i = 0; i < 256; ++i) {
|
||||||
|
document.getElementById("no-such-id-in-the-document" + i);
|
||||||
|
}
|
||||||
|
|
||||||
|
var s1b = createSpan("test2", null);
|
||||||
|
is(document.getElementById("test2"), s1b,
|
||||||
|
"Only one span with id=test2 in the tree; should work!");
|
||||||
|
|
||||||
|
var s2b = createSpan("test2", null);
|
||||||
|
is(document.getElementById("test2"), s1b,
|
||||||
|
"Appending span with id=test2 doesn't change which one comes first");
|
||||||
|
|
||||||
|
var s3b = createSpan("test2", s2b);
|
||||||
|
is(document.getElementById("test2"), s1b,
|
||||||
|
"Inserting span with id=test2 not at the beginning; doesn't matter");
|
||||||
|
|
||||||
|
var s4b = createSpan("test2", s1b);
|
||||||
|
is(document.getElementById("test2"), s4b,
|
||||||
|
"Inserting span with id=test2 at the beginning changes which one is first");
|
||||||
|
|
||||||
|
s4b.parentNode.removeChild(s4b);
|
||||||
|
is(document.getElementById("test2"), s1b,
|
||||||
|
"First-created span with id=test2 is first again");
|
||||||
|
|
||||||
|
s1b.parentNode.removeChild(s1b);
|
||||||
|
is(document.getElementById("test2"), s3b,
|
||||||
|
"Third-created span with id=test2 is first now");
|
||||||
|
]]>
|
||||||
|
</script>
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
@ -269,15 +269,36 @@ IdAndNameMapEntry::AddIdContent(nsIContent* aContent)
|
|||||||
return mIdContentList.ReplaceElementAt(aContent, 0);
|
return mIdContentList.ReplaceElementAt(aContent, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Have to check whether it's in the list already, in case we're
|
// Common case
|
||||||
// registering from the top when going live.
|
if (mIdContentList.Count() == 0) {
|
||||||
PRInt32 index = mIdContentList.IndexOf(aContent);
|
return mIdContentList.AppendElement(aContent);
|
||||||
if (index != -1) {
|
|
||||||
// nothing else to do here
|
|
||||||
return PR_TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return mIdContentList.AppendElement(aContent);
|
// We seem to have multiple content nodes for the same id, or we're doing our
|
||||||
|
// top-down registration when the id table is going live. Search for the
|
||||||
|
// right place to insert the content.
|
||||||
|
PRInt32 start = 0;
|
||||||
|
PRInt32 end = mIdContentList.Count();
|
||||||
|
do {
|
||||||
|
NS_ASSERTION(start < end, "Bogus start/end");
|
||||||
|
|
||||||
|
PRInt32 cur = (start + end) / 2;
|
||||||
|
NS_ASSERTION(cur >= start && cur < end, "What happened here?");
|
||||||
|
|
||||||
|
nsIContent* curContent = static_cast<nsIContent*>(mIdContentList[cur]);
|
||||||
|
if (curContent == aContent) {
|
||||||
|
// Already in the list, so already in the right spot. Get out of here.
|
||||||
|
return PR_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nsContentUtils::PositionIsBefore(aContent, curContent)) {
|
||||||
|
end = cur;
|
||||||
|
} else {
|
||||||
|
start = cur + 1;
|
||||||
|
}
|
||||||
|
} while (start != end);
|
||||||
|
|
||||||
|
return mIdContentList.InsertElementAt(aContent, start);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -63,6 +63,8 @@ _TEST_FILES = test_bug1682.html \
|
|||||||
test_bug386495.html \
|
test_bug386495.html \
|
||||||
test_bug391777.html \
|
test_bug391777.html \
|
||||||
test_bug402680.html \
|
test_bug402680.html \
|
||||||
|
test_bug403868.html \
|
||||||
|
test_bug403868.xhtml \
|
||||||
test_form-parsing.html \
|
test_form-parsing.html \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
|
|||||||
@ -43,13 +43,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=311681
|
|||||||
newParent.appendChild(node);
|
newParent.appendChild(node);
|
||||||
|
|
||||||
// Check what getElementById returns, no flushing
|
// Check what getElementById returns, no flushing
|
||||||
is(getCont(), testNode, "Should be getting orig node pre-flush 1");
|
is(getCont(), node, "Should be getting new node pre-flush 1");
|
||||||
|
|
||||||
// Trigger a layout flush, just in case.
|
// Trigger a layout flush, just in case.
|
||||||
var itemHeight = newParent.offsetHeight/10;
|
var itemHeight = newParent.offsetHeight/10;
|
||||||
|
|
||||||
// Check what getElementById returns now.
|
// Check what getElementById returns now.
|
||||||
is(getCont(), testNode, "Should be getting orig node post-flush 1");
|
is(getCont(), node, "Should be getting new node post-flush 1");
|
||||||
|
|
||||||
clear(newParent);
|
clear(newParent);
|
||||||
|
|
||||||
|
|||||||
@ -43,13 +43,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=311681
|
|||||||
newParent.appendChild(node);
|
newParent.appendChild(node);
|
||||||
|
|
||||||
// Check what getElementById returns, no flushing
|
// Check what getElementById returns, no flushing
|
||||||
is(getCont(), testNode, "Should be getting orig node pre-flush 1");
|
is(getCont(), node, "Should be getting new node pre-flush 1");
|
||||||
|
|
||||||
// Trigger a layout flush, just in case.
|
// Trigger a layout flush, just in case.
|
||||||
var itemHeight = newParent.offsetHeight/10;
|
var itemHeight = newParent.offsetHeight/10;
|
||||||
|
|
||||||
// Check what getElementById returns now.
|
// Check what getElementById returns now.
|
||||||
is(getCont(), testNode, "Should be getting orig node post-flush 1");
|
is(getCont(), node, "Should be getting new node post-flush 1");
|
||||||
|
|
||||||
clear(newParent);
|
clear(newParent);
|
||||||
|
|
||||||
|
|||||||
88
mozilla/content/html/document/test/test_bug403868.html
Normal file
88
mozilla/content/html/document/test/test_bug403868.html
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<!--
|
||||||
|
https://bugzilla.mozilla.org/show_bug.cgi?id=403868
|
||||||
|
-->
|
||||||
|
<head>
|
||||||
|
<title>Test for Bug 403868</title>
|
||||||
|
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||||
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=403868">Mozilla Bug 403868</a>
|
||||||
|
<p id="display"></p>
|
||||||
|
<div id="content" style="display: none">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<pre id="test">
|
||||||
|
<script class="testbody" type="text/javascript">
|
||||||
|
|
||||||
|
/** Test for Bug 403868 **/
|
||||||
|
function createSpan(id, insertionPoint) {
|
||||||
|
var s = document.createElement("span");
|
||||||
|
s.id = id;
|
||||||
|
$("content").insertBefore(s, insertionPoint);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
var s1a = createSpan("test1", null);
|
||||||
|
is(document.getElementById("test1"), s1a,
|
||||||
|
"Only one span with id=test1 in the tree; should work!");
|
||||||
|
|
||||||
|
var s2a = createSpan("test1", null);
|
||||||
|
is(document.getElementById("test1"), s1a,
|
||||||
|
"Appending span with id=test1 doesn't change which one comes first");
|
||||||
|
|
||||||
|
var s3a = createSpan("test1", s2a);
|
||||||
|
is(document.getElementById("test1"), s1a,
|
||||||
|
"Inserting span with id=test1 not at the beginning; doesn't matter");
|
||||||
|
|
||||||
|
var s4a = createSpan("test1", s1a);
|
||||||
|
is(document.getElementById("test1"), s4a,
|
||||||
|
"Inserting span with id=test1 at the beginning changes which one is first");
|
||||||
|
|
||||||
|
s4a.parentNode.removeChild(s4a);
|
||||||
|
is(document.getElementById("test1"), s1a,
|
||||||
|
"First-created span with id=test1 is first again");
|
||||||
|
|
||||||
|
s1a.parentNode.removeChild(s1a);
|
||||||
|
is(document.getElementById("test1"), s3a,
|
||||||
|
"Third-created span with id=test1 is first now");
|
||||||
|
|
||||||
|
// Start the id hashtable
|
||||||
|
for (var i = 0; i < 256; ++i) {
|
||||||
|
document.getElementById("no-such-id-in-the-document" + i);
|
||||||
|
}
|
||||||
|
|
||||||
|
var s1b = createSpan("test2", null);
|
||||||
|
is(document.getElementById("test2"), s1b,
|
||||||
|
"Only one span with id=test2 in the tree; should work!");
|
||||||
|
|
||||||
|
var s2b = createSpan("test2", null);
|
||||||
|
is(document.getElementById("test2"), s1b,
|
||||||
|
"Appending span with id=test2 doesn't change which one comes first");
|
||||||
|
|
||||||
|
var s3b = createSpan("test2", s2b);
|
||||||
|
is(document.getElementById("test2"), s1b,
|
||||||
|
"Inserting span with id=test2 not at the beginning; doesn't matter");
|
||||||
|
|
||||||
|
var s4b = createSpan("test2", s1b);
|
||||||
|
is(document.getElementById("test2"), s4b,
|
||||||
|
"Inserting span with id=test2 at the beginning changes which one is first");
|
||||||
|
|
||||||
|
s4b.parentNode.removeChild(s4b);
|
||||||
|
is(document.getElementById("test2"), s1b,
|
||||||
|
"First-created span with id=test2 is first again");
|
||||||
|
|
||||||
|
s1b.parentNode.removeChild(s1b);
|
||||||
|
is(document.getElementById("test2"), s3b,
|
||||||
|
"Third-created span with id=test2 is first now");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
87
mozilla/content/html/document/test/test_bug403868.xhtml
Normal file
87
mozilla/content/html/document/test/test_bug403868.xhtml
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<!--
|
||||||
|
https://bugzilla.mozilla.org/show_bug.cgi?id=403868
|
||||||
|
-->
|
||||||
|
<head>
|
||||||
|
<title>Test for Bug 403868</title>
|
||||||
|
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||||
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=403868">Mozilla Bug 403868</a>
|
||||||
|
<p id="display"></p>
|
||||||
|
<div id="content" style="display: none">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<pre id="test">
|
||||||
|
<script class="testbody" type="text/javascript">
|
||||||
|
<![CDATA[
|
||||||
|
|
||||||
|
/** Test for Bug 403868 **/
|
||||||
|
function createSpan(id, insertionPoint) {
|
||||||
|
var s = document.createElementNS("http://www.w3.org/1999/xhtml", "span");
|
||||||
|
s.id = id;
|
||||||
|
$("content").insertBefore(s, insertionPoint);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
var s1a = createSpan("test1", null);
|
||||||
|
is(document.getElementById("test1"), s1a,
|
||||||
|
"Only one span with id=test1 in the tree; should work!");
|
||||||
|
|
||||||
|
var s2a = createSpan("test1", null);
|
||||||
|
is(document.getElementById("test1"), s1a,
|
||||||
|
"Appending span with id=test1 doesn't change which one comes first");
|
||||||
|
|
||||||
|
var s3a = createSpan("test1", s2a);
|
||||||
|
is(document.getElementById("test1"), s1a,
|
||||||
|
"Inserting span with id=test1 not at the beginning; doesn't matter");
|
||||||
|
|
||||||
|
var s4a = createSpan("test1", s1a);
|
||||||
|
is(document.getElementById("test1"), s4a,
|
||||||
|
"Inserting span with id=test1 at the beginning changes which one is first");
|
||||||
|
|
||||||
|
s4a.parentNode.removeChild(s4a);
|
||||||
|
is(document.getElementById("test1"), s1a,
|
||||||
|
"First-created span with id=test1 is first again");
|
||||||
|
|
||||||
|
s1a.parentNode.removeChild(s1a);
|
||||||
|
is(document.getElementById("test1"), s3a,
|
||||||
|
"Third-created span with id=test1 is first now");
|
||||||
|
|
||||||
|
// Start the id hashtable
|
||||||
|
for (var i = 0; i < 256; ++i) {
|
||||||
|
document.getElementById("no-such-id-in-the-document" + i);
|
||||||
|
}
|
||||||
|
|
||||||
|
var s1b = createSpan("test2", null);
|
||||||
|
is(document.getElementById("test2"), s1b,
|
||||||
|
"Only one span with id=test2 in the tree; should work!");
|
||||||
|
|
||||||
|
var s2b = createSpan("test2", null);
|
||||||
|
is(document.getElementById("test2"), s1b,
|
||||||
|
"Appending span with id=test2 doesn't change which one comes first");
|
||||||
|
|
||||||
|
var s3b = createSpan("test2", s2b);
|
||||||
|
is(document.getElementById("test2"), s1b,
|
||||||
|
"Inserting span with id=test2 not at the beginning; doesn't matter");
|
||||||
|
|
||||||
|
var s4b = createSpan("test2", s1b);
|
||||||
|
is(document.getElementById("test2"), s4b,
|
||||||
|
"Inserting span with id=test2 at the beginning changes which one is first");
|
||||||
|
|
||||||
|
s4b.parentNode.removeChild(s4b);
|
||||||
|
is(document.getElementById("test2"), s1b,
|
||||||
|
"First-created span with id=test2 is first again");
|
||||||
|
|
||||||
|
s1b.parentNode.removeChild(s1b);
|
||||||
|
is(document.getElementById("test2"), s3b,
|
||||||
|
"Third-created span with id=test2 is first now");
|
||||||
|
|
||||||
|
]]>
|
||||||
|
</script>
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
@ -47,6 +47,7 @@ include $(topsrcdir)/config/rules.mk
|
|||||||
_TEST_FILES = \
|
_TEST_FILES = \
|
||||||
test_bug311681.xul \
|
test_bug311681.xul \
|
||||||
test_bug199692.xul \
|
test_bug199692.xul \
|
||||||
|
test_bug403868.xul \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
libs:: $(_TEST_FILES)
|
libs:: $(_TEST_FILES)
|
||||||
|
|||||||
@ -47,13 +47,15 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=311681
|
|||||||
newParent.appendChild(node);
|
newParent.appendChild(node);
|
||||||
|
|
||||||
// Check what getElementById returns, no flushing
|
// Check what getElementById returns, no flushing
|
||||||
is(getCont(), testNode, "Should be getting orig node pre-flush 1");
|
todo(getCont() == node, "Should be getting new node pre-flush 1")
|
||||||
|
is(getCont(), testNode, "XUL does it differently for now");
|
||||||
|
|
||||||
// Trigger a layout flush, just in case.
|
// Trigger a layout flush, just in case.
|
||||||
var itemHeight = newParent.offsetHeight/10;
|
var itemHeight = newParent.offsetHeight/10;
|
||||||
|
|
||||||
// Check what getElementById returns now.
|
// Check what getElementById returns now.
|
||||||
is(getCont(), testNode, "Should be getting orig node post-flush 1");
|
todo(getCont() == node, "Should be getting new node post-flush 1")
|
||||||
|
is(getCont(), testNode, "XUL does it differently for now");
|
||||||
|
|
||||||
clear(newParent);
|
clear(newParent);
|
||||||
|
|
||||||
|
|||||||
90
mozilla/content/xul/document/test/test_bug403868.xul
Normal file
90
mozilla/content/xul/document/test/test_bug403868.xul
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||||
|
<?xml-stylesheet href="/tests/SimpleTest/test.css" type="text/css"?>
|
||||||
|
<!--
|
||||||
|
https://bugzilla.mozilla.org/show_bug.cgi?id=403868
|
||||||
|
-->
|
||||||
|
<window title="Mozilla Bug 403868"
|
||||||
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||||
|
<script type="application/javascript" src="/MochiKit/packed.js" />
|
||||||
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"/>
|
||||||
|
|
||||||
|
<!-- test resuls are displayed in the html:body -->
|
||||||
|
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=403868"
|
||||||
|
target="_blank">Mozilla Bug 403868</a>
|
||||||
|
<div id="content" style="display: none"/>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
<!-- test code goes here -->
|
||||||
|
<script type="application/javascript"><![CDATA[
|
||||||
|
|
||||||
|
/** Test for Bug 403868 **/
|
||||||
|
function createSpan(id, insertionPoint) {
|
||||||
|
var s = document.createElementNS("http://www.w3.org/1999/xhtml", "span");
|
||||||
|
s.id = id;
|
||||||
|
$("content").insertBefore(s, insertionPoint);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
var s1a = createSpan("test1", null);
|
||||||
|
is(document.getElementById("test1"), s1a,
|
||||||
|
"Only one span with id=test1 in the tree; should work!");
|
||||||
|
|
||||||
|
var s2a = createSpan("test1", null);
|
||||||
|
is(document.getElementById("test1"), s1a,
|
||||||
|
"Appending span with id=test1 doesn't change which one comes first");
|
||||||
|
|
||||||
|
var s3a = createSpan("test1", s2a);
|
||||||
|
is(document.getElementById("test1"), s1a,
|
||||||
|
"Inserting span with id=test1 not at the beginning; doesn't matter");
|
||||||
|
|
||||||
|
var s4a = createSpan("test1", s1a);
|
||||||
|
todo(document.getElementById("test1") == s4a,
|
||||||
|
"Inserting span with id=test1 at the beginning changes which one is first");
|
||||||
|
is(document.getElementById("test1"), s1a, "XUL is confused")
|
||||||
|
|
||||||
|
s4a.parentNode.removeChild(s4a);
|
||||||
|
is(document.getElementById("test1"), s1a,
|
||||||
|
"First-created span with id=test1 is first again");
|
||||||
|
|
||||||
|
s1a.parentNode.removeChild(s1a);
|
||||||
|
todo(document.getElementById("test1") == s3a,
|
||||||
|
"Third-created span with id=test1 is first now");
|
||||||
|
is(document.getElementById("test1"), s2a,
|
||||||
|
"XUL is confused");
|
||||||
|
|
||||||
|
// Start the id hashtable
|
||||||
|
for (var i = 0; i < 256; ++i) {
|
||||||
|
document.getElementById("no-such-id-in-the-document" + i);
|
||||||
|
}
|
||||||
|
|
||||||
|
var s1b = createSpan("test2", null);
|
||||||
|
is(document.getElementById("test2"), s1b,
|
||||||
|
"Only one span with id=test2 in the tree; should work!");
|
||||||
|
|
||||||
|
var s2b = createSpan("test2", null);
|
||||||
|
is(document.getElementById("test2"), s1b,
|
||||||
|
"Appending span with id=test2 doesn't change which one comes first");
|
||||||
|
|
||||||
|
var s3b = createSpan("test2", s2b);
|
||||||
|
is(document.getElementById("test2"), s1b,
|
||||||
|
"Inserting span with id=test2 not at the beginning; doesn't matter");
|
||||||
|
|
||||||
|
var s4b = createSpan("test2", s1b);
|
||||||
|
todo(document.getElementById("test2") == s4b,
|
||||||
|
"Inserting span with id=test2 at the beginning changes which one is first");
|
||||||
|
is(document.getElementById("test2"), s1b, "XUL is confused")
|
||||||
|
|
||||||
|
s4b.parentNode.removeChild(s4b);
|
||||||
|
is(document.getElementById("test2"), s1b,
|
||||||
|
"First-created span with id=test2 is first again");
|
||||||
|
|
||||||
|
s1b.parentNode.removeChild(s1b);
|
||||||
|
todo(document.getElementById("test2") == s3b,
|
||||||
|
"Third-created span with id=test2 is first now");
|
||||||
|
is(document.getElementById("test2"), s2b,
|
||||||
|
"XUL is confused");
|
||||||
|
|
||||||
|
]]></script>
|
||||||
|
</window>
|
||||||
Loading…
x
Reference in New Issue
Block a user