зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1709674 [wpt PR 28846] - Upstream and expand outerText tests, a=testonly
Automatic update from web-platform-tests Upstream and expand outerText tests This accompanies https://github.com/whatwg/html/pull/6653. Fixed: 710764 Change-Id: I7168df9bbaeef12ed256b7f2fb9c2c43c9d6b227 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2875725 Reviewed-by: Mason Freed <masonf@chromium.org> Commit-Queue: Domenic Denicola <domenic@chromium.org> Cr-Commit-Position: refs/heads/master@{#880460} -- wpt-commits: e2bfe7b3d06bb26ff4d800087df6aad417feadfa wpt-pr: 28846
This commit is contained in:
Родитель
588b083ab5
Коммит
5b08d9bb1d
|
@ -28,12 +28,9 @@ testNodeDisconnector(function (customElement) {
|
|||
customElement.parentNode.innerText = '';
|
||||
}, 'innerText on HTMLElement');
|
||||
|
||||
if ('outerText' in HTMLElement.prototype) {
|
||||
// Not yet to be in the standard but all but Gecko supports this property: https://github.com/whatwg/html/issues/668
|
||||
testNodeDisconnector(function (customElement) {
|
||||
customElement.outerText = '';
|
||||
}, 'outerText on HTMLElement');
|
||||
}
|
||||
testNodeDisconnector(function (customElement) {
|
||||
customElement.outerText = '';
|
||||
}, 'outerText on HTMLElement');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<title>innerText getter test with dynamic style changes</title>
|
||||
<title>innerText/outerText getter test with dynamic style changes</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="container"></div>
|
||||
|
@ -19,7 +19,8 @@ function testText(html, expectedPlain, msg, mutate) {
|
|||
if (!e) {
|
||||
e = container.firstChild;
|
||||
}
|
||||
assert_equals(e.innerText, expectedPlain);
|
||||
assert_equals(e.innerText, expectedPlain, "innerText");
|
||||
assert_equals(e.outerText, expectedPlain, "outerText");
|
||||
container.textContext = '';
|
||||
}, msg + ' (' + format_value(html) + ')');
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Test innerText for a combination of a list item with ::first-letter in multicol</title>
|
||||
<title>Test innerText/outerText for a combination of a list item with ::first-letter in multicol</title>
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/dom.html#dom-innertext">
|
||||
<link rel="help" href="https://crbug.com/1174985">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
|
@ -12,6 +12,7 @@
|
|||
<div id="item" class="col"><div class="col">PASS</div></div>
|
||||
<script>
|
||||
test(() => {
|
||||
assert_equals(item.innerText, "PASS");
|
||||
assert_equals(item.innerText, "PASS", "innerText");
|
||||
assert_equals(item.outerText, "PASS", "outerText");
|
||||
}, "");
|
||||
</script>
|
|
@ -1,5 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<title>innerText getter test</title>
|
||||
<title>innerText/outerText getter test</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<style>
|
||||
|
@ -55,7 +55,8 @@ function textTextInContainer(cont, html, expectedPlain, msg) {
|
|||
while (e && e.nodeType != Node.ELEMENT_NODE) {
|
||||
e = e.nextSibling;
|
||||
}
|
||||
assert_equals(e.innerText, expectedPlain);
|
||||
assert_equals(e.innerText, expectedPlain, "innerText");
|
||||
assert_equals(e.outerText, expectedPlain, "outerText");
|
||||
cont.textContent = '';
|
||||
}, msg + ' (' + format_value(html) + ')');
|
||||
}
|
|
@ -85,4 +85,4 @@ function testHTML(context, plain, expectedHTML, msg) {
|
|||
}, msg + ", detached");
|
||||
}
|
||||
</script>
|
||||
<script src="setter-tests.js"></script>
|
||||
<script src="innertext-setter-tests.js"></script>
|
|
@ -9,7 +9,8 @@ async_test(t => {
|
|||
t1.data = "X";
|
||||
t2.data = " ";
|
||||
t3.data = "Y";
|
||||
assert_equals(div.innerText, "X Y");
|
||||
assert_equals(div.innerText, "X Y", "innerText");
|
||||
assert_equals(div.outerText, "X Y", "outerText");
|
||||
t.done();
|
||||
}, 100);
|
||||
}, "Ensure multiple text nodes get rendered properly");
|
|
@ -0,0 +1,140 @@
|
|||
<!DOCTYPE html>
|
||||
<title>outerText setter test</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
|
||||
<ul>
|
||||
<li>A <span id="testReplacePrevious">B</span></li>
|
||||
<li><span id="testReplaceFollowing">A</span> B</li>
|
||||
<li>A <span id="testReplaceBoth">B</span> C</li>
|
||||
<li><span id="testRemove">Testing</span> removing node using outerText.</li>
|
||||
</ul>
|
||||
|
||||
<div id="container"></div>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
test(() => {
|
||||
const node = document.getElementById("testReplacePrevious");
|
||||
const parent = node.parentNode;
|
||||
|
||||
node.outerText = "Replaced";
|
||||
|
||||
assert_equals(parent.innerHTML, "A Replaced");
|
||||
assert_equals(parent.childNodes.length, 1, "It got merged with the previous text node");
|
||||
}, "Replacing a node and merging with the previous text node");
|
||||
|
||||
test(() => {
|
||||
const node = document.getElementById("testReplaceFollowing");
|
||||
const parent = node.parentNode;
|
||||
|
||||
node.outerText = "Replaced";
|
||||
|
||||
assert_equals(parent.innerHTML, "Replaced B");
|
||||
assert_equals(parent.childNodes.length, 1, "It got merged with the following text node");
|
||||
}, "Replacing a node and merging with the following text node");
|
||||
|
||||
test(() => {
|
||||
const node = document.getElementById("testReplaceBoth");
|
||||
const parent = node.parentNode;
|
||||
|
||||
node.outerText = "Replaced";
|
||||
|
||||
assert_equals(parent.innerHTML, "A Replaced C");
|
||||
assert_equals(parent.childNodes.length, 1, "It got merged with the previous and following text node");
|
||||
}, "Replacing a node and merging with the previous and following text node");
|
||||
|
||||
test(t => {
|
||||
const container = document.getElementById("container");
|
||||
t.add_cleanup(() => { container.textContent = ""; });
|
||||
|
||||
container.append("A", "B", document.createElement("span"), "D", "E");
|
||||
assert_equals(container.childNodes.length, 5, "Precondition check: five separate nodes");
|
||||
|
||||
const node = container.childNodes[2];
|
||||
node.outerText = "Replaced";
|
||||
|
||||
assert_equals(container.innerHTML, "ABReplacedDE");
|
||||
assert_equals(container.childNodes.length, 3, "It got merged with the previous and following text node");
|
||||
assert_equals(container.childNodes[0].data, "A");
|
||||
assert_equals(container.childNodes[1].data, "BReplacedD");
|
||||
assert_equals(container.childNodes[2].data, "E");
|
||||
}, "Only merges with the previous and following text nodes, does not completely normalize");
|
||||
|
||||
test(() => {
|
||||
const node = document.getElementById("testRemove");
|
||||
const parent = node.parentNode;
|
||||
|
||||
node.outerText = "";
|
||||
|
||||
assert_equals(parent.innerHTML, " removing node using outerText.");
|
||||
}, "Removing a node");
|
||||
|
||||
test(() => {
|
||||
const node = document.createElement("span");
|
||||
|
||||
assert_throws_dom("NoModificationAllowedError", () => { node.outerText = ""; });
|
||||
}, "Detached node");
|
||||
|
||||
testText("<div>", "abc", "abc", "Simplest possible test");
|
||||
testHTML("<div>", "abc\ndef", "abc<br>def", "Newlines convert to <br> in non-white-space:pre elements");
|
||||
testHTML("<pre>", "abc\ndef", "abc<br>def", "Newlines convert to <br> in <pre> element");
|
||||
testHTML("<textarea>", "abc\ndef", "abc<br>def", "Newlines convert to <br> in <textarea> element");
|
||||
testHTML("<div style='white-space:pre'>", "abc\ndef", "abc<br>def", "Newlines convert to <br> in white-space:pre element");
|
||||
testHTML("<div>", "abc\rdef", "abc<br>def", "CRs convert to <br> in non-white-space:pre elements");
|
||||
testHTML("<pre>", "abc\rdef", "abc<br>def", "CRs convert to <br> in <pre> element");
|
||||
testHTML("<div>", "abc\r\ndef", "abc<br>def", "Newline/CR pair converts to <br> in non-white-space:pre element");
|
||||
testHTML("<div>", "abc\n\ndef", "abc<br><br>def", "Newline/newline pair converts to two <br>s in non-white-space:pre element");
|
||||
testHTML("<div>", "abc\r\rdef", "abc<br><br>def", "CR/CR pair converts to two <br>s in non-white-space:pre element");
|
||||
testHTML("<div style='white-space:pre'>", "abc\rdef", "abc<br>def", "CRs convert to <br> in white-space:pre element");
|
||||
testText("<div>", "abc<def", "abc<def", "< preserved");
|
||||
testText("<div>", "abc>def", "abc>def", "> preserved");
|
||||
testText("<div>", "abc&", "abc&", "& preserved");
|
||||
testText("<div>", "abc\"def", "abc\"def", "\" preserved");
|
||||
testText("<div>", "abc\'def", "abc\'def", "\' preserved");
|
||||
testHTML("<svg>", "abc", "<svg></svg>", "outerText not supported on SVG elements");
|
||||
testHTML("<math>", "abc", "<math></math>", "outerText not supported on MathML elements");
|
||||
testText("<div>", "abc\0def", "abc\0def", "Null characters preserved");
|
||||
testText("<div>", "abc\tdef", "abc\tdef", "Tabs preserved");
|
||||
testText("<div>", " abc", " abc", "Leading whitespace preserved");
|
||||
testText("<div>", "abc ", "abc ", "Trailing whitespace preserved");
|
||||
testText("<div>", "abc def", "abc def", "Whitespace not compressed");
|
||||
testText("<div>abc\n\n", "abc", "abc", "Existing text deleted");
|
||||
testText("<div><br>", "abc", "abc", "Existing <br> deleted");
|
||||
testHTML("<div>", "", "", "Assigning the empty string");
|
||||
testHTML("<div>", null, "", "Assigning null");
|
||||
testHTML("<div>", undefined, "undefined", "Assigning undefined");
|
||||
testHTML("<div>", "\rabc", "<br>abc", "Start with CR");
|
||||
testHTML("<div>", "\nabc", "<br>abc", "Start with LF");
|
||||
testHTML("<div>", "\r\nabc", "<br>abc", "Start with CRLF");
|
||||
testHTML("<div>", "abc\r", "abc<br>", "End with CR");
|
||||
testHTML("<div>", "abc\n", "abc<br>", "End with LF");
|
||||
testHTML("<div>", "abc\r\n", "abc<br>", "End with CRLF");
|
||||
|
||||
function testText(startingHTML, outerText, expected, description) {
|
||||
test(t => {
|
||||
const container = document.getElementById("container");
|
||||
t.add_cleanup(() => { container.textContent = ""; });
|
||||
|
||||
container.innerHTML = startingHTML;
|
||||
const elementToReplace = container.firstElementChild;
|
||||
|
||||
elementToReplace.outerText = outerText;
|
||||
assert_equals(container.textContent, expected);
|
||||
}, description);
|
||||
}
|
||||
|
||||
function testHTML(startingHTML, outerText, expected, description) {
|
||||
test(t => {
|
||||
const container = document.getElementById("container");
|
||||
t.add_cleanup(() => { container.textContent = ""; });
|
||||
|
||||
container.innerHTML = startingHTML;
|
||||
const elementToReplace = container.firstElementChild;
|
||||
|
||||
elementToReplace.outerText = outerText;
|
||||
assert_equals(container.innerHTML, expected);
|
||||
}, description);
|
||||
}
|
||||
</script>
|
Загрузка…
Ссылка в новой задаче