Bug 1709790 - Implement HTMLElement.outerText. r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D136240
This commit is contained in:
Emilio Cobos Álvarez 2022-01-19 12:49:29 +00:00
Родитель 4beb65365c
Коммит 42b3b10f8a
13 изменённых файлов: 130 добавлений и 944 удалений

Просмотреть файл

@ -2110,14 +2110,20 @@ void nsINode::ReplaceChildren(const Sequence<OwningNodeOrString>& aNodes,
if (aRv.Failed()) {
return;
}
MOZ_ASSERT(node);
return ReplaceChildren(node, aRv);
}
EnsurePreInsertionValidity(*node, nullptr, aRv);
if (aRv.Failed()) {
return;
void nsINode::ReplaceChildren(nsINode* aNode, ErrorResult& aRv) {
if (aNode) {
EnsurePreInsertionValidity(*aNode, nullptr, aRv);
if (aRv.Failed()) {
return;
}
}
// Needed when used in combination with contenteditable (maybe)
mozAutoDocUpdate updateBatch(doc, true);
mozAutoDocUpdate updateBatch(OwnerDoc(), true);
nsAutoMutationBatch mb(this, true, false);
@ -2127,8 +2133,10 @@ void nsINode::ReplaceChildren(const Sequence<OwningNodeOrString>& aNodes,
}
mb.RemovalDone();
AppendChild(*node, aRv);
mb.NodesAdded();
if (aNode) {
AppendChild(*aNode, aRv);
mb.NodesAdded();
}
}
void nsINode::RemoveChildNode(nsIContent* aKid, bool aNotify) {

Просмотреть файл

@ -2113,6 +2113,7 @@ class nsINode : public mozilla::dom::EventTarget {
ErrorResult& aRv);
MOZ_CAN_RUN_SCRIPT void ReplaceChildren(
const Sequence<OwningNodeOrString>& aNodes, ErrorResult& aRv);
MOZ_CAN_RUN_SCRIPT void ReplaceChildren(nsINode* aNode, ErrorResult& aRv);
void GetBoxQuads(const BoxQuadOptions& aOptions,
nsTArray<RefPtr<DOMQuad>>& aResult, CallerType aCallerType,

Просмотреть файл

@ -2916,27 +2916,12 @@ void nsGenericHTMLElement::GetInnerText(mozilla::dom::DOMString& aValue,
}
}
void nsGenericHTMLElement::SetInnerText(const nsAString& aValue) {
// Batch possible DOMSubtreeModified events.
mozAutoSubtreeModified subtree(OwnerDoc(), nullptr);
FireNodeRemovedForChildren();
// Might as well stick a batch around this since we're performing several
// mutations.
mozAutoDocUpdate updateBatch(GetComposedDoc(), true);
nsAutoMutationBatch mb;
mb.Init(this, true, false);
while (HasChildren()) {
RemoveChildNode(nsINode::GetFirstChild(), true);
}
mb.RemovalDone();
static already_AddRefed<nsINode> TextToNode(const nsAString& aString,
nsNodeInfoManager* aNim) {
nsString str;
const char16_t* s = aValue.BeginReading();
const char16_t* end = aValue.EndReading();
const char16_t* s = aString.BeginReading();
const char16_t* end = aString.EndReading();
RefPtr<DocumentFragment> fragment;
while (true) {
if (s != end && *s == '\r' && s + 1 != end && s[1] == '\n') {
// a \r\n pair should only generate one <br>, so just skip the \r
@ -2944,28 +2929,93 @@ void nsGenericHTMLElement::SetInnerText(const nsAString& aValue) {
}
if (s == end || *s == '\r' || *s == '\n') {
if (!str.IsEmpty()) {
RefPtr<nsTextNode> textContent = new (NodeInfo()->NodeInfoManager())
nsTextNode(NodeInfo()->NodeInfoManager());
RefPtr<nsTextNode> textContent = new (aNim) nsTextNode(aNim);
textContent->SetText(str, true);
AppendChildTo(textContent, true, IgnoreErrors());
if (!fragment) {
if (s == end) {
return textContent.forget();
}
fragment = new (aNim) DocumentFragment(aNim);
}
fragment->AppendChildTo(textContent, true, IgnoreErrors());
}
if (s == end) {
break;
}
str.Truncate();
RefPtr<mozilla::dom::NodeInfo> ni =
NodeInfo()->NodeInfoManager()->GetNodeInfo(
nsGkAtoms::br, nullptr, kNameSpaceID_XHTML, ELEMENT_NODE);
RefPtr<NodeInfo> ni = aNim->GetNodeInfo(
nsGkAtoms::br, nullptr, kNameSpaceID_XHTML, nsINode::ELEMENT_NODE);
auto* nim = ni->NodeInfoManager();
RefPtr<HTMLBRElement> br = new (nim) HTMLBRElement(ni.forget());
AppendChildTo(br, true, IgnoreErrors());
if (!fragment) {
if (s + 1 == end) {
return br.forget();
}
fragment = new (aNim) DocumentFragment(aNim);
}
fragment->AppendChildTo(br, true, IgnoreErrors());
} else {
str.Append(*s);
}
++s;
}
return fragment.forget();
}
mb.NodesAdded();
void nsGenericHTMLElement::SetInnerText(const nsAString& aValue) {
RefPtr<nsINode> node = TextToNode(aValue, NodeInfo()->NodeInfoManager());
ReplaceChildren(node, IgnoreErrors());
}
// https://html.spec.whatwg.org/#merge-with-the-next-text-node
static void MergeWithNextTextNode(Text& aText, ErrorResult& aRv) {
RefPtr<Text> nextSibling = Text::FromNodeOrNull(aText.GetNextSibling());
if (!nextSibling) {
return;
}
nsAutoString data;
nextSibling->GetData(data);
aText.AppendData(data, aRv);
nextSibling->Remove();
}
// https://html.spec.whatwg.org/#dom-outertext
void nsGenericHTMLElement::SetOuterText(const nsAString& aValue,
ErrorResult& aRv) {
nsCOMPtr<nsINode> parent = GetParentNode();
if (!parent) {
return aRv.ThrowNoModificationAllowedError("Element has no parent");
}
RefPtr<nsINode> next = GetNextSibling();
RefPtr<nsINode> previous = GetPreviousSibling();
// Batch possible DOMSubtreeModified events.
mozAutoSubtreeModified subtree(OwnerDoc(), nullptr);
nsNodeInfoManager* nim = NodeInfo()->NodeInfoManager();
RefPtr<nsINode> node = TextToNode(aValue, nim);
if (!node) {
// This doesn't match the spec, see
// https://github.com/whatwg/html/issues/7508
node = new (nim) nsTextNode(nim);
}
parent->ReplaceChild(*node, *this, aRv);
if (aRv.Failed()) {
return;
}
if (next) {
if (RefPtr<Text> text = Text::FromNodeOrNull(next->GetPreviousSibling())) {
MergeWithNextTextNode(*text, aRv);
if (aRv.Failed()) {
return;
}
}
}
if (auto* text = Text::FromNodeOrNull(previous)) {
MergeWithNextTextNode(*text, aRv);
}
}
already_AddRefed<ElementInternals> nsGenericHTMLElement::AttachInternals(

Просмотреть файл

@ -169,9 +169,14 @@ class nsGenericHTMLElement : public nsGenericHTMLElementBase {
}
MOZ_CAN_RUN_SCRIPT
void GetInnerText(mozilla::dom::DOMString& aValue,
mozilla::ErrorResult& aError);
void SetInnerText(const nsAString& aValue);
void GetInnerText(mozilla::dom::DOMString& aValue, ErrorResult& aError);
MOZ_CAN_RUN_SCRIPT
void GetOuterText(mozilla::dom::DOMString& aValue, ErrorResult& aError) {
return GetInnerText(aValue, aError);
}
MOZ_CAN_RUN_SCRIPT void SetInnerText(const nsAString& aValue);
MOZ_CAN_RUN_SCRIPT void SetOuterText(const nsAString& aValue,
ErrorResult& aRv);
void GetInputMode(nsAString& aValue) {
GetEnumAttr(nsGkAtoms::inputmode, nullptr, aValue);

Просмотреть файл

@ -27,6 +27,8 @@ interface HTMLElement : Element {
[CEReactions, GetterThrows, Pure]
attribute [LegacyNullToEmptyString] DOMString innerText;
[CEReactions, GetterThrows, SetterThrows, Pure]
attribute [LegacyNullToEmptyString] DOMString outerText;
// user interaction
[CEReactions, SetterThrows, Pure]

Просмотреть файл

@ -4,7 +4,3 @@
[translate on HTMLElement must enqueue an attributeChanged reaction when replacing an existing attribute]
expected: FAIL
[outerText on HTMLElement must enqueue a disconnected reaction]
expected: FAIL

Просмотреть файл

@ -1,22 +0,0 @@
[dynamic-getter.html]
[text-transform applied to child element ("<div id='target'><div id='child'>abc")]
expected: FAIL
[text-transform applied to parent element ("<div id='parent'><div id='target'>abc")]
expected: FAIL
[display: none applied to child element ("<div id='target'>abc<div id='child'>def")]
expected: FAIL
[display: none applied to parent element ("<div id='parent'>invisible<div id='target'>abc")]
expected: FAIL
[insert node into sub-tree ("<div id='target'>abc")]
expected: FAIL
[remove node from sub-tree ("<div id='target'>abc<div id='remove'>def")]
expected: FAIL
[insert whole sub-tree ("<div id='target'>")]
expected: FAIL

Просмотреть файл

@ -1,4 +0,0 @@
[getter-first-letter-marker-multicol.html]
[Test innerText/outerText for a combination of a list item with ::first-letter in multicol]
expected: FAIL

Просмотреть файл

@ -1,775 +1,24 @@
[getter.html]
[Simplest possible test ("<div>abc")]
expected: FAIL
[Leading whitespace removed ("<div> abc")]
expected: FAIL
[Trailing whitespace removed ("<div>abc ")]
expected: FAIL
[Internal whitespace compressed ("<div>abc def")]
expected: FAIL
[\\n converted to space ("<div>abc\\ndef")]
expected: FAIL
[\\r converted to space ("<div>abc\\rdef")]
expected: FAIL
[\\t converted to space ("<div>abc\\tdef")]
expected: FAIL
[Trailing whitespace before hard line break removed ("<div>abc <br>def")]
expected: FAIL
[Leading whitespace after hard line break removed ("<div>abc<br> def")]
expected: FAIL
[Leading whitespace preserved ("<pre> abc")]
expected: FAIL
[Trailing whitespace preserved ("<pre>abc ")]
expected: FAIL
[Internal whitespace preserved ("<pre>abc def")]
expected: FAIL
[\\n preserved ("<pre>abc\\ndef")]
expected: FAIL
[\\r converted to newline ("<pre>abc\\rdef")]
expected: FAIL
[\\t preserved ("<pre>abc\\tdef")]
expected: FAIL
[Two <pre> siblings ("<div><pre>abc</pre><pre>def</pre>")]
expected: FAIL
[Leading whitespace preserved ("<div style='white-space:pre'> abc")]
expected: FAIL
[Trailing whitespace preserved ("<div style='white-space:pre'>abc ")]
expected: FAIL
[Internal whitespace preserved ("<div style='white-space:pre'>abc def")]
expected: FAIL
[\\n preserved ("<div style='white-space:pre'>abc\\ndef")]
expected: FAIL
[\\r converted to newline ("<div style='white-space:pre'>abc\\rdef")]
expected: FAIL
[\\t preserved ("<div style='white-space:pre'>abc\\tdef")]
expected: FAIL
[Leading whitespace preserved ("<span style='white-space:pre'> abc")]
expected: FAIL
[Trailing whitespace preserved ("<span style='white-space:pre'>abc ")]
expected: FAIL
[Internal whitespace preserved ("<span style='white-space:pre'>abc def")]
expected: FAIL
[\\n preserved ("<span style='white-space:pre'>abc\\ndef")]
expected: FAIL
[\\r converted to newline ("<span style='white-space:pre'>abc\\rdef")]
expected: FAIL
[\\t preserved ("<span style='white-space:pre'>abc\\tdef")]
expected: FAIL
[Leading whitespace removed ("<div style='white-space:pre-line'> abc")]
expected: FAIL
[Trailing whitespace removed ("<div style='white-space:pre-line'>abc ")]
expected: FAIL
[Internal whitespace collapsed ("<div style='white-space:pre-line'>abc def")]
expected: FAIL
[\\n preserved ("<div style='white-space:pre-line'>abc\\ndef")]
expected: FAIL
[\\r converted to newline ("<div style='white-space:pre-line'>abc\\rdef")]
expected: FAIL
[\\t converted to space ("<div style='white-space:pre-line'>abc\\tdef")]
expected: FAIL
[Whitespace collapses across element boundaries ("<div><span>abc </span> def")]
expected: FAIL
[Whitespace collapses across element boundaries ("<div><span>abc </span><span></span> def")]
expected: FAIL
[Whitespace collapses across element boundaries ("<div><span>abc </span><span style='white-space:pre'></span> def")]
expected: FAIL
[Whitespace around <input> should not be collapsed ("<div>abc <input> def")]
expected: FAIL
[Whitespace around inline-block should not be collapsed ("<div>abc <span style='display:inline-block'></span> def")]
expected: FAIL
[Trailing space at end of inline-block should be collapsed ("<div>abc <span style='display:inline-block'> def </span> ghi")]
expected: FAIL
[Whitespace between <input> and block should be collapsed ("<div><input> <div>abc</div>")]
expected: FAIL
[Whitespace between inline-block and block should be collapsed ("<div><span style='inline-block'></span> <div>abc</div>")]
expected: FAIL
[Whitespace around <img> should not be collapsed ("<div>abc <img> def")]
expected: FAIL
[Whitespace around <img> should not be collapsed ("<div>abc <img width=1 height=1> def")]
expected: FAIL
[Leading whitesapce should not be collapsed ("<div><img> abc")]
expected: FAIL
[Trailing whitesapce should not be collapsed ("<div>abc <img>")]
expected: FAIL
[Whitespace around empty span should be collapsed ("<div>abc <b></b> def")]
expected: FAIL
[Whitespace around empty spans should be collapsed ("<div>abc <b><i></i></b> def")]
expected: FAIL
[<canvas> should not collapse following space ("<div><canvas></canvas> abc")]
expected: FAIL
[Replaced element <img> with display:block should be treated as block-level ("<div>abc <img style='display:block'> def")]
expected: FAIL
[Replaced element <canvas> with display:block should be treated as block-level ("<div>abc <canvas style='display:block'></canvas> def")]
expected: FAIL
[Soft line breaks ignored ("<div style='width:0'>abc def")]
expected: FAIL
[Soft line break at hyphen ignored ("<div style='width:0'>abc-def")]
expected: FAIL
[Whitespace text node preserved ("<div style='width:0'><span>abc</span> <span>def</span>")]
expected: FAIL
[Soft breaks ignored in presence of word-break:break-word ("<div style='width:1px; word-break:break-word'>Hello Kitty</div>")]
expected: FAIL
[Element boundaries ignored for soft break handling (1) ("<div style='width:1px; word-break:break-word'><x>Hello</x> <x>Kitty</x></div>")]
expected: FAIL
[Whitespace collapses across element boundaries at soft break (1) ("<div style='width:1px; word-break:break-word'><x>Hello</x> <x> Kitty</x></div>")]
expected: FAIL
[Element boundaries ignored for soft break handling (2) ("<div style='width:1px; word-break:break-word'><x>Hello</x><x> Kitty</x></div>")]
expected: FAIL
[Whitespace collapses across element boundaries at soft break (2) ("<div style='width:1px; word-break:break-word'><x>Hello </x> <x>Kitty</x></div>")]
expected: FAIL
[Element boundaries ignored for soft break handling (3) ("<div style='width:1px; word-break:break-word'><x>Hello </x><x>Kitty</x></div>")]
expected: FAIL
[Whitespace collapses across element boundaries at soft break (3) ("<div style='width:1px; word-break:break-word'><x>Hello </x><x> Kitty</x></div>")]
expected: FAIL
[Whitespace collapses across element boundaries at soft break (4) ("<div style='width:1px; word-break:break-word'><x>Hello </x> <x> Kitty</x></div>")]
expected: FAIL
[Element boundaries ignored for soft break handling (4) ("<div style='width:1px; word-break:break-word'><x>Hello</x> Kitty</div>")]
expected: FAIL
[Element boundaries ignored for soft break handling (5) ("<div style='width:1px; word-break:break-word'><x>Hello </x>Kitty</div>")]
expected: FAIL
[Soft breaks ignored, text-transform applied ("<div style='width:1px; word-break:break-word; text-transform:uppercase'>Hello Kitty</div>")]
expected: FAIL
[<br> returned as newline, following space collapsed ("<div style='width:1px; word-break:break-word'>Hello<br> Kitty</div>")]
expected: FAIL
[<br> returned as newline, preceding space collapsed ("<div style='width:1px; word-break:break-word'>Hello <br>Kitty</div>")]
expected: FAIL
[<br> returned as newline, adjacent spaces collapsed across element boundaries ("<div style='width:1px; word-break:break-word'><x>Hello </x> <br> <x> Kitty</x></div>")]
expected: FAIL
[::first-line styles applied ("<div class='first-line-uppercase' style='width:0'>abc def")]
expected: FAIL
[::first-letter styles applied ("<div class='first-letter-uppercase' style='width:0'>abc def")]
expected: FAIL
[::first-letter float ignored ("<div class='first-letter-float' style='width:0'>abc def")]
expected: FAIL
[&nbsp; preserved ("<div>&nbsp;")]
expected: FAIL
[display:none container ("<div style='display:none'>abc")]
expected: FAIL
[No whitespace compression in display:none container ("<div style='display:none'>abc def")]
expected: FAIL
[No removal of leading/trailing whitespace in display:none container ("<div style='display:none'> abc def ")]
expected: FAIL
[display:none child not rendered ("<div>123<span style='display:none'>abc")]
expected: FAIL
[display:none container with non-display-none target child ("<div style='display:none'><span id='target'>abc")]
expected: FAIL
[non-display-none child of svg ("<div id='target'>abc")]
expected: FAIL
[display:none child of svg ("<div style='display:none' id='target'>abc")]
expected: FAIL
[child of display:none child of svg ("<div style='display:none'><div id='target'>abc")]
expected: FAIL
[display:contents container ("<div style='display:contents'>abc")]
expected: FAIL
[display:contents container ("<div><div style='display:contents'>abc")]
expected: FAIL
[display:contents rendered ("<div>123<span style='display:contents'>abc")]
expected: FAIL
[display:contents not processed via textContent ("<div style='display:contents'> ")]
expected: FAIL
[display:contents not processed via textContent ("<div><div style='display:contents'> ")]
expected: FAIL
[visibility:hidden container ("<div style='visibility:hidden'>abc")]
expected: FAIL
[visibility:hidden child not rendered ("<div>123<span style='visibility:hidden'>abc")]
expected: FAIL
[visibility:visible child rendered ("<div style='visibility:hidden'>123<span style='visibility:visible'>abc")]
expected: FAIL
[visibility:collapse row-group ("<table><tbody style='visibility:collapse'><tr><td>abc")]
expected: FAIL
[visibility:collapse row ("<table><tr style='visibility:collapse'><td>abc")]
expected: FAIL
[visibility:collapse cell ("<table><tr><td style='visibility:collapse'>abc")]
expected: FAIL
[visibility:collapse row-group with visible cell ("<table><tbody style='visibility:collapse'><tr><td style='visibility:visible'>abc")]
expected: FAIL
[visibility:collapse row with visible cell ("<table><tr style='visibility:collapse'><td style='visibility:visible'>abc")]
expected: FAIL
[visibility:collapse honored on flex item ("<div style='display:flex'><span style='visibility:collapse'>1</span><span>2</span></div>")]
expected: FAIL
[visibility:collapse honored on grid item ("<div style='display:grid'><span style='visibility:collapse'>1</span><span>2</span></div>")]
expected: FAIL
[opacity:0 container ("<div style='opacity:0'>abc")]
expected: FAIL
[Whitespace compression in opacity:0 container ("<div style='opacity:0'>abc def")]
expected: FAIL
[Remove leading/trailing whitespace in opacity:0 container ("<div style='opacity:0'> abc def ")]
expected: FAIL
[opacity:0 child rendered ("<div>123<span style='opacity:0'>abc")]
expected: FAIL
[Generated content not included ("<div class='before'>")]
expected: FAIL
[Generated content on child not included ("<div><div class='before'>")]
expected: FAIL
[<button> contents preserved ("<button>abc")]
expected: FAIL
[<fieldset> contents preserved ("<fieldset>abc")]
expected: FAIL
[<fieldset> <legend> contents preserved ("<fieldset><legend>abc")]
expected: FAIL
[<input> contents ignored ("<input type='text' value='abc'>")]
expected: FAIL
[<textarea> contents ignored ("<textarea>abc")]
expected: FAIL
[<iframe> contents ignored ("<iframe>abc")]
expected: FAIL
[<iframe> contents ignored ("<iframe><div id='target'>abc")]
expected: FAIL
[<iframe> subdocument ignored ("<iframe src='data:text/html,abc'>")]
expected: FAIL
[<audio> contents ignored ("<audio style='display:block'>abc")]
expected: FAIL
[<audio> contents ok for element not being rendered ("<audio style='display:block'><source id='target' class='poke' style='display:block'>")]
expected: FAIL
[<audio> contents ok for element not being rendered ("<audio style='display:block'><source id='target' class='poke' style='display:none'>")]
expected: FAIL
[<video> contents ignored ("<video>abc")]
expected: FAIL
[<video> contents ok for element not being rendered ("<video style='display:block'><source id='target' class='poke' style='display:block'>")]
expected: FAIL
[<video> contents ok for element not being rendered ("<video style='display:block'><source id='target' class='poke' style='display:none'>")]
expected: FAIL
[<canvas> contents ignored ("<canvas>abc")]
expected: FAIL
[<canvas><div id='target'> contents ok for element not being rendered ("<canvas><div id='target'>abc")]
expected: FAIL
[<img> alt text ignored ("<img alt='abc'>")]
expected: FAIL
[<img> contents ignored ("<img src='about:blank' class='poke'>")]
expected: FAIL
[<svg> text contents preserved ("<div><svg><text>abc</text></svg></div>")]
expected: FAIL
[<svg><defs> text contents ignored ("<div><svg><defs><text>abc</text></defs></svg></div>")]
expected: FAIL
[<svg> non-rendered text ignored ("<div><svg><stop>abc</stop></svg></div>")]
expected: FAIL
[<foreignObject> contents preserved ("<svg><foreignObject><span id='target'>abc</span></foreignObject></svg>")]
expected: FAIL
[<select size='1'> contents of options preserved ("<select size='1'><option>abc</option><option>def")]
expected: FAIL
[<select size='2'> contents of options preserved ("<select size='2'><option>abc</option><option>def")]
expected: FAIL
[<select size='1'> contents of target option preserved ("<select size='1'><option id='target'>abc</option><option>def")]
expected: FAIL
[<select size='2'> contents of target option preserved ("<select size='2'><option id='target'>abc</option><option>def")]
expected: FAIL
[empty <select> ("<div>a<select></select>bc")]
expected: FAIL
[empty <optgroup> in <select> ("<div>a<select><optgroup></select>bc")]
expected: FAIL
[empty <option> in <select> ("<div>a<select><option></select>bc")]
expected: FAIL
[<select> containing text node child ("<select class='poke'></select>")]
expected: FAIL
[<optgroup> containing <optgroup> ("<select><optgroup class='poke-optgroup'></select>")]
expected: FAIL
[<optgroup> containing <option> ("<select><optgroup><option>abc</select>")]
expected: FAIL
[<div> in <option> ("<select><option class='poke-div'>123</select>")]
expected: FAIL
[empty <optgroup> in <div> ("<div>a<optgroup></optgroup>bc")]
expected: FAIL
[<optgroup> in <div> ("<div>a<optgroup>123</optgroup>bc")]
expected: FAIL
[empty <option> in <div> ("<div>a<option></option>bc")]
expected: FAIL
[<option> in <div> ("<div>a<option>123</option>bc")]
expected: FAIL
[<button> contents preserved ("<div><button>abc")]
expected: FAIL
[<fieldset> contents preserved ("<div><fieldset>abc")]
expected: FAIL
[<fieldset> <legend> contents preserved ("<div><fieldset><legend>abc")]
expected: FAIL
[<input> contents ignored ("<div><input type='text' value='abc'>")]
expected: FAIL
[<textarea> contents ignored ("<div><textarea>abc")]
expected: FAIL
[<select size='1'> contents of options preserved ("<div><select size='1'><option>abc</option><option>def")]
expected: FAIL
[<select size='2'> contents of options preserved ("<div><select size='2'><option>abc</option><option>def")]
expected: FAIL
[<iframe> contents ignored ("<div><iframe>abc")]
expected: FAIL
[ <iframe> subdocument ignored ("<div><iframe src='data:text/html,abc'>")]
expected: FAIL
[<audio> contents ignored ("<div><audio>abc")]
expected: FAIL
[<video> contents ignored ("<div><video>abc")]
expected: FAIL
[<canvas> contents ignored ("<div><canvas>abc")]
expected: FAIL
[<img> alt text ignored ("<div><img alt='abc'>")]
expected: FAIL
[Newline at block boundary ("<div>123<div>abc</div>def")]
expected: FAIL
[Newline at display:block boundary ("<div>123<span style='display:block'>abc</span>def")]
expected: FAIL
[Empty block induces single line break ("<div>abc<div></div>def")]
expected: FAIL
[Consecutive empty blocks ignored ("<div>abc<div></div><div></div>def")]
expected: FAIL
[No blank lines around <p> alone ("<div><p>abc")]
expected: FAIL
[No blank lines around <p> followed by only collapsible whitespace ("<div><p>abc</p> ")]
expected: FAIL
[No blank lines around <p> preceded by only collapsible whitespace ("<div> <p>abc</p>")]
expected: FAIL
[Blank line between consecutive <p>s ("<div><p>abc<p>def")]
expected: FAIL
[Blank line between consecutive <p>s separated only by collapsible whitespace ("<div><p>abc</p> <p>def")]
expected: FAIL
[Blank line between consecutive <p>s separated only by empty block ("<div><p>abc</p><div></div><p>def")]
expected: FAIL
[Blank lines between <p>s separated by non-empty block ("<div><p>abc</p><div>123</div><p>def")]
expected: FAIL
[Blank lines around a <p> in its own block ("<div>abc<div><p>123</p></div>def")]
expected: FAIL
[Blank line before <p> ("<div>abc<p>def")]
expected: FAIL
[Blank line after <p> ("<div><p>abc</p>def")]
expected: FAIL
[One blank line between <p>s, ignoring empty <p>s ("<div><p>abc<p></p><p></p><p>def")]
expected: FAIL
[Invisible <p> doesn't induce extra line breaks ("<div style='visibility:hidden'><p><span style='visibility:visible'>abc</span></p>\\n<div style='visibility:visible'>def</div>")]
expected: FAIL
[No blank lines around <div> with margin ("<div>abc<div style='margin:2em'>def")]
expected: FAIL
[No newlines at display:inline-block boundary ("<div>123<span style='display:inline-block'>abc</span>def")]
expected: FAIL
[Leading/trailing space removal at display:inline-block boundary ("<div>123<span style='display:inline-block'> abc </span>def")]
expected: FAIL
[Blank lines around <p> even without margin ("<div>123<p style='margin:0px'>abc</p>def")]
expected: FAIL
[No blank lines around <h1> ("<div>123<h1>abc</h1>def")]
expected: FAIL
[No blank lines around <h2> ("<div>123<h2>abc</h2>def")]
expected: FAIL
[No blank lines around <h3> ("<div>123<h3>abc</h3>def")]
expected: FAIL
[No blank lines around <h4> ("<div>123<h4>abc</h4>def")]
expected: FAIL
[No blank lines around <h5> ("<div>123<h5>abc</h5>def")]
expected: FAIL
[No blank lines around <h6> ("<div>123<h6>abc</h6>def")]
expected: FAIL
[<span> boundaries are irrelevant ("<div>123<span>abc</span>def")]
expected: FAIL
[<span> boundaries are irrelevant ("<div>123 <span>abc</span> def")]
expected: FAIL
[<span> boundaries are irrelevant ("<div style='width:0'>123 <span>abc</span> def")]
expected: FAIL
[<em> gets no special treatment ("<div>123<em>abc</em>def")]
expected: FAIL
[<b> gets no special treatment ("<div>123<b>abc</b>def")]
expected: FAIL
[<i> gets no special treatment ("<div>123<i>abc</i>def")]
expected: FAIL
[<strong> gets no special treatment ("<div>123<strong>abc</strong>def")]
expected: FAIL
[<tt> gets no special treatment ("<div>123<tt>abc</tt>def")]
expected: FAIL
[<code> gets no special treatment ("<div>123<code>abc</code>def")]
expected: FAIL
[soft hyphen preserved ("<div>abc&shy;def")]
expected: FAIL
[soft hyphen preserved ("<div style='width:0'>abc&shy;def")]
expected: FAIL
[Ignoring non-rendered table whitespace ("<div><table style='white-space:pre'> <td>abc</td> </table>")]
expected: FAIL
[Tab-separated table cells ("<div><table><tr><td>abc<td>def</table>")]
expected: FAIL
[Tab-separated table cells including empty cells ("<div><table><tr><td>abc<td><td>def</table>")]
expected: FAIL
[Tab-separated table cells including trailing empty cells ("<div><table><tr><td>abc<td><td></table>")]
expected: FAIL
[Newline-separated table rows ("<div><table><tr><td>abc<tr><td>def</table>")]
expected: FAIL
[Newlines around table ("<div>abc<table><td>def</table>ghi")]
expected: FAIL
[Tab-separated table cells in a border-collapse table ("<div><table style='border-collapse:collapse'><tr><td>abc<td>def</table>")]
expected: FAIL
[tfoot not reordered ("<div><table><tfoot>x</tfoot><tbody>y</tbody></table>")]
expected: FAIL
[ ("<table><tfoot><tr><td>footer</tfoot><thead><tr><td style='visibility:collapse'>thead</thead><tbody><tr><td>tbody</tbody></table>")]
expected: FAIL
[No tab on table-cell itself ("<table><tr><td id=target>abc</td><td>def</td>")]
expected: FAIL
[No newline on table-row itself ("<table><tr id=target><td>abc</td><td>def</td></tr><tr id=target><td>ghi</td><td>jkl</td></tr>")]
expected: FAIL
[Newline between cells and caption ("<div><table><tr><td>abc<caption>def</caption></table>")]
expected: FAIL
[Tab-separated table cells ("<div><div class='table'><span class='cell'>abc</span>\\n<span class='cell'>def</span></div>")]
expected: FAIL
[Newline-separated table rows ("<div><div class='table'><span class='row'><span class='cell'>abc</span></span>\\n<span class='row'><span class='cell'>def</span></span></div>")]
expected: FAIL
[Newlines around table ("<div>abc<div class='table'><span class='cell'>def</span></div>ghi")]
expected: FAIL
[Tab-separated table cells ("<div><div class='itable'><span class='cell'>abc</span>\\n<span class='cell'>def</span></div>")]
expected: FAIL
[Newline-separated table rows ("<div><div class='itable'><span class='row'><span class='cell'>abc</span></span>\\n<span class='row'><span class='cell'>def</span></span></div>")]
expected: FAIL
[No newlines around inline-table ("<div>abc<div class='itable'><span class='cell'>def</span></div>ghi")]
expected: FAIL
[Single newline in two-row inline-table ("<div>abc<div class='itable'><span class='row'><span class='cell'>def</span></span>\\n<span class='row'><span class='cell'>123</span></span></div>ghi")]
expected: FAIL
[display:table-row on the element itself ("<div style='display:table-row'>")]
expected: FAIL
[display:table-cell on the element itself ("<div style='display:table-cell'>")]
expected: FAIL
[display:table-caption on the element itself ("<div style='display:table-caption'>")]
expected: FAIL
[<ol> list items get no special treatment ("<div><ol><li>abc")]
expected: FAIL
[<ul> list items get no special treatment ("<div><ul><li>abc")]
expected: FAIL
[display:block <script> is rendered ("<div><script style='display:block'>abc")]
expected: FAIL
[display:block <style> is rendered ("<div><style style='display:block'>abc")]
expected: FAIL
[display:block <noscript> is not rendered (it's not parsed!) ("<div><noscript style='display:block'>abc")]
expected: FAIL
[display:block <template> contents are not rendered (the contents are in a different document) ("<div><template style='display:block'>abc")]
expected: FAIL
[<br> induces line break ("<div>abc<br>def")]
expected: FAIL
[<br> induces line break even at end of block ("<div>abc<br>")]
expected: FAIL
[<br> content ignored ("<div><br class='poke'>")]
expected: FAIL
[<hr> induces line break ("<div>abc<hr>def")]
expected: FAIL
[<hr><hr> induces just one line break ("<div>abc<hr><hr>def")]
expected: FAIL
[<hr><hr><hr> induces just one line break ("<div>abc<hr><hr><hr>def")]
expected: FAIL
[<hr> content rendered ("<div><hr class='poke'>")]
expected: FAIL
[comment ignored ("<div>abc<!--comment-->def")]
expected: FAIL
[<br> ("<br>")]
expected: FAIL
[empty <p> ("<p>")]
expected: FAIL
[empty <div> ("<div>")]
expected: FAIL
[text-transform is applied ("<div><div style='text-transform:uppercase'>abc")]
expected: FAIL
[text-transform handles es-zet ("<div><div style='text-transform:uppercase'>Maß")]
expected: FAIL
[text-transform handles Turkish casing ("<div><div lang='tr' style='text-transform:uppercase'>i ı")]
expected: FAIL
[block-in-inline doesn't add unnecessary newlines ("<div>abc<span>123<div>456</div>789</span>def")]
expected: FAIL
[floats induce a block boundary ("<div>abc<div style='float:left'>123</div>def")]
expected: FAIL
[floats induce a block boundary ("<div>abc<span style='float:left'>123</span>def")]
expected: FAIL
[float on the element itself ("<div style='float:left'>123")]
expected: FAIL
[position:absolute induces a block boundary ("<div>abc<div style='position:absolute'>123</div>def")]
expected: FAIL
[position:absolute induces a block boundary ("<div>abc<span style='position:absolute'>123</span>def")]
expected: FAIL
[position:absolute on the element itself ("<div style='position:absolute'>123")]
expected: FAIL
[position:relative has no effect ("<div>abc<div style='position:relative'>123</div>def")]
expected: FAIL
[position:relative has no effect ("<div>abc<span style='position:relative'>123</span>def")]
expected: FAIL
[overflow:hidden ignored ("<div style='overflow:hidden'>abc")]
expected: FAIL
[overflow:hidden ignored even with zero width ("<div style='width:0; overflow:hidden'>abc")]
expected: FAIL
[overflow:hidden ignored even with zero height ("<div style='height:0; overflow:hidden'>abc")]
expected: FAIL
[text-overflow:ellipsis ignored ("<div style='width:0; overflow:hidden; text-overflow:ellipsis'>abc")]
expected: FAIL
[innerText not supported on SVG elements ("<svg>abc")]
expected: FAIL
[innerText not supported on MathML elements ("<math>abc")]
expected: FAIL
[<rt> and no <rp> ("<div><ruby>abc<rt>def</rt></ruby>")]
expected: FAIL
[<rp> ("<div><ruby>abc<rp>(</rp><rt>def</rt><rp>)</rp></ruby>")]
expected: FAIL
[Lone <rp> ("<div><rp>abc</rp>")]
expected: FAIL
[visibility:hidden <rp> ("<div><rp style='visibility:hidden'>abc</rp>")]
expected: FAIL
[display:block <rp> ("<div><rp style='display:block'>abc</rp>def")]
expected: FAIL
[display:block <rp> with whitespace ("<div><rp style='display:block'> abc </rp>def")]
expected: FAIL
[<rp> in a <select> ("<div><select class='poke-rp'></select>")]
expected: FAIL
[Shadow DOM contents ignored ("<div class='shadow'>")]
expected: FAIL
[Shadow DOM contents ignored ("<div><div class='shadow'>")]
expected: FAIL
[CSS 'order' property ignored ("<div style='display:flex'><div style='order:1'>1</div><div>2</div></div>")]
expected: FAIL
[Flex items blockified ("<div style='display:flex'><span>1</span><span>2</span></div>")]
expected: FAIL
[CSS 'order' property ignored ("<div style='display:grid'><div style='order:1'>1</div><div>2</div></div>")]
expected: FAIL
[Grid items blockified ("<div style='display:grid'><span>1</span><span>2</span></div>")]
expected: FAIL

Просмотреть файл

@ -1,4 +0,0 @@
[multiple-text-nodes.window.html]
[Ensure multiple text nodes get rendered properly]
expected: FAIL

Просмотреть файл

@ -1,115 +0,0 @@
[outertext-setter.html]
[Replacing a node and merging with the previous text node]
expected: FAIL
[Replacing a node and merging with the following text node]
expected: FAIL
[Replacing a node and merging with the previous and following text node]
expected: FAIL
[Only merges with the previous and following text nodes, does not completely normalize]
expected: FAIL
[Removing a node]
expected: FAIL
[Detached node]
expected: FAIL
[Simplest possible test]
expected: FAIL
[Newlines convert to <br> in non-white-space:pre elements]
expected: FAIL
[Newlines convert to <br> in <pre> element]
expected: FAIL
[Newlines convert to <br> in <textarea> element]
expected: FAIL
[Newlines convert to <br> in white-space:pre element]
expected: FAIL
[CRs convert to <br> in non-white-space:pre elements]
expected: FAIL
[CRs convert to <br> in <pre> element]
expected: FAIL
[Newline/CR pair converts to <br> in non-white-space:pre element]
expected: FAIL
[Newline/newline pair converts to two <br>s in non-white-space:pre element]
expected: FAIL
[CR/CR pair converts to two <br>s in non-white-space:pre element]
expected: FAIL
[CRs convert to <br> in white-space:pre element]
expected: FAIL
[< preserved]
expected: FAIL
[> preserved]
expected: FAIL
[& preserved]
expected: FAIL
[" preserved]
expected: FAIL
[' preserved]
expected: FAIL
[Null characters preserved]
expected: FAIL
[Tabs preserved]
expected: FAIL
[Leading whitespace preserved]
expected: FAIL
[Trailing whitespace preserved]
expected: FAIL
[Whitespace not compressed]
expected: FAIL
[Existing text deleted]
expected: FAIL
[Existing <br> deleted]
expected: FAIL
[Assigning the empty string]
expected: FAIL
[Assigning null]
expected: FAIL
[Assigning undefined]
expected: FAIL
[Start with CR]
expected: FAIL
[Start with LF]
expected: FAIL
[Start with CRLF]
expected: FAIL
[End with CR]
expected: FAIL
[End with LF]
expected: FAIL
[End with CRLF]
expected: FAIL

Просмотреть файл

@ -753,7 +753,6 @@ prefs: [dom.security.featurePolicy.experimental.enabled:true, dom.security.featu
[idlharness.https.html?include=HTML.*]
prefs: [dom.dialog_element.enabled:true, gfx.offscreencanvas.enabled:true]
[HTMLInputElement interface: attribute dirName]
expected: FAIL
@ -934,12 +933,6 @@ prefs: [dom.security.featurePolicy.experimental.enabled:true, dom.security.featu
[HTMLIFrameElement interface: document.createElement("iframe") must inherit property "loading" with the proper type]
expected: FAIL
[HTMLElement interface: attribute outerText]
expected: FAIL
[HTMLElement interface: document.createElement("noscript") must inherit property "outerText" with the proper type]
expected: FAIL
[HTMLElement interface: attribute oncontextlost]
expected: FAIL

Просмотреть файл

@ -62,6 +62,33 @@ test(t => {
assert_equals(container.childNodes[2].data, "E");
}, "Only merges with the previous and following text nodes, does not completely normalize");
test(t => {
const container = document.getElementById("container");
t.add_cleanup(() => { container.textContent = ""; });
container.append(document.createElement("span"));
const node = container.childNodes[0];
// https://github.com/whatwg/html/issues/7508
node.outerText = "";
assert_equals(container.childNodes.length, 1, "Creates text node for the empty string");
assert_equals(container.childNodes[0].data, "");
}, "Empty string");
test(t => {
const container = document.getElementById("container");
t.add_cleanup(() => { container.textContent = ""; });
container.append("1", "2", document.createElement("span"), "3", "4");
const node = container.childNodes[2];
node.outerText = "";
assert_equals(container.childNodes.length, 3, "It got merged with the previous and following text node");
assert_equals(container.childNodes[0].data, "1");
assert_equals(container.childNodes[1].data, "23");
assert_equals(container.childNodes[2].data, "4");
}, "Empty string with surrounding text nodes");
test(() => {
const node = document.getElementById("testRemove");
const parent = node.parentNode;