Commit 401501e8 authored by xiaochengh's avatar xiaochengh Committed by Commit bot

Convert editing/spelling/spelling-on-context-menu-key.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/2480133002
Cr-Commit-Position: refs/heads/master@{#430227}
parent ef99d7ee
Spell check selects the misspelled word on context menu key. To test manually, type 'wellcome home.' place the cursor on 'wellcome', and press the context menu key. The test succeeds when 'wellcome' is selected after the context menu key.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS window.getSelection().toString() is "wellcome"
PASS window.getSelection().toString() is "wellcome"
PASS successfullyParsed is true
TEST COMPLETE
wellcome home.
<!DOCTYPE html> <!DOCTYPE html>
<html> <script src="../../resources/testharness.js"></script>
<head> <script src="../../resources/testharnessreport.js"></script>
<script src="../../resources/js-test.js"></script> <script src="../assert_selection.js"></script>
<script src="resources/util.js"></script> <script src="spellcheck_test.js"></script>
</head>
<body>
<div id="container">
<div id="destination" contentEditable></div>
</div>
<script> <script>
test(() => assert_false(navigator.platform.includes('Mac')),
description("Spell check selects the misspelled word on context menu key. " + 'This test requires context menu key.');
"To test manually, type 'wellcome home.' place the cursor on 'wellcome', and press the context menu key. " + test(() => assert_not_equals(window.eventSender, undefined),
"The test succeeds when 'wellcome' is selected after the context menu key."); 'This test requires event sender.');
initSpellTest("destination", "wellcome home.", function(textNode) { spellcheck_test(
var behaviors = ["win", "mac"]; '<div contenteditable>well|come home.</div>',
for (var i = 0; i < behaviors.length; i++) { '',
internals.settings.setEditingBehavior(behaviors[i]); '<div contenteditable>#wellcome# home.</div>',
{
// Place cursor on "wellcome". title: 'Mark initial misspelling.',
window.getSelection().removeAllRanges(); callback: sample => test(() => {
var range = document.createRange(); eventSender.keyDown('ContextMenu');
range.setStart(textNode, 2); eventSender.keyDown('Escape');
range.setEnd(textNode, 2); assert_equals(sample.selection.toString(), 'wellcome');
window.getSelection().addRange(range); }, 'When caret is on a misspelled word, pressing context menu key ' +
'selects the word.')
// Context menu key to show the context menu. });
eventSender.keyDown("ContextMenu");
// Esc to close the context menu.
eventSender.keyDown("Escape");
shouldBeEqualToString("window.getSelection().toString()", "wellcome");
}
});
</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