Commit 9537e32b authored by Xiaocheng Hu's avatar Xiaocheng Hu Committed by Commit Bot

[EditingNG] Remove spaces before <br> from some layout tests

Legacy layout has a bug that, whitespaces before <br> are not collapsed
(https://crbug.com/40634). The issue is fixed in NG.

This difference results in that, in some editing/selection layout tests,
one less character is moved through when EditingNG is enabled, so these
tests fail.

This patch removes the spaces before <br> so that these tests pass.

Bug: 707656
Change-Id: I4256865abb0a1fe925cfa584fe111b8ba8312332
Reviewed-on: https://chromium-review.googlesource.com/1185998Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#585548}
parent 98ccf1c6
...@@ -15,26 +15,26 @@ test(() => assert_selection( ...@@ -15,26 +15,26 @@ test(() => assert_selection(
test(() => assert_selection( test(() => assert_selection(
[ [
'<div contenteditable>', '<div contenteditable>',
'|a<img src="../../resources/abe.png">new', '|a<img src="../../resources/abe.png">new<br>',
'<br>nation <i> </i> <img src="../../resources/abe.png">', 'nation <i> </i> <img src="../../resources/abe.png">',
'', '',
'', '',
'conceived', 'conceived<br>',
'<br>nation<img src="../../resources/abe.png">', 'nation<img src="../../resources/abe.png">',
'</div>', '</div>',
].join(' '), ].join(' '),
selection => { selection => {
for (var i = 0; i < 33; ++i) for (var i = 0; i < 31; ++i)
selection.modify('extend', 'forward', 'character'); selection.modify('extend', 'forward', 'character');
}, },
[ [
'<div contenteditable>', '<div contenteditable>',
'^a<img src="../../resources/abe.png">new', '^a<img src="../../resources/abe.png">new<br>',
'<br>nation <i> </i> <img src="../../resources/abe.png">', 'nation <i> </i> <img src="../../resources/abe.png">',
'', '',
'', '',
'conceived', 'conceived<br>',
'<br>nation|<img src="../../resources/abe.png">', 'nation|<img src="../../resources/abe.png">',
'</div>', '</div>',
].join(' ')), ].join(' ')),
'extend forward character through image'); 'extend forward character through image');
...@@ -44,20 +44,20 @@ test(() => assert_selection( ...@@ -44,20 +44,20 @@ test(() => assert_selection(
'<div contenteditable>', '<div contenteditable>',
'<i>F |and seven</i> years <b> as </b>our fathers f upon this', '<i>F |and seven</i> years <b> as </b>our fathers f upon this',
'continent, a new nation, conceived &nbsp;&nbsp; in Liberty, and dedicated to the', 'continent, a new nation, conceived &nbsp;&nbsp; in Liberty, and dedicated to the',
'proposition that all ', 'proposition that all<br>',
'<br>men are created equal.', 'men are created equal.',
'</div>', '</div>',
].join(' '), ].join(' '),
selection => { selection => {
for (var i = 0; i < 157; ++i) for (var i = 0; i < 156; ++i)
selection.modify('extend', 'forward', 'character'); selection.modify('extend', 'forward', 'character');
}, },
[ [
'<div contenteditable>', '<div contenteditable>',
'<i>F ^and seven</i> years <b> as </b>our fathers f upon this', '<i>F ^and seven</i> years <b> as </b>our fathers f upon this',
'continent, a new nation, conceived \u{00A0}\u{00A0} in Liberty, and dedicated to the', 'continent, a new nation, conceived \u{00A0}\u{00A0} in Liberty, and dedicated to the',
'proposition that all ', 'proposition that all<br>',
'<br>men are created equal|.', 'men are created equal|.',
'</div>', '</div>',
].join(' ')), ].join(' ')),
'extend forward character through multiple spaces'); 'extend forward character through multiple spaces');
...@@ -65,26 +65,26 @@ test(() => assert_selection( ...@@ -65,26 +65,26 @@ test(() => assert_selection(
test(() => assert_selection( test(() => assert_selection(
[ [
'<div contenteditable>', '<div contenteditable>',
'a<img src="../../resources/abe.png">new', 'a<img src="../../resources/abe.png">new<br>',
'<br>nation <i> </i> <img src="../../resources/abe.png">', 'nation <i> </i> <img src="../../resources/abe.png">',
'', '',
'', '',
'conceived', 'conceived<br>',
'<br>nation|<img src="../../resources/abe.png">', 'nation|<img src="../../resources/abe.png">',
'</div>', '</div>',
].join(' '), ].join(' '),
selection => { selection => {
for (var i = 0; i < 30; ++i) for (var i = 0; i < 28; ++i)
selection.modify('extend', 'backward', 'character'); selection.modify('extend', 'backward', 'character');
}, },
[ [
'<div contenteditable>', '<div contenteditable>',
'a<img src="../../resources/abe.png">n|ew', 'a<img src="../../resources/abe.png">n|ew<br>',
'<br>nation <i> </i> <img src="../../resources/abe.png">', 'nation <i> </i> <img src="../../resources/abe.png">',
'', '',
'', '',
'conceived', 'conceived<br>',
'<br>nation^<img src="../../resources/abe.png">', 'nation^<img src="../../resources/abe.png">',
'</div>', '</div>',
].join(' ')), ].join(' ')),
'extend backward character through image'); 'extend backward character through image');
...@@ -94,20 +94,20 @@ test(() => assert_selection( ...@@ -94,20 +94,20 @@ test(() => assert_selection(
'<div contenteditable>', '<div contenteditable>',
'<i>F and seven</i> years <b> as </b>our fathers f upon this', '<i>F and seven</i> years <b> as </b>our fathers f upon this',
'continent, a new nation, conceived &nbsp;&nbsp; in Liberty, and dedicated to the', 'continent, a new nation, conceived &nbsp;&nbsp; in Liberty, and dedicated to the',
'proposition that all ', 'proposition that all<br>',
'<br>men are created equ|al.', 'men are created equ|al.',
'</div>', '</div>',
].join(' '), ].join(' '),
selection => { selection => {
for (var i = 0; i < 157; ++i) for (var i = 0; i < 156; ++i)
selection.modify('extend', 'backward', 'character'); selection.modify('extend', 'backward', 'character');
}, },
[ [
'<div contenteditable>', '<div contenteditable>',
'<i>|F and seven</i> years <b> as </b>our fathers f upon this', '<i>|F and seven</i> years <b> as </b>our fathers f upon this',
'continent, a new nation, conceived \u{00A0}\u{00A0} in Liberty, and dedicated to the', 'continent, a new nation, conceived \u{00A0}\u{00A0} in Liberty, and dedicated to the',
'proposition that all ', 'proposition that all<br>',
'<br>men are created equ^al.', 'men are created equ^al.',
'</div>', '</div>',
].join(' ')), ].join(' ')),
'extend backward character through multiple spaces'); 'extend backward character through multiple spaces');
......
...@@ -3,20 +3,20 @@ ...@@ -3,20 +3,20 @@
<script src="../../../resources/testharnessreport.js"></script> <script src="../../../resources/testharnessreport.js"></script>
<body> <body>
<div contenteditable id="root" class="editing"> <div contenteditable id="root" class="editing">
<span id="sample">a<img src="../../resources/abe.png">new <span id="sample">a<img src="../../resources/abe.png">new<br>
<br>nation <i> </i> <img src="../../resources/abe.png"> conceived nation <i> </i> <img src="../../resources/abe.png"> conceived<br>
<br>nation<img src="../../resources/abe.png"></span> nation<img src="../../resources/abe.png"></span>
</div> </div>
<div id="log"></div> <div id="log"></div>
<script> <script>
test(function() { test(function() {
var selection = window.getSelection(); var selection = window.getSelection();
selection.collapse(sample, 0); selection.collapse(sample, 0);
for (i = 0; i < 33; ++i) for (i = 0; i < 31; ++i)
selection.modify('move', 'forward', 'character'); selection.modify('move', 'forward', 'character');
assert_true(selection.isCollapsed, 'isCollapsed'); assert_true(selection.isCollapsed, 'isCollapsed');
assert_equals(selection.anchorNode, sample.childNodes[10], 'anchorNode'); assert_equals(selection.anchorNode, sample.childNodes[10], 'anchorNode');
assert_equals(selection.anchorOffset, 6, 'anchorOffset'); assert_equals(selection.anchorOffset, 7, 'anchorOffset');
}); });
</script> </script>
......
...@@ -5,19 +5,19 @@ ...@@ -5,19 +5,19 @@
<div contenteditable id="root" class="editing"> <div contenteditable id="root" class="editing">
<span id="sample"><i>F and seven</i> years <b> as </b>our fathers f upon this <span id="sample"><i>F and seven</i> years <b> as </b>our fathers f upon this
continent, a new nation, conceived &nbsp;&nbsp; in Liberty, and dedicated to the continent, a new nation, conceived &nbsp;&nbsp; in Liberty, and dedicated to the
proposition that all proposition that all<br>
<br>men are created equal.</span> men are created equal.</span>
</div> </div>
<div id="log"></div> <div id="log"></div>
<script> <script>
test(function () { test(function () {
var selection = window.getSelection(); var selection = window.getSelection();
selection.collapse(sample, 0); selection.collapse(sample, 0);
for (i = 0; i < 159; ++i) for (i = 0; i < 158; ++i)
selection.modify('move', 'forward', 'character'); selection.modify('move', 'forward', 'character');
assert_true(selection.isCollapsed, 'isCollapsed'); assert_true(selection.isCollapsed, 'isCollapsed');
assert_equals(selection.anchorNode, sample.childNodes[5], 'anchorNode'); assert_equals(selection.anchorNode, sample.childNodes[5], 'anchorNode');
assert_equals(selection.anchorOffset, 21, 'anchorOffset'); assert_equals(selection.anchorOffset, 22, 'anchorOffset');
}); });
</script> </script>
......
...@@ -3,18 +3,18 @@ ...@@ -3,18 +3,18 @@
<script src="../../../resources/testharnessreport.js"></script> <script src="../../../resources/testharnessreport.js"></script>
<body> <body>
<div contenteditable id="root" class="editing"> <div contenteditable id="root" class="editing">
<span id="sample">a<img src="../../resources/abe.png">new <span id="sample">a<img src="../../resources/abe.png">new<br>
<br>nation <i> </i> <img src="../../resources/abe.png"> conceived nation <i> </i> <img src="../../resources/abe.png"> conceived<br>
<br>nation<img src="../../resources/abe.png"></span> nation<img src="../../resources/abe.png"></span>
</div> </div>
<div id="log"></div> <div id="log"></div>
<script> <script>
test(function () { test(function () {
var selection = window.getSelection(); var selection = window.getSelection();
selection.collapse(sample, 0); selection.collapse(sample, 0);
for (i = 0; i < 33; ++i) for (i = 0; i < 31; ++i)
selection.modify('move', 'forward', 'character'); selection.modify('move', 'forward', 'character');
for (i = 0; i < 32; ++i) for (i = 0; i < 30; ++i)
selection.modify('move', 'backward', 'character'); selection.modify('move', 'backward', 'character');
assert_true(selection.isCollapsed, 'isCollapsed'); assert_true(selection.isCollapsed, 'isCollapsed');
assert_equals(selection.anchorNode, sample.firstChild, 'anchorNode'); assert_equals(selection.anchorNode, sample.firstChild, 'anchorNode');
......
...@@ -5,17 +5,17 @@ ...@@ -5,17 +5,17 @@
<div contenteditable id="root" class="editing"> <div contenteditable id="root" class="editing">
<span id="sample"><i>F and seven</i> years <b> as </b>our fathers f upon this <span id="sample"><i>F and seven</i> years <b> as </b>our fathers f upon this
continent, a new nation, conceived &nbsp;&nbsp; in Liberty, and dedicated to the continent, a new nation, conceived &nbsp;&nbsp; in Liberty, and dedicated to the
proposition that all proposition that all<br>
<br>men are created equal.</span> men are created equal.</span>
</div> </div>
<div id="log"></div> <div id="log"></div>
<script> <script>
test(function() { test(function() {
var selection = window.getSelection(); var selection = window.getSelection();
selection.collapse(sample, 0); selection.collapse(sample, 0);
for (i = 0; i < 159; ++i)
selection.modify('move', 'forward', 'character');
for (i = 0; i < 158; ++i) for (i = 0; i < 158; ++i)
selection.modify('move', 'forward', 'character');
for (i = 0; i < 157; ++i)
selection.modify('move', 'backward', 'character'); selection.modify('move', 'backward', 'character');
assert_true(selection.isCollapsed, 'isCollapsed'); assert_true(selection.isCollapsed, 'isCollapsed');
assert_equals(selection.anchorNode, sample.firstChild.firstChild, 'anchorNode'); assert_equals(selection.anchorNode, sample.firstChild.firstChild, 'anchorNode');
......
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