mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Merge pull request #3016 from saneyuki/test
Remove needless tests about document.getElementById() which are covered by wpt; r=Ms2ger
This commit is contained in:
commit
1d09d324d2
2 changed files with 0 additions and 138 deletions
|
@ -8,104 +8,6 @@
|
||||||
<script>
|
<script>
|
||||||
let gBody = document.getElementsByTagName("body")[0];
|
let gBody = document.getElementsByTagName("body")[0];
|
||||||
|
|
||||||
// test1: on static page
|
|
||||||
{
|
|
||||||
let foo = document.getElementById("foo");
|
|
||||||
is_not(foo, null, "test-1-0, on static page");
|
|
||||||
is(foo && foo.tagName, "HEAD", "test1-1, on static page");
|
|
||||||
is_a(foo, HTMLHeadElement, "test1-2, on static page");
|
|
||||||
|
|
||||||
let bar = document.getElementById("bar");
|
|
||||||
is_not(bar, null, "test1-3, on static page");
|
|
||||||
is(bar && bar.tagName, "DIV", "test1-4, on static page");
|
|
||||||
is_a(bar, HTMLDivElement, "test1-5, on static page");
|
|
||||||
}
|
|
||||||
|
|
||||||
// test2: scripted element
|
|
||||||
{
|
|
||||||
let TEST_ID = "test";
|
|
||||||
let test = document.createElement("div");
|
|
||||||
test.setAttribute("id", TEST_ID);
|
|
||||||
gBody.appendChild(test);
|
|
||||||
|
|
||||||
// test: appended element
|
|
||||||
let appended = document.getElementById(TEST_ID);
|
|
||||||
is_not(appended, null, "test2-0, appended element");
|
|
||||||
is(appended && appended.tagName, "DIV", "test2-1, appended element");
|
|
||||||
is_a(appended, HTMLDivElement, "test2-2, appended element");
|
|
||||||
|
|
||||||
// test: removed element
|
|
||||||
gBody.removeChild(test);
|
|
||||||
let removed = document.getElementById(TEST_ID);
|
|
||||||
// `document.getElementById()` returns `null` if there is none.
|
|
||||||
// http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-getElBId
|
|
||||||
// http://dom.spec.whatwg.org/#dom-document-getelementbyid (2013-09-20)
|
|
||||||
is(removed, null, "test2-3, removed element");
|
|
||||||
}
|
|
||||||
|
|
||||||
// test3: update `id` attribute
|
|
||||||
{
|
|
||||||
// setup fixtures.
|
|
||||||
let TEST_ID = "test3";
|
|
||||||
let test = document.createElement("div");
|
|
||||||
test.setAttribute("id", TEST_ID);
|
|
||||||
gBody.appendChild(test);
|
|
||||||
|
|
||||||
// update id
|
|
||||||
let UPDATED_ID = "test3-updated";
|
|
||||||
test.setAttribute("id", UPDATED_ID);
|
|
||||||
let e = document.getElementById(UPDATED_ID);
|
|
||||||
is(e, test, "test3-0, update 'id' attribute.");
|
|
||||||
|
|
||||||
let old = document.getElementById(TEST_ID);
|
|
||||||
is(old, null, "test3-1, the method shouldn't get the element by the old id.");
|
|
||||||
|
|
||||||
// remove id.
|
|
||||||
test.removeAttribute("id");
|
|
||||||
let e2 = document.getElementById(UPDATED_ID);
|
|
||||||
is(e2, null, "test3-2, the method should return null when the passed id is none in document.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// test 4
|
|
||||||
{
|
|
||||||
// Ensure that the id attribute only affects elements present in a document
|
|
||||||
let e = document.createElement('div');
|
|
||||||
e.id = "should-not-exist";
|
|
||||||
is(document.getElementById("should-not-exist"), null, "test 4-0");
|
|
||||||
document.body.appendChild(e);
|
|
||||||
is(document.getElementById("should-not-exist"), e, "test 4-1");
|
|
||||||
}
|
|
||||||
|
|
||||||
// test5: "in tree order, within the context object's tree"
|
|
||||||
// http://dom.spec.whatwg.org/#dom-document-getelementbyid.
|
|
||||||
// we test this in test_document_getElementById_tree_order.html
|
|
||||||
|
|
||||||
// TODO:
|
|
||||||
// test6: innerHTML
|
|
||||||
|
|
||||||
// test 7
|
|
||||||
{
|
|
||||||
// Test that we only cache elements by ID if they're in a document (see #1874).
|
|
||||||
let s = document.createElement("div");
|
|
||||||
s.setAttribute("id", "x");
|
|
||||||
document.createElement("div").appendChild(s);
|
|
||||||
is(document.getElementById("x"), null, "test 7-0");
|
|
||||||
}
|
|
||||||
|
|
||||||
// test 8
|
|
||||||
{
|
|
||||||
let TEST_ID = "test-8"
|
|
||||||
let element = document.createElement("div");
|
|
||||||
element.setAttribute("id", TEST_ID);
|
|
||||||
document.body.appendChild(element);
|
|
||||||
let target = document.getElementById(TEST_ID);
|
|
||||||
is_not(target, null, "test 8-0, getElementById is correct before changing the value");
|
|
||||||
|
|
||||||
element.attributes[0].value = TEST_ID + "-updated";
|
|
||||||
let target2 = document.getElementById(TEST_ID);
|
|
||||||
is(target2, null, "test 8-1, should return null after updated id via Attr.value");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test the assertion with inserting node with child having id into the document (mozilla#2630)
|
// Test the assertion with inserting node with child having id into the document (mozilla#2630)
|
||||||
// This need not to port to WPF-test because this tests servo's internally flags.
|
// This need not to port to WPF-test because this tests servo's internally flags.
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,40 +0,0 @@
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<script src="harness.js"></script>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="a">
|
|
||||||
</div>
|
|
||||||
<div id="b">
|
|
||||||
<p id="b">P</p>
|
|
||||||
<input id="b" type="submit" value="Submit">
|
|
||||||
</div>
|
|
||||||
<script>
|
|
||||||
{
|
|
||||||
var b = document.getElementById("b");
|
|
||||||
is_a(b, HTMLDivElement);
|
|
||||||
var a = document.getElementById("a");
|
|
||||||
var p = document.createElement("p");
|
|
||||||
p.id = "b";
|
|
||||||
a.appendChild(p);
|
|
||||||
var newB = document.getElementById("b");
|
|
||||||
is_a(newB, HTMLParagraphElement);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
var gbody = document.getElementsByTagName("body")[0];
|
|
||||||
var div = document.createElement("div");
|
|
||||||
div.setAttribute("id", "c");
|
|
||||||
var h1 = document.createElement("h1");
|
|
||||||
h1.setAttribute("id", "c");
|
|
||||||
gbody.appendChild(div);
|
|
||||||
gbody.appendChild(h1);
|
|
||||||
var c = document.getElementById("c");
|
|
||||||
is_a(c, HTMLDivElement);
|
|
||||||
gbody.removeChild(div);
|
|
||||||
var newC = document.getElementById("c");
|
|
||||||
is_a(newC, HTMLHeadingElement);
|
|
||||||
}
|
|
||||||
finish();
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
Loading…
Add table
Add a link
Reference in a new issue