Commit 39096e3e authored by Yoshifumi Inoue's avatar Yoshifumi Inoue Committed by Commit Bot

Utilize w3c test harness in fast/dom/NodeList/childNodes-reverse-iteration.html

This patch changes "childNodes-reverse-iteration.html" to utilize w3c test
harness for ease of maintenance.

This patch is a preparation of the patch[1].

[1] http://crrev.com/c/1114673 Make Element#innerText specification compliant

Bug: 859410
Change-Id: Ie4f834134639bd2b21838764c032183319d62a73
Reviewed-on: https://chromium-review.googlesource.com/1122073Reviewed-by: default avatarXiaocheng Hu <xiaochengh@chromium.org>
Reviewed-by: default avatarYoichi Osato <yoichio@chromium.org>
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#572111}
parent 8a700fb2
This is an integration test for childNodes. You should see 1 through 5 below.
1
2
3
4
5
PASS node.innerText is '1\n2\n3\n4\n5\n'
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html> <!DOCTYPE html>
<html> <script src="../../../resources/testharness.js"></script>
<body> <script src="../../../resources/testharnessreport.js"></script>
<p>This is an integration test for childNodes. You should see 1 through 5 below.</p>
<pre></pre> <pre></pre>
<div id="console"></div>
<script src="../../../resources/js-test.js"></script>
<script> <script>
test(() => {
if (window.testRunner) const node = document.querySelector('pre');
testRunner.dumpAsText(); for (let j = 0; j < 5; ++j) {
const child = document.createElement('div');
var node = document.querySelector('pre');
var failed = false;
for (var j = 0; j < 5; ++j) {
var child = document.createElement('div');
child.innerHTML = j + 1; child.innerHTML = j + 1;
node.appendChild(child); node.appendChild(child);
for (var i = node.childNodes.length - 1; i >= 0; --i) { for (let i = node.childNodes.length - 1; i >= 0; --i) {
var actual = node.childNodes[i] ? node.childNodes[i].innerHTML : undefined; const actual = node.childNodes[i] ? node.childNodes[i].innerHTML
if (actual != i + 1) { : undefined;
testFailed('Got ' + actual + ' on ' + (i + 1) + 'st/nd/th child after adding ' + (j + 1) + 'st/nd/th child.'); assert_equals(actual, (i + 1).toString(),
failed = true; `child[${i}] after adding child[${j}]`);
}
} }
} }
}, 'Node#childNodes reverse iteration');
shouldBe("node.innerText", "'1\\n2\\n3\\n4\\n5\\n'");
</script> </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