Commit b76f8316 authored by David Morejon's avatar David Morejon Committed by Commit Bot

Automated transformation from js-test to testharness

This is an automated transformation using
https://github.com/Ecosystem-Infra/web-test-transformer.

The tool verifies its transformations, all of these files run
successfully after transformation. See the tool output:
https://gist.github.com/dmorejon/8383b6b532b13b0446d3398d8bc13593

This commit is the raw tool changes. There might be some stylistic
changes to be made manually.

Bug: 1120356, 936364
Change-Id: Ia5ba295bf83312d4951e548cf0d078ff1d4506f5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2368851Reviewed-by: default avatarRobert Ma <robertma@chromium.org>
Reviewed-by: default avatarLuke Z <lpz@chromium.org>
Commit-Queue: Robert Ma <robertma@chromium.org>
Cr-Commit-Position: refs/heads/master@{#801839}
parent c2d75f45
PASS document.querySelector('#lower1').textContent is 'lower 1'
PASS document.querySelector('#LOWER2') is null
PASS document.querySelector('#UPPER1').textContent is 'UPPER 1'
PASS document.querySelector('#upper2') is null
PASS document.getElementById('lower1').webkitMatchesSelector('#lower1') is true
PASS document.getElementById('lower2').webkitMatchesSelector('#LOWER2') is false
PASS document.getElementById('UPPER1').webkitMatchesSelector('#UPPER1') is true
PASS document.getElementById('UPPER2').webkitMatchesSelector('#upper2') is false
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<title>fast/dom/SelectorAPI/caseID-almost-strict.html</title>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
</head>
<body>
<div style="display: none">
......@@ -11,15 +13,17 @@
<span id="UPPER2">UPPER 2</span><br>
</div>
<script>
shouldBe("document.querySelector('#lower1').textContent", "'lower 1'");
shouldBeNull("document.querySelector('#LOWER2')");
shouldBe("document.querySelector('#UPPER1').textContent", "'UPPER 1'");
shouldBeNull("document.querySelector('#upper2')");
setup({ single_test: true });
assert_equals(document.querySelector('#lower1').textContent, 'lower 1');
assert_equals(document.querySelector('#LOWER2'), null);
assert_equals(document.querySelector('#UPPER1').textContent, 'UPPER 1');
assert_equals(document.querySelector('#upper2'), null);
shouldBeTrue("document.getElementById('lower1').webkitMatchesSelector('#lower1')");
shouldBeFalse("document.getElementById('lower2').webkitMatchesSelector('#LOWER2')");
shouldBeTrue("document.getElementById('UPPER1').webkitMatchesSelector('#UPPER1')");
shouldBeFalse("document.getElementById('UPPER2').webkitMatchesSelector('#upper2')");
assert_true(document.getElementById('lower1').webkitMatchesSelector('#lower1'));
assert_false(document.getElementById('lower2').webkitMatchesSelector('#LOWER2'));
assert_true(document.getElementById('UPPER1').webkitMatchesSelector('#UPPER1'));
assert_false(document.getElementById('UPPER2').webkitMatchesSelector('#upper2'));
done();
</script>
</body>
</html>
PASS document.querySelector('#lower1').textContent is 'lower 1'
PASS document.querySelector('#LOWER2').textContent is 'lower 2'
PASS document.querySelector('#UPPER1').textContent is 'UPPER 1'
PASS document.querySelector('#upper2').textContent is 'UPPER 2'
PASS document.getElementById('lower1').webkitMatchesSelector('#lower1') is true
PASS document.getElementById('lower2').webkitMatchesSelector('#LOWER2') is true
PASS document.getElementById('UPPER1').webkitMatchesSelector('#UPPER1') is true
PASS document.getElementById('UPPER2').webkitMatchesSelector('#upper2') is true
PASS successfullyParsed is true
TEST COMPLETE
PASS document.querySelector('#lower1').textContent is 'lower 1'
PASS document.querySelector('#LOWER2') is null
PASS document.querySelector('#UPPER1').textContent is 'UPPER 1'
PASS document.querySelector('#upper2') is null
PASS document.getElementById('lower1').webkitMatchesSelector('#lower1') is true
PASS document.getElementById('lower2').webkitMatchesSelector('#LOWER2') is false
PASS document.getElementById('UPPER1').webkitMatchesSelector('#UPPER1') is true
PASS document.getElementById('UPPER2').webkitMatchesSelector('#upper2') is false
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<title>fast/dom/SelectorAPI/caseID-strict.html</title>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
</head>
<body>
<div style="display: none">
......@@ -11,15 +13,17 @@
<span id="UPPER2">UPPER 2</span><br>
</div>
<script>
shouldBe("document.querySelector('#lower1').textContent", "'lower 1'");
shouldBeNull("document.querySelector('#LOWER2')");
shouldBe("document.querySelector('#UPPER1').textContent", "'UPPER 1'");
shouldBeNull("document.querySelector('#upper2')");
setup({ single_test: true });
assert_equals(document.querySelector('#lower1').textContent, 'lower 1');
assert_equals(document.querySelector('#LOWER2'), null);
assert_equals(document.querySelector('#UPPER1').textContent, 'UPPER 1');
assert_equals(document.querySelector('#upper2'), null);
shouldBeTrue("document.getElementById('lower1').webkitMatchesSelector('#lower1')");
shouldBeFalse("document.getElementById('lower2').webkitMatchesSelector('#LOWER2')");
shouldBeTrue("document.getElementById('UPPER1').webkitMatchesSelector('#UPPER1')");
shouldBeFalse("document.getElementById('UPPER2').webkitMatchesSelector('#upper2')");
</script>
assert_true(document.getElementById('lower1').webkitMatchesSelector('#lower1'));
assert_false(document.getElementById('lower2').webkitMatchesSelector('#LOWER2'));
assert_true(document.getElementById('UPPER1').webkitMatchesSelector('#UPPER1'));
assert_false(document.getElementById('UPPER2').webkitMatchesSelector('#upper2'));
done();
</script>
</body>
</html>
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<title>fast/dom/SelectorAPI/caseID.html</title>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
</head>
<body>
<div style="display: none">
......@@ -10,15 +12,17 @@
<span id="UPPER2">UPPER 2</span><br>
</div>
<script>
shouldBe("document.querySelector('#lower1').textContent", "'lower 1'");
shouldBe("document.querySelector('#LOWER2').textContent", "'lower 2'");
shouldBe("document.querySelector('#UPPER1').textContent", "'UPPER 1'");
shouldBe("document.querySelector('#upper2').textContent", "'UPPER 2'");
setup({ single_test: true });
assert_equals(document.querySelector('#lower1').textContent, 'lower 1');
assert_equals(document.querySelector('#LOWER2').textContent, 'lower 2');
assert_equals(document.querySelector('#UPPER1').textContent, 'UPPER 1');
assert_equals(document.querySelector('#upper2').textContent, 'UPPER 2');
shouldBeTrue("document.getElementById('lower1').webkitMatchesSelector('#lower1')");
shouldBeTrue("document.getElementById('lower2').webkitMatchesSelector('#LOWER2')");
shouldBeTrue("document.getElementById('UPPER1').webkitMatchesSelector('#UPPER1')");
shouldBeTrue("document.getElementById('UPPER2').webkitMatchesSelector('#upper2')");
</script>
assert_true(document.getElementById('lower1').webkitMatchesSelector('#lower1'));
assert_true(document.getElementById('lower2').webkitMatchesSelector('#LOWER2'));
assert_true(document.getElementById('UPPER1').webkitMatchesSelector('#UPPER1'));
assert_true(document.getElementById('UPPER2').webkitMatchesSelector('#upper2'));
done();
</script>
</body>
</html>
PASS document.querySelector('div SPAN').textContent is 'lower'
PASS document.querySelector('div p').textContent is 'UPPER'
PASS document.getElementById('lower1').webkitMatchesSelector('div SPAN') is true
PASS document.getElementById('UPPER1').webkitMatchesSelector('div p') is true
PASS successfullyParsed is true
TEST COMPLETE
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<title>fast/dom/SelectorAPI/caseTag.html</title>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
</head>
<body>
<div style="display: none">
......@@ -8,11 +10,13 @@
<P id="UPPER1">UPPER</P><br>
</div>
<script>
shouldBe("document.querySelector('div SPAN').textContent", "'lower'");
shouldBe("document.querySelector('div p').textContent", "'UPPER'");
setup({ single_test: true });
assert_equals(document.querySelector('div SPAN').textContent, 'lower');
assert_equals(document.querySelector('div p').textContent, 'UPPER');
shouldBeTrue("document.getElementById('lower1').webkitMatchesSelector('div SPAN')");
shouldBeTrue("document.getElementById('UPPER1').webkitMatchesSelector('div p')");
</script>
assert_true(document.getElementById('lower1').webkitMatchesSelector('div SPAN'));
assert_true(document.getElementById('UPPER1').webkitMatchesSelector('div p'));
done();
</script>
</body>
</html>
This tests that querySelector, querySelectorAll and matchesSelector (webkitMatchesSelector) work with elements that are not in a document yet.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS root.querySelector('div') is correctNode
PASS root.querySelector('#testId') is correctNode
PASS root.querySelectorAll('div').length is 1
PASS root.querySelectorAll('div').item(0) is correctNode
PASS root.querySelectorAll('#testId').length is 1
PASS root.querySelectorAll('#testId').item(0) is correctNode
PASS noChild.querySelector('div') is null
PASS noChild.querySelectorAll('div').length is 0
PASS correctNode.webkitMatchesSelector('div') is true
PASS correctNode.webkitMatchesSelector('#testId') is true
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<title>This tests that querySelector, querySelectorAll and matchesSelector (webkitMatchesSelector) work with elements that are not in a document yet.</title>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
</head>
<body>
<script>
description(
"This tests that querySelector, querySelectorAll and matchesSelector (webkitMatchesSelector) work with elements that are not in a document yet."
);
setup({ single_test: true });
var root = document.createElement('div');
var correctNode = document.createElement('div');
correctNode.setAttribute("id", "testId")
correctNode.setAttribute("id", "testId");
root.appendChild(correctNode);
var noChild = document.createElement('div');
shouldBe("root.querySelector('div')", "correctNode");
shouldBe("root.querySelector('#testId')", "correctNode");
assert_equals(root.querySelector('div'), correctNode);
assert_equals(root.querySelector('#testId'), correctNode);
shouldBe("root.querySelectorAll('div').length", "1");
shouldBe("root.querySelectorAll('div').item(0)", "correctNode");
shouldBe("root.querySelectorAll('#testId').length", "1");
shouldBe("root.querySelectorAll('#testId').item(0)", "correctNode");
assert_equals(root.querySelectorAll('div').length, 1);
assert_equals(root.querySelectorAll('div').item(0), correctNode);
assert_equals(root.querySelectorAll('#testId').length, 1);
assert_equals(root.querySelectorAll('#testId').item(0), correctNode);
shouldBeNull("noChild.querySelector('div')");
shouldBe("noChild.querySelectorAll('div').length", "0");
assert_equals(noChild.querySelector('div'), null);
assert_equals(noChild.querySelectorAll('div').length, 0);
shouldBeTrue("correctNode.webkitMatchesSelector('div')");
shouldBeTrue("correctNode.webkitMatchesSelector('#testId')");
assert_true(correctNode.webkitMatchesSelector('div'));
assert_true(correctNode.webkitMatchesSelector('#testId'));
done();
</script>
</body>
</html>
DocumentFragment.querySelector matching nth-child of fragment.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS fragment.querySelector(":nth-child(12)").id is "pass"
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<script src="../../../resources/js-test.js"></script>
<title>DocumentFragment.querySelector matching nth-child of fragment.</title>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script>
description("DocumentFragment.querySelector matching nth-child of fragment.");
setup({ single_test: true });
var fragment = document.createDocumentFragment();
for (var i = 0; i < 12; i++) {
var child = document.createElement("span");
if (i == 11)
child.id = "pass";
fragment.appendChild(child);
var child = document.createElement("span");
if (i == 11)
child.id = "pass";
fragment.appendChild(child);
}
shouldBe('fragment.querySelector(":nth-child(12)").id', '"pass"');
assert_equals(fragment.querySelector(":nth-child(12)").id, "pass");
done();
</script>
line 4
line 5
PASS testQuerySelectorAll(document, ".target + div") is "[object HTMLDivElement], [object HTMLDivElement], length: 2"
PASS testQuerySelectorAll(document.getElementById("test"), ".target + div") is "[object HTMLDivElement], [object HTMLDivElement], length: 2"
PASS testQuerySelectorAll(document.getElementById("test2"), ".target + div") is "length: 0"
PASS testQuerySelectorAll(document.getElementById("test3"), ".target + div") is "length: 0"
PASS successfullyParsed is true
TEST COMPLETE
<!doctype html>
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<title>fast/dom/SelectorAPI/dumpNodeList-2.html</title>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
</head>
<body>
<div id="test">
......@@ -19,29 +21,31 @@
</div>
<pre id="console"></pre>
<script>
NodeList.prototype.dump = function()
setup({ single_test: true });
NodeList.prototype.dump = function ()
{
var result = "";
var length = this.length;
for (var i = 0; i < length; i++)
result += this[i] + ", ";
result += "length: " + length;
return result;
}
var result = "";
var length = this.length;
for (var i = 0; i < length; i++)
result += this[i] + ", ";
result += "length: " + length;
return result;
};
function testQuerySelectorAll(node, selectorString)
{
try {
return node.querySelectorAll(selectorString).dump();
} catch (e) {
return "" + e;
}
try {
return node.querySelectorAll(selectorString).dump();
} catch (e) {
return "" + e;
}
}
shouldBeEqualToString('testQuerySelectorAll(document, ".target + div")', "[object HTMLDivElement], [object HTMLDivElement], length: 2");
shouldBeEqualToString('testQuerySelectorAll(document.getElementById("test"), ".target + div")', "[object HTMLDivElement], [object HTMLDivElement], length: 2");
shouldBeEqualToString('testQuerySelectorAll(document.getElementById("test2"), ".target + div")', "length: 0");
shouldBeEqualToString('testQuerySelectorAll(document.getElementById("test3"), ".target + div")', "length: 0");
assert_equals(testQuerySelectorAll(document, ".target + div"), "[object HTMLDivElement], [object HTMLDivElement], length: 2");
assert_equals(testQuerySelectorAll(document.getElementById("test"), ".target + div"), "[object HTMLDivElement], [object HTMLDivElement], length: 2");
assert_equals(testQuerySelectorAll(document.getElementById("test2"), ".target + div"), "length: 0");
assert_equals(testQuerySelectorAll(document.getElementById("test3"), ".target + div"), "length: 0");
done();
</script>
</body>
</html>
Test that CSS selector queries on duplicate Ids respect scope.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS document.querySelectorAll('#duplicateId1').length is 6
PASS document.querySelectorAll('#duplicateId2').length is 2
PASS scopeDiv.querySelectorAll('#duplicateId1').length is 4
PASS scopeDiv.querySelector('#duplicateId2') is null
PASS scopeDiv.querySelectorAll('#duplicateId2').length is 0
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<title>Test that CSS selector queries on duplicate Ids respect scope.</title>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
</head>
<body>
<span id="duplicateId1"></span>
......@@ -15,15 +17,16 @@
<span id="duplicateId1"></span>
</div>
<script>
description("Test that CSS selector queries on duplicate Ids respect scope.");
setup({ single_test: true });
shouldBe("document.querySelectorAll('#duplicateId1').length", "6");
shouldBe("document.querySelectorAll('#duplicateId2').length", "2");
assert_equals(document.querySelectorAll('#duplicateId1').length, 6);
assert_equals(document.querySelectorAll('#duplicateId2').length, 2);
scopeDiv = document.getElementById("scopeDiv");
shouldBe("scopeDiv.querySelectorAll('#duplicateId1').length", "4");
shouldBeNull("scopeDiv.querySelector('#duplicateId2')");
shouldBe("scopeDiv.querySelectorAll('#duplicateId2').length", "0");
</script>
scopeDiv = document.getElementById("scopeDiv");
assert_equals(scopeDiv.querySelectorAll('#duplicateId1').length, 4);
assert_equals(scopeDiv.querySelector('#duplicateId2'), null);
assert_equals(scopeDiv.querySelectorAll('#duplicateId2').length, 0);
done();
</script>
</body>
</html>
This tests that querySelector and querySelectorAll don't search outside their root node.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS root.querySelector('div') is correctNode
PASS root.querySelectorAll('div').length is 1
PASS root.querySelectorAll('div').item(0) is correctNode
PASS noChild.querySelector('div') is null
PASS noChild.querySelectorAll('div').length is 0
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<title>This tests that querySelector and querySelectorAll don't search outside their root node.</title>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
</head>
<body>
<script>
description(
"This tests that querySelector and querySelectorAll don't search outside their root node."
);
setup({ single_test: true });
var root = document.createElement('div');
var correctNode = document.createElement('div');
......@@ -16,12 +16,13 @@ document.body.appendChild(root);
var noChild = document.createElement('div');
document.body.appendChild(noChild);
shouldBe("root.querySelector('div')", "correctNode");
shouldBe("root.querySelectorAll('div').length", "1");
shouldBe("root.querySelectorAll('div').item(0)", "correctNode");
assert_equals(root.querySelector('div'), correctNode);
assert_equals(root.querySelectorAll('div').length, 1);
assert_equals(root.querySelectorAll('div').item(0), correctNode);
shouldBeNull("noChild.querySelector('div')");
shouldBe("noChild.querySelectorAll('div').length", "0");
assert_equals(noChild.querySelector('div'), null);
assert_equals(noChild.querySelectorAll('div').length, 0);
done();
</script>
</body>
</html>
This tests that the querySelector and querySelectorAll fast path for IDs in almost strict mode.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS document.querySelector('#testId') is correctNode
PASS document.querySelector('div#testId') is correctNode
PASS document.querySelector('ul#testId') is null
PASS document.querySelector('ul #testId') is null
PASS document.querySelector('#testId[attr]') is null
PASS document.querySelector('#testId:not(div)') is null
PASS document.querySelectorAll('div#testId').length is 1
PASS document.querySelectorAll('div#testId').item(0) is correctNode
PASS document.querySelectorAll('#testId').length is 1
PASS document.querySelectorAll('#testId').item(0) is correctNode
PASS document.querySelectorAll('ul#testId').length is 0
PASS document.querySelectorAll('ul #testId').length is 0
PASS document.querySelectorAll('#testId[attr]').length is 0
PASS document.querySelectorAll('#testId:not(div)').length is 0
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<title>This tests that the querySelector and querySelectorAll fast path for IDs in almost strict mode.</title>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
</head>
<body>
<script src="resources/id-fastpath-almost-strict.js"></script>
......
This tests that the querySelector and querySelectorAll fast path for IDs is not overzelous.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS document.querySelector('div#testid') is correctNode
PASS document.querySelector('#testid') is correctNode
PASS document.querySelector('ul#testid') is null
PASS document.querySelector('ul #testid') is null
PASS document.querySelector('#testid[attr]') is null
PASS document.querySelector('#testid:not(div)') is null
PASS document.querySelectorAll('div#testid').length is 1
PASS document.querySelectorAll('div#testid').item(0) is correctNode
PASS document.querySelectorAll('#testid').length is 1
PASS document.querySelectorAll('#testid').item(0) is correctNode
PASS document.querySelectorAll('ul#testid').length is 0
PASS document.querySelectorAll('ul #testid').length is 0
PASS document.querySelectorAll('#testid[attr]').length is 0
PASS document.querySelectorAll('#testid:not(div)').length is 0
PASS successfullyParsed is true
TEST COMPLETE
This tests that the querySelector and querySelectorAll fast path for IDs is not overzelous.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS document.querySelector('#testId') is correctNode
PASS document.querySelector('div#testId') is correctNode
PASS document.querySelector('ul#testId') is null
PASS document.querySelector('ul #testId') is null
PASS document.querySelector('#testId[attr]') is null
PASS document.querySelector('#testId:not(div)') is null
PASS document.querySelectorAll('div#testId').length is 1
PASS document.querySelectorAll('div#testId').item(0) is correctNode
PASS document.querySelectorAll('#testId').length is 1
PASS document.querySelectorAll('#testId').item(0) is correctNode
PASS document.querySelectorAll('ul#testId').length is 0
PASS document.querySelectorAll('ul #testId').length is 0
PASS document.querySelectorAll('#testId[attr]').length is 0
PASS document.querySelectorAll('#testId:not(div)').length is 0
PASS successfullyParsed is true
TEST COMPLETE
......@@ -2,7 +2,9 @@
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<title>This tests that the querySelector and querySelectorAll fast path for IDs is not overzelous.</title>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
</head>
<body>
<script src="resources/id-fastpath-strict.js"></script>
......
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<title>This tests that the querySelector and querySelectorAll fast path for IDs is not overzelous.</title>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
</head>
<body>
<script>
description(
"This tests that the querySelector and querySelectorAll fast path for IDs is not overzelous."
);
setup({ single_test: true });
var root = document.createElement('div');
var correctNode = document.createElement('div');
correctNode.setAttribute("id", "testid")
correctNode.setAttribute("id", "testid");
root.appendChild(correctNode);
document.body.appendChild(root);
shouldBe("document.querySelector('div#testid')", "correctNode");
shouldBe("document.querySelector('#testid')", "correctNode");
shouldBeNull("document.querySelector('ul#testid')");
shouldBeNull("document.querySelector('ul #testid')");
shouldBeNull("document.querySelector('#testid[attr]')");
shouldBeNull("document.querySelector('#testid:not(div)')");
assert_equals(document.querySelector('div#testid'), correctNode);
assert_equals(document.querySelector('#testid'), correctNode);
assert_equals(document.querySelector('ul#testid'), null);
assert_equals(document.querySelector('ul #testid'), null);
assert_equals(document.querySelector('#testid[attr]'), null);
assert_equals(document.querySelector('#testid:not(div)'), null);
shouldBe("document.querySelectorAll('div#testid').length", "1");
shouldBe("document.querySelectorAll('div#testid').item(0)", "correctNode");
shouldBe("document.querySelectorAll('#testid').length", "1");
shouldBe("document.querySelectorAll('#testid').item(0)", "correctNode");
shouldBe("document.querySelectorAll('ul#testid').length", "0");
shouldBe("document.querySelectorAll('ul #testid').length", "0");
shouldBe("document.querySelectorAll('#testid[attr]').length", "0");
shouldBe("document.querySelectorAll('#testid:not(div)').length", "0");
assert_equals(document.querySelectorAll('div#testid').length, 1);
assert_equals(document.querySelectorAll('div#testid').item(0), correctNode);
assert_equals(document.querySelectorAll('#testid').length, 1);
assert_equals(document.querySelectorAll('#testid').item(0), correctNode);
assert_equals(document.querySelectorAll('ul#testid').length, 0);
assert_equals(document.querySelectorAll('ul #testid').length, 0);
assert_equals(document.querySelectorAll('#testid[attr]').length, 0);
assert_equals(document.querySelectorAll('#testid:not(div)').length, 0);
done();
</script>
</body>
</html>
Element.querySelector matching nth-child of loose subtree.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS root.querySelector(":nth-child(12)").id is "pass"
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<script src="../../../resources/js-test.js"></script>
<title>Element.querySelector matching nth-child of loose subtree.</title>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script>
description("Element.querySelector matching nth-child of loose subtree.");
setup({ single_test: true });
var root = document.createElement("div");
for (var i = 0; i < 12; i++) {
var child = document.createElement("span");
if (i == 11)
child.id = "pass";
root.appendChild(child);
var child = document.createElement("span");
if (i == 11)
child.id = "pass";
root.appendChild(child);
}
shouldBe('root.querySelector(":nth-child(12)").id', '"pass"');
assert_equals(root.querySelector(":nth-child(12)").id, "pass");
done();
</script>
querySelectorAll and namespaces
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS sandbox.querySelectorAll('span').length is 3
PASS sandbox.querySelectorAll('*|span').length is 3
PASS sandbox.querySelectorAll('|span').length is 1
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<script src="../../../resources/js-test.js"></script>
<title>querySelectorAll and namespaces</title>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<div id="sandbox">
<span></span>
</div>
<script>
description("querySelectorAll and namespaces");
setup({ single_test: true });
sandbox.appendChild(document.createElementNS("http://dummynamespace", "span"));
sandbox.appendChild(document.createElementNS("", "span"));
shouldBe("sandbox.querySelectorAll('span').length", "3");
shouldBe("sandbox.querySelectorAll('*|span').length", "3");
shouldBe("sandbox.querySelectorAll('|span').length", "1");
assert_equals(sandbox.querySelectorAll('span').length, 3);
assert_equals(sandbox.querySelectorAll('*|span').length, 3);
assert_equals(sandbox.querySelectorAll('|span').length, 1);
done();
</script>
description(
"This tests that the querySelector and querySelectorAll fast path for IDs in almost strict mode."
);
setup({single_test: true});
var root = document.createElement('div');
var correctNode = document.createElement('div');
correctNode.setAttribute("id", "testId")
correctNode.setAttribute('id', 'testId');
root.appendChild(correctNode);
document.body.appendChild(root);
shouldBe("document.querySelector('#testId')", "correctNode");
shouldBe("document.querySelector('div#testId')", "correctNode");
shouldBeNull("document.querySelector('ul#testId')");
shouldBeNull("document.querySelector('ul #testId')");
shouldBeNull("document.querySelector('#testId[attr]')");
shouldBeNull("document.querySelector('#testId:not(div)')");
assert_equals(document.querySelector('#testId'), correctNode);
assert_equals(document.querySelector('div#testId'), correctNode);
assert_equals(document.querySelector('ul#testId'), null);
assert_equals(document.querySelector('ul #testId'), null);
assert_equals(document.querySelector('#testId[attr]'), null);
assert_equals(document.querySelector('#testId:not(div)'), null);
shouldBe("document.querySelectorAll('div#testId').length", "1");
shouldBe("document.querySelectorAll('div#testId').item(0)", "correctNode");
shouldBe("document.querySelectorAll('#testId').length", "1");
shouldBe("document.querySelectorAll('#testId').item(0)", "correctNode");
shouldBe("document.querySelectorAll('ul#testId').length", "0");
shouldBe("document.querySelectorAll('ul #testId').length", "0");
shouldBe("document.querySelectorAll('#testId[attr]').length", "0");
shouldBe("document.querySelectorAll('#testId:not(div)').length", "0");
assert_equals(document.querySelectorAll('div#testId').length, 1);
assert_equals(document.querySelectorAll('div#testId').item(0), correctNode);
assert_equals(document.querySelectorAll('#testId').length, 1);
assert_equals(document.querySelectorAll('#testId').item(0), correctNode);
assert_equals(document.querySelectorAll('ul#testId').length, 0);
assert_equals(document.querySelectorAll('ul #testId').length, 0);
assert_equals(document.querySelectorAll('#testId[attr]').length, 0);
assert_equals(document.querySelectorAll('#testId:not(div)').length, 0);
done();
\ No newline at end of file
description(
"This tests that the querySelector and querySelectorAll fast path for IDs is not overzelous."
);
setup({single_test: true});
var root = document.createElement('div');
var correctNode = document.createElement('div');
correctNode.setAttribute("id", "testId")
correctNode.setAttribute('id', 'testId');
root.appendChild(correctNode);
document.body.appendChild(root);
shouldBe("document.querySelector('#testId')", "correctNode");
shouldBe("document.querySelector('div#testId')", "correctNode");
shouldBeNull("document.querySelector('ul#testId')");
shouldBeNull("document.querySelector('ul #testId')");
shouldBeNull("document.querySelector('#testId[attr]')");
shouldBeNull("document.querySelector('#testId:not(div)')");
assert_equals(document.querySelector('#testId'), correctNode);
assert_equals(document.querySelector('div#testId'), correctNode);
assert_equals(document.querySelector('ul#testId'), null);
assert_equals(document.querySelector('ul #testId'), null);
assert_equals(document.querySelector('#testId[attr]'), null);
assert_equals(document.querySelector('#testId:not(div)'), null);
shouldBe("document.querySelectorAll('div#testId').length", "1");
shouldBe("document.querySelectorAll('div#testId').item(0)", "correctNode");
shouldBe("document.querySelectorAll('#testId').length", "1");
shouldBe("document.querySelectorAll('#testId').item(0)", "correctNode");
shouldBe("document.querySelectorAll('ul#testId').length", "0");
shouldBe("document.querySelectorAll('ul #testId').length", "0");
shouldBe("document.querySelectorAll('#testId[attr]').length", "0");
shouldBe("document.querySelectorAll('#testId:not(div)').length", "0");
assert_equals(document.querySelectorAll('div#testId').length, 1);
assert_equals(document.querySelectorAll('div#testId').item(0), correctNode);
assert_equals(document.querySelectorAll('#testId').length, 1);
assert_equals(document.querySelectorAll('#testId').item(0), correctNode);
assert_equals(document.querySelectorAll('ul#testId').length, 0);
assert_equals(document.querySelectorAll('ul #testId').length, 0);
assert_equals(document.querySelectorAll('#testId[attr]').length, 0);
assert_equals(document.querySelectorAll('#testId:not(div)').length, 0);
done();
\ No newline at end of file
This tests that the querySelector, querySelectorAll and matchesSelector (webkitMatchesSelector) correctly stringify null and undefined to "null" and "undefined".
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS document.querySelector(null) is nullNode
PASS document.querySelector(undefined) is undefinedNode
PASS document.querySelectorAll(null).length is 1
PASS document.querySelectorAll(null).item(0) is nullNode
PASS document.querySelectorAll(undefined).length is 1
PASS document.querySelectorAll(undefined).item(0) is undefinedNode
PASS nullNode.webkitMatchesSelector(null) is true
PASS undefinedNode.webkitMatchesSelector(undefined) is true
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<title>This tests that the querySelector, querySelectorAll and matchesSelector (webkitMatchesSelector) correctly stringify null and undefined to "null" and "undefined".</title>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
</head>
<body>
<script>
description(
"This tests that the querySelector, querySelectorAll and matchesSelector (webkitMatchesSelector) correctly stringify null and undefined to \"null\" and \"undefined\"."
);
setup({ single_test: true });
var root = document.createElement('div');
var nullNode = document.createElement('null');
......@@ -16,16 +16,17 @@ var undefinedNode = document.createElement('undefined');
root.appendChild(undefinedNode);
document.body.appendChild(root);
shouldBe("document.querySelector(null)", "nullNode");
shouldBe("document.querySelector(undefined)", "undefinedNode");
assert_equals(document.querySelector(null), nullNode);
assert_equals(document.querySelector(undefined), undefinedNode);
shouldBe("document.querySelectorAll(null).length", "1");
shouldBe("document.querySelectorAll(null).item(0)", "nullNode");
shouldBe("document.querySelectorAll(undefined).length", "1");
shouldBe("document.querySelectorAll(undefined).item(0)", "undefinedNode");
assert_equals(document.querySelectorAll(null).length, 1);
assert_equals(document.querySelectorAll(null).item(0), nullNode);
assert_equals(document.querySelectorAll(undefined).length, 1);
assert_equals(document.querySelectorAll(undefined).item(0), undefinedNode);
shouldBeTrue("nullNode.webkitMatchesSelector(null)");
shouldBeTrue("undefinedNode.webkitMatchesSelector(undefined)");
assert_true(nullNode.webkitMatchesSelector(null));
assert_true(undefinedNode.webkitMatchesSelector(undefined));
done();
</script>
</body>
</html>
This tests that querySelector, querySelectorAll and matchesSelector (webkitMatchesSelector) don't crash when used in a viewless document.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS testDoc.querySelector('p') is p1
PASS testDoc.querySelectorAll('span').length is 2
PASS testDoc.querySelectorAll('span').item(1) is s2
PASS testDoc.querySelector('.d1') is d1
PASS testDoc.querySelectorAll('p span').length is 1
PASS p1.webkitMatchesSelector('p') is true
PASS s1.webkitMatchesSelector('p span') is true
PASS s2.webkitMatchesSelector('#s2') is true
PASS d1.webkitMatchesSelector('.d1') is true
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<title>This tests that querySelector, querySelectorAll and matchesSelector (webkitMatchesSelector) don't crash when used in a viewless document.</title>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
</head>
<body>
<script>
description(
"This tests that querySelector, querySelectorAll and matchesSelector (webkitMatchesSelector) don't crash when used in a viewless document."
);
setup({ single_test: true });
var testDoc = document.implementation.createDocument("http://www.w3.org/1999/xhtml", "html");
testDoc.documentElement.appendChild(testDoc.createElement("body"));
......@@ -21,16 +21,17 @@ var s1 = testDoc.getElementById("s1");
var s2 = testDoc.getElementById("s2");
var d1 = testDoc.body.lastChild;
shouldBe("testDoc.querySelector('p')", "p1");
shouldBe("testDoc.querySelectorAll('span').length", "2");
shouldBe("testDoc.querySelectorAll('span').item(1)", "s2");
shouldBe("testDoc.querySelector('.d1')", "d1");
shouldBe("testDoc.querySelectorAll('p span').length", "1");
assert_equals(testDoc.querySelector('p'), p1);
assert_equals(testDoc.querySelectorAll('span').length, 2);
assert_equals(testDoc.querySelectorAll('span').item(1), s2);
assert_equals(testDoc.querySelector('.d1'), d1);
assert_equals(testDoc.querySelectorAll('p span').length, 1);
shouldBeTrue("p1.webkitMatchesSelector('p')");
shouldBeTrue("s1.webkitMatchesSelector('p span')");
shouldBeTrue("s2.webkitMatchesSelector('#s2')");
shouldBeTrue("d1.webkitMatchesSelector('.d1')");
assert_true(p1.webkitMatchesSelector('p'));
assert_true(s1.webkitMatchesSelector('p span'));
assert_true(s2.webkitMatchesSelector('#s2'));
assert_true(d1.webkitMatchesSelector('.d1'));
done();
</script>
</body>
</html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment