Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / spelling / spelling-exactly-selected-word.html
blob13ad582f2e4e7ee8d8a6675c4ff3344929da5bc3
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../resources/js-test.js"></script>
5 <script src="resources/util.js"></script>
6 </head>
7 <body>
8 <div id="container">
9 <div id="destination" contentEditable></div>
10 </div>
12 <script>
14 description("Spelling should work when the user selects the misspelled word exactly. " +
15 "To test manually, type 'wellcome home.', select 'wellcome', and context-click on the selection. " +
16 "The test succeeds when the context menu shows spelling suggestions.");
18 initSpellTest("destination", "wellcome home.", function(textNode) {
19 spellingMarkerRange = internals.markerRangeForNode(textNode, "spelling", 0);
20 shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome");
21 shouldBeEqualToString("window.getSelection().toString()", "");
23 // Select the misspelled word without surrounding whitespace or punctuation.
24 var wordRange = document.createRange();
25 wordRange.setStart(textNode, 0);
26 wordRange.setEnd(textNode, 8);
27 window.getSelection().removeAllRanges();
28 window.getSelection().addRange(wordRange);
30 shouldBeEqualToString("window.getSelection().toString()", "wellcome");
32 // Context click on "wellcome" to show the context menu.
33 var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 40;
34 var y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2;
35 eventSender.mouseMoveTo(x, y);
36 contextMenuElements = eventSender.contextClick();
37 // Esc key to hide the context menu.
38 eventSender.keyDown("escape", null);
40 spellingMarkerRange = internals.markerRangeForNode(textNode, "spelling", 0);
41 shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome");
42 shouldBeEqualToString("window.getSelection().toString()", "wellcome");
43 shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "welcome");
45 // Select a correctly spelled word without surrounding whitespace or punctuation.
46 wordRange.setStart(textNode, 9);
47 wordRange.setEnd(textNode, 13);
48 window.getSelection().removeAllRanges();
49 window.getSelection().addRange(wordRange);
50 shouldBeEqualToString("window.getSelection().toString()", "home");
52 // Context click on "home" to show the context menu.
53 var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 80;
54 var y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2;
55 eventSender.mouseMoveTo(x, y);
56 contextMenuElements = eventSender.contextClick();
57 // Esc key to hide the context menu.
58 eventSender.keyDown("escape", null);
60 shouldBeEqualToString("window.getSelection().toString()", "home");
61 shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "<separator>");
62 });
64 </script>
65 </body>
66 </html>