Commit 973fe594 authored by Yoshifumi Inoue's avatar Yoshifumi Inoue Committed by Commit Bot

Utilize selection_test() in editing/selection/modify_move/move_backward_line_table.html

This patch changes "move_backward_line_table.html" to utilize |selection_test()|
for ease of maintenance and help to implementing EditingNG.

Bug: 707656, 679977
Change-Id: Ib5088b3888a26e599639bbfa9366aec75a067329
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2210171
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Auto-Submit: Yoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#770906}
parent 4876006f
<!doctype html> <!doctype html>
<script src="../../../resources/testharness.js"></script> <script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script> <script src="../../../resources/testharnessreport.js"></script>
<p>This tests for a bug moving down by a line from a line just above a ToDo, <script src="../../assert_selection.js"></script>
and moving up by a line from just below a ToDo.</p>
<div id="sample" contenteditable>
<div id="above">Click anywhere in this line and move down.</div>
<table border="1" contenteditable="false"><tr><td>The caret <span style="color: blue;" contenteditable id="anchor">should</span> always go into the editable region.</td></tr></table>
<div id="below">Click anywhere in this line and move up.</div>
</div>
<div id="log"</div>
<script> <script>
test(function() { // This tests for a bug moving down by a line from a line just above a table,
var selection = window.getSelection(); // and moving up by a line from just below a table.
var above = document.getElementById('above').firstChild; selection_test(
selection.collapse(above, 0); [
selection.modify('move', 'forward', 'line'); '<div contenteditable>',
selection.collapse(above, above.length); '<div>|above</div>',
selection.modify('move', 'forward', 'line'); '<table border="1" contenteditable="false"><tbody><tr>',
var below = document.getElementById('below').firstChild; '<td>ab <span contenteditable>cd</span> ef</td>',
selection.collapse(below, 0); '</tr></tbody></table>',
selection.modify('move', 'backward', 'line'); '<div>below</div>',
selection.collapse(below, below.length); '</div>',
selection.modify('move', 'backward', 'line'); ],
selection => selection.modify('move', 'forward', 'line'),
var anchor = document.getElementById('anchor'); [
assert_equals(selection.anchorNode, anchor.firstChild, 'anchorNode'); '<div contenteditable>',
assert_equals(selection.anchorOffset, 6, 'anchorOffset'); '<div>above</div>',
assert_equals(selection.focusNode, anchor.firstChild, 'focusNode'); '<table border="1" contenteditable="false"><tbody><tr>',
assert_equals(selection.focusOffset, 6, 'focusOffset'); '<td>ab <span contenteditable>|cd</span> ef</td>',
}); '</tr></tbody></table>',
'<div>below</div>',
'</div>',
], 'start of "above"');
selection_test(
[
'<div contenteditable>',
'<div>above|</div>',
'<table border="1" contenteditable="false"><tbody><tr>',
'<td>ab <span contenteditable>cd</span> ef</td>',
'</tr></tbody></table>',
'<div>below</div>',
'</div>',
],
selection => selection.modify('move', 'forward', 'line'),
[
'<div contenteditable>',
'<div>above</div>',
'<table border="1" contenteditable="false"><tbody><tr>',
'<td>ab <span contenteditable>cd|</span> ef</td>',
'</tr></tbody></table>',
'<div>below</div>',
'</div>',
], 'end of "above"');
selection_test(
[
'<div contenteditable>',
'<div>above</div>',
'<table border="1" contenteditable="false"><tbody><tr>',
'<td>ab <span contenteditable>cd</span> ef</td>',
'</tr></tbody></table>',
'<div>below|</div>',
'</div>',
],
selection => selection.modify('move', 'backward', 'line'),
[
'<div contenteditable>',
'<div>above</div>',
'<table border="1" contenteditable="false"><tbody><tr>',
'<td>ab <span contenteditable>cd|</span> ef</td>',
'</tr></tbody></table>',
'<div>below</div>',
'</div>',
], 'start of "below"');
selection_test(
[
'<div contenteditable>',
'<div>above</div>',
'<table border="1" contenteditable="false"><tbody><tr>',
'<td>ab <span contenteditable>cd</span> ef</td>',
'</tr></tbody></table>',
'<div>below|</div>',
'</div>',
],
selection => selection.modify('move', 'backward', 'line'),
[
'<div contenteditable>',
'<div>above</div>',
'<table border="1" contenteditable="false"><tbody><tr>',
'<td>ab <span contenteditable>cd|</span> ef</td>',
'</tr></tbody></table>',
'<div>below</div>',
'</div>',
], 'end of "below"');
</script> </script>
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