Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / editing / spelling / spelling-exactly-selected-multiple-words.html
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>
11 <script>
12
13 description("Spelling should work when the user selects a multi-word misspelling exactly. " +
14             "To test manually, enable 'Ask Google for Suggestions' in Chrome, type 'It should be upper case.', select 'upper case', and context-click on the selection." +
15             "The test succeeds when the context menu shows spelling suggestions.");
16
17 initSpellTest("destination", "It should be upper case.", function(textNode) {
18     spellingMarkerRange = internals.markerRangeForNode(textNode, "spelling", 0);
19     shouldBeEqualToString("spellingMarkerRange.toString()", "upper case");
20     shouldBeEqualToString("window.getSelection().toString()", "");
21     
22     // Select the multi-word misspelling without surrounding whitespace or punctuation.
23     var wordRange = document.createRange();
24     wordRange.setStart(textNode, 13);
25     wordRange.setEnd(textNode, 23);
26     window.getSelection().removeAllRanges();
27     window.getSelection().addRange(wordRange);
28
29     shouldBeEqualToString("window.getSelection().toString()", "upper case");
30
31     // Context click on "upper case" to show the context menu.
32     var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 100;
33     var y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2;
34     eventSender.mouseMoveTo(x, y);
35     contextMenuElements = eventSender.contextClick();
36     // Esc key to hide the context menu.
37     eventSender.keyDown("escape", null);
38
39     spellingMarkerRange = internals.markerRangeForNode(textNode, "spelling", 0);
40     shouldBeEqualToString("spellingMarkerRange.toString()", "upper case");
41     shouldBeEqualToString("window.getSelection().toString()", "upper case");
42     shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "uppercase");
43 });
44
45 </script>
46 </body>
47 </html>