Commit 05cbdfe5 authored by Owen Min's avatar Owen Min Committed by Commit Bot

Reland "innerText setter should not modify an existing Text child"

This reverts commit 43e1f5d7.

Reason for revert: Revert didn't fix the flaky test, reland the CL.

Original change's description:
> Revert "innerText setter should not modify an existing Text child"
> 
> This reverts commit 976ec7a9.
> 
> Reason for revert: crbug.com/938591
> 
> Original change's description:
> > innerText setter should not modify an existing Text child
> > 
> > We have an optimization reusing a Text child, but the standard doesn't
> > define such behavior, and Edge, Firefox, and Safari don't have it.
> > 
> > This CL might regress benchmarks.  We'll accept it.
> > 
> > Bug: 573309
> > Change-Id: I3aacae5d37e5a7685ce2d310944dfef8d6e4b13a
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1502338
> > Commit-Queue: Kent Tamura <tkent@chromium.org>
> > Auto-Submit: Kent Tamura <tkent@chromium.org>
> > Reviewed-by: Yoshifumi Inoue <yosin@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#637665}
> 
> TBR=yosin@chromium.org,tkent@chromium.org
> 
> Change-Id: Ib1884d8b20d9c8d10fc1566498cbdd719cc97b50
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: 573309
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1504128
> Reviewed-by: Owen Min <zmin@chromium.org>
> Commit-Queue: Owen Min <zmin@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#637805}

TBR=yosin@chromium.org,tkent@chromium.org,zmin@chromium.org

