Commit 3b156bf2 authored by xiaochengh's avatar xiaochengh Committed by Commit bot

Convert editing/spelling/spelling-backward.html with spellcheck_test

This patch converts the layout test with spellcheck_test as a
preparation for implementing idle time spellchecker.

BUG=517298

Review-Url: https://codereview.chromium.org/2476193002
Cr-Commit-Position: refs/heads/master@{#430228}
parent 401501e8
This tests for a bug when moving the caret backward through a misspelled word. Once the caret is no longer adjacent to it, it should be marked as misspelled.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS internals.hasSpellingMarker(document, 42, 3) became true
PASS successfullyParsed is true
TEST COMPLETE
This sentence ends with a misspelled word asd.
<!DOCTYPE html>
<html>
<body>
<script src="../../resources/js-test.js"></script>
<script src="../../editing/editing.js"></script>
<div id="div" contenteditable="true"></div>
<script>
description('This tests for a bug when moving the caret backward through '
+ 'a misspelled word. Once the caret is no longer adjacent to it, '
+ 'it should be marked as misspelled.');
jsTestIsAsync = true;
if (window.testRunner)
testRunner.setMockSpellCheckerEnabled(true);
var div = document.getElementById("div");
div.focus();
document.execCommand("InsertText", false, "This sentence ends with a misspelled word asd.");
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script src="spellcheck_test.js"></script>
moveSelectionBackwardByCharacterCommand();
moveSelectionBackwardByCharacterCommand();
moveSelectionBackwardByCharacterCommand();
moveSelectionBackwardByCharacterCommand();
moveSelectionBackwardByCharacterCommand();
moveSelectionBackwardByCharacterCommand();
if (window.internals)
shouldBecomeEqual("internals.hasSpellingMarker(document, 42, 3)", "true", finishJSTest);
<script>
spellcheck_test(
'<div contenteditable>|</div>',
'insertText This sentence ends with a misspelled word asd.',
'<div contenteditable>This sentence ends with a misspelled word #asd#.</div>',
{
title: 'Mark misspelled word "asd" after typing.',
callback: sample => spellcheck_test(
sample,
() => {
const selection = sample.selection;
selection.modify('move', 'backward', 'character');
selection.modify('move', 'backward', 'character');
selection.modify('move', 'backward', 'character');
selection.modify('move', 'backward', 'character');
selection.modify('move', 'backward', 'character');
},
'<div contenteditable>This sentence ends with a misspelled word #asd#.</div>',
'Misspelled word should still be marked when caret is no longer adjacent with it.')
});
</script>
</body>
</html>
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