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> <!DOCTYPE html>
<html> <script src="../../resources/testharness.js"></script>
<body> <script src="../../resources/testharnessreport.js"></script>
<script src="../../resources/js-test.js"></script> <script src="../assert_selection.js"></script>
<script src="../../editing/editing.js"></script> <script src="spellcheck_test.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.");
moveSelectionBackwardByCharacterCommand(); <script>
moveSelectionBackwardByCharacterCommand(); spellcheck_test(
moveSelectionBackwardByCharacterCommand(); '<div contenteditable>|</div>',
moveSelectionBackwardByCharacterCommand(); 'insertText This sentence ends with a misspelled word asd.',
moveSelectionBackwardByCharacterCommand(); '<div contenteditable>This sentence ends with a misspelled word #asd#.</div>',
moveSelectionBackwardByCharacterCommand(); {
title: 'Mark misspelled word "asd" after typing.',
if (window.internals) callback: sample => spellcheck_test(
shouldBecomeEqual("internals.hasSpellingMarker(document, 42, 3)", "true", finishJSTest); 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> </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