Change-Id: Id66ace389fd1b318b57b598e462182155a5f9d0b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 573309
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1505997Reviewed-by: default avatarOwen Min <zmin@chromium.org>
Commit-Queue: Owen Min <zmin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#638126}
parent cca15fbc
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<div id="live" aria-live="polite">Before</div> <div id="live" aria-live="polite">Before</div>
<script> <script>
function go() { function go() {
document.getElementById('live').innerText = 'After'; document.getElementById('live').firstChild.data = 'After';
} }
</script> </script>
</body> </body>
......
...@@ -737,22 +737,6 @@ void ReplaceChildrenWithText(ContainerNode* container, ...@@ -737,22 +737,6 @@ void ReplaceChildrenWithText(ContainerNode* container,
ChildListMutationScope mutation(*container_node); ChildListMutationScope mutation(*container_node);
// FIXME: This is wrong if containerNode->firstChild() has more than one ref!
// Example:
// <div>foo</div>
// <script>
// var oldText = div.firstChild;
// console.log(oldText.data); // foo
// div.innerText = "bar";
// console.log(oldText.data); // bar!?!
// </script>
// I believe this is an intentional benchmark cheat from years ago.
// We should re-visit if we actually want this still.
if (container_node->HasOneTextChild()) {
ToText(container_node->firstChild())->setData(text);
return;
}
// NOTE: This method currently always creates a text node, even if that text // NOTE: This method currently always creates a text node, even if that text
// node will be empty. // node will be empty.
Text* text_node = Text::Create(container_node->GetDocument(), text); Text* text_node = Text::Create(container_node->GetDocument(), text);
......
...@@ -30,7 +30,8 @@ async_test_after_layout_and_paint((t) => { ...@@ -30,7 +30,8 @@ async_test_after_layout_and_paint((t) => {
assert_equals(axInlineBefore1.name, 'two lines of text.'); assert_equals(axInlineBefore1.name, 'two lines of text.');
// Modify the text. // Modify the text.
document.getElementById("p").innerText += ' One more sentence.'; var p = document.getElementById("p");
p.firstChild.data = p.innerText + ' One more sentence.';
// Wait for a notification on the element before checking the new state. // Wait for a notification on the element before checking the new state.
axStaticText.addNotificationListener(t.step_func((notification) => { axStaticText.addNotificationListener(t.step_func((notification) => {
......
This is a testharness.js-based test.
Found 126 tests; 95 PASS, 31 FAIL, 0 TIMEOUT, 0 NOTRUN.
PASS Simplest possible test
PASS Simplest possible test, detached
PASS Newlines convert to <br> in non-white-space:pre elements
PASS Newlines convert to <br> in non-white-space:pre elements, detached
PASS Newlines convert to <br> in <pre> element
PASS Newlines convert to <br> in <pre> element, detached
PASS Newlines convert to <br> in <textarea> element
PASS Newlines convert to <br> in <textarea> element, detached
PASS Newlines convert to <br> in white-space:pre element
PASS Newlines convert to <br> in white-space:pre element, detached
PASS CRs convert to <br> in non-white-space:pre elements
PASS CRs convert to <br> in non-white-space:pre elements, detached
PASS CRs convert to <br> in <pre> element
PASS CRs convert to <br> in <pre> element, detached
PASS Newline/CR pair converts to <br> in non-white-space:pre element
PASS Newline/CR pair converts to <br> in non-white-space:pre element, detached
PASS Newline/newline pair converts to two <br>s in non-white-space:pre element
PASS Newline/newline pair converts to two <br>s in non-white-space:pre element, detached
PASS CR/CR pair converts to two <br>s in non-white-space:pre element
PASS CR/CR pair converts to two <br>s in non-white-space:pre element, detached
PASS CRs convert to <br> in white-space:pre element
PASS CRs convert to <br> in white-space:pre element, detached
PASS < preserved
PASS < preserved, detached
PASS > preserved
PASS > preserved, detached
PASS & preserved
PASS & preserved, detached
PASS " preserved
PASS " preserved, detached
PASS ' preserved
PASS ' preserved, detached
PASS innerText not supported on SVG elements
PASS innerText not supported on SVG elements, detached
PASS innerText not supported on MathML elements
PASS innerText not supported on MathML elements, detached
PASS Null characters preserved
PASS Null characters preserved, detached
PASS Tabs preserved
PASS Tabs preserved, detached
PASS Leading whitespace preserved
PASS Leading whitespace preserved, detached
PASS Trailing whitespace preserved
PASS Trailing whitespace preserved, detached
PASS Whitespace not compressed
PASS Whitespace not compressed, detached
FAIL Existing text deleted assert_not_equals: Child should be a *new* text node got disallowed value Text node "abc"
FAIL Existing text deleted, detached assert_not_equals: Child should be a *new* text node got disallowed value Text node "abc"
PASS Existing <br> deleted
PASS Existing <br> deleted, detached
PASS Assigning the empty string
PASS Assigning the empty string, detached
PASS Assigning null
PASS Assigning null, detached
PASS Assigning undefined
PASS Assigning undefined, detached
PASS Start with CR
PASS Start with CR, detached
PASS Start with LF
PASS Start with LF, detached
PASS Start with CRLF
PASS Start with CRLF, detached
PASS End with CR
PASS End with CR, detached
PASS End with LF
PASS End with LF, detached
PASS End with CRLF
PASS End with CRLF, detached
PASS innerText on <area> element
FAIL innerText on <area> element, detached assert_not_equals: Child should be a *new* text node got disallowed value Text node "abc"
PASS innerText on <base> element
FAIL innerText on <base> element, detached assert_not_equals: Child should be a *new* text node got disallowed value Text node "abc"
PASS innerText on <basefont> element
FAIL innerText on <basefont> element, detached assert_not_equals: Child should be a *new* text node got disallowed value Text node "abc"
PASS innerText on <bgsound> element
FAIL innerText on <bgsound> element, detached assert_not_equals: Child should be a *new* text node got disallowed value Text node "abc"
PASS innerText on <br> element
FAIL innerText on <br> element, detached assert_not_equals: Child should be a *new* text node got disallowed value Text node "abc"
PASS innerText on <col> element
FAIL innerText on <col> element, detached assert_not_equals: Child should be a *new* text node got disallowed value Text node "abc"
PASS innerText on <embed> element
FAIL innerText on <embed> element, detached assert_not_equals: Child should be a *new* text node got disallowed value Text node "abc"
PASS innerText on <frame> element
FAIL innerText on <frame> element, detached assert_not_equals: Child should be a *new* text node got disallowed value Text node "abc"
PASS innerText on <hr> element
FAIL innerText on <hr> element, detached assert_not_equals: Child should be a *new* text node got disallowed value Text node "abc"
PASS innerText on <image> element
FAIL innerText on <image> element, detached assert_not_equals: Child should be a *new* text node got disallowed value Text node "abc"
PASS innerText on <img> element
FAIL innerText on <img> element, detached assert_not_equals: Child should be a *new* text node got disallowed value Text node "abc"
PASS innerText on <input> element
FAIL innerText on <input> element, detached assert_not_equals: Child should be a *new* text node got disallowed value Text node "abc"
PASS innerText on <keygen> element
FAIL innerText on <keygen> element, detached assert_not_equals: Child should be a *new* text node got disallowed value Text node "abc"
PASS innerText on <link> element
FAIL innerText on <link> element, detached assert_not_equals: Child should be a *new* text node got disallowed value Text node "abc"
PASS innerText on <menuitem> element
FAIL innerText on <menuitem> element, detached assert_not_equals: Child should be a *new* text node got disallowed value Text node "abc"
PASS innerText on <meta> element
FAIL innerText on <meta> element, detached assert_not_equals: Child should be a *new* text node got disallowed value Text node "abc"
PASS innerText on <param> element
FAIL innerText on <param> element, detached assert_not_equals: Child should be a *new* text node got disallowed value Text node "abc"
PASS innerText on <source> element
FAIL innerText on <source> element, detached assert_not_equals: Child should be a *new* text node got disallowed value Text node "abc"
PASS innerText on <track> element
FAIL innerText on <track> element, detached assert_not_equals: Child should be a *new* text node got disallowed value Text node "abc"
PASS innerText on <wbr> element
FAIL innerText on <wbr> element, detached assert_not_equals: Child should be a *new* text node got disallowed value Text node "abc"
PASS innerText on <colgroup> element
FAIL innerText on <colgroup> element, detached assert_not_equals: Child should be a *new* text node got disallowed value Text node "abc"
PASS innerText on <frameset> element
FAIL innerText on <frameset> element, detached assert_not_equals: Child should be a *new* text node got disallowed value Text node "abc"
PASS innerText on <head> element
FAIL innerText on <head> element, detached assert_not_equals: Child should be a *new* text node got disallowed value Text node "abc"
PASS innerText on <html> element
FAIL innerText on <html> element, detached assert_not_equals: Child should be a *new* text node got disallowed value Text node "abc"
PASS innerText on <table> element
FAIL innerText on <table> element, detached assert_not_equals: Child should be a *new* text node got disallowed value Text node "abc"
PASS innerText on <tbody> element
FAIL innerText on <tbody> element, detached assert_not_equals: Child should be a *new* text node got disallowed value Text node "abc"
PASS innerText on <tfoot> element
FAIL innerText on <tfoot> element, detached assert_not_equals: Child should be a *new* text node got disallowed value Text node "abc"
PASS innerText on <thead> element
FAIL innerText on <thead> element, detached assert_not_equals: Child should be a *new* text node got disallowed value Text node "abc"
PASS innerText on <tr> element
FAIL innerText on <tr> element, detached assert_not_equals: Child should be a *new* text node got disallowed value Text node "abc"
Harness: the test ran to completion.
...@@ -99,8 +99,8 @@ function test() ...@@ -99,8 +99,8 @@ function test()
runTest('', 'innerText', '<a></a><b></b>', 'modified'); runTest('', 'innerText', '<a></a><b></b>', 'modified');
runTest('text', 'innerText', '', 'modified'); runTest('text', 'innerText', '', 'modified');
runTest('text', 'innerText', 'different text', 'modified, with same first child'); runTest('text', 'innerText', 'different text', 'modified');
runTest('text', 'innerText', 'text', 'modified, with same first child'); runTest('text', 'innerText', 'text', 'modified');
runTest('<a></a>', 'innerText', '', 'modified'); runTest('<a></a>', 'innerText', '', 'modified');
runTest('<a></a>', 'innerText', 'text', 'modified'); runTest('<a></a>', 'innerText', 'text', 'modified');
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<script> <script>
function repaintTest() function repaintTest()
{ {
document.getElementById("target").innerText += " la"; document.getElementById("target").firstChild.data += " la";
} }
</script> </script>
<script src="resources/text-based-repaint.js"></script> <script src="resources/text-based-repaint.js"></script>
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<script type="text/javascript"> <script type="text/javascript">
function repaintTest() function repaintTest()
{ {
document.getElementById("target").innerText = "PASS"; document.getElementById("target").firstChild.data = "PASS";
} }
</script> </script>
</head> </head>
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<script type="text/javascript"> <script type="text/javascript">
function repaintTest() function repaintTest()
{ {
document.getElementById("target").innerText = "PASS"; document.getElementById("target").firstChild.data = "PASS";
} }
</script> </script>
<style type="text/css" media="screen"> <style type="text/css" media="screen">
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
parent.scrollLeft = 10; parent.scrollLeft = 10;
function repaintTest() { function repaintTest() {
document.getElementById('target').innerText = 'after'; document.getElementById('target').firstChild.data = 'after';
} }
</script> </script>
</html> </html>
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
parent2.scrollLeft = 7; parent2.scrollLeft = 7;
function repaintTest() { function repaintTest() {
document.getElementById('target').innerText = 'after' document.getElementById('target').firstChild.data = 'after'
} }
</script> </script>
</html> </html>
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
parent.scrollLeft = 10; parent.scrollLeft = 10;
function repaintTest() { function repaintTest() {
document.getElementById('target').innerText = 'after'; document.getElementById('target').firstChild.data = 'after';
} }
</script> </script>
</html> </html>
...@@ -7,6 +7,6 @@ ...@@ -7,6 +7,6 @@
function repaintTest() function repaintTest()
{ {
target.innerText = " PASS ."; target.firstChild.data = " PASS .";
} }
</script> </script>
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<script type="text/javascript"> <script type="text/javascript">
function repaintTest() function repaintTest()
{ {
document.getElementById("target").innerText = "PASS"; document.getElementById("target").firstChild.data = "PASS";
} }
</script> </script>
<style type="text/css" media="screen"> <style type="text/css" media="screen">
......
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