Commit b392dd07 authored by yoichio's avatar yoichio Committed by Commit bot

[Editing][CodeHealth] Allow assert_selection have no anchor sample text.

This enable us to test creating new selection.

TEST=LayoutTests/editing/assert_selection.html

Review-Url: https://codereview.chromium.org/2114903002
Cr-Commit-Position: refs/heads/master@{#403433}
parent 08ade9cc
......@@ -14,6 +14,7 @@ function checked_assert_selection(input, command, output) {
}
test(() => {
assert_selection('foo', 'noop', 'foo');
assert_selection('|foo', 'noop', '|foo');
assert_selection('f|oo', 'noop', 'f|oo');
assert_selection('foo|', 'noop', 'foo|');
......@@ -60,11 +61,6 @@ test(() => {
'|<table><tbody><tr><td>foo</td></tr></tbody></table>^');
}, 'markers around table');
test(() => {
assert_equals(checked_assert_selection('foo', 'noop', 'baz'),
'You should specify caret position in "foo".');
}, 'no marker in input');
test(() => {
assert_equals(checked_assert_selection('fo|o', 'noop', 'fo|o'),
'no exception');
......
......@@ -462,8 +462,6 @@ class Serializer {
* @param {!HTMLDocument} document
*/
serialize(document) {
if (this.selection_.isNone)
return document.body.firstChild.outerHTML;
this.serializeChildren(document.body);
return this.strings_.join('');
}
......@@ -534,7 +532,7 @@ class Sample {
load(sampleText) {
const anchorMarker = sampleText.indexOf('^');
const focusMarker = sampleText.indexOf('|');
if (focusMarker < 0) {
if (focusMarker < 0 && anchorMarker >= 0) {
throw new Error(`You should specify caret position in "${sampleText}".`);
}
if (focusMarker != sampleText.lastIndexOf('|')) {
......
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