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