summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/editing/spelling/spelling-subword-selection.html
blob: 70ec740d5aa56f97483d5928c6cbeff305d0ac0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<!DOCTYPE html>
<html>
<head>
<script src="../../fast/js/resources/js-test-pre.js"></script>
<script src="resources/util.js"></script>
</head>
<body>
<div id="container">
  <div id="destination" contentEditable></div>
</div>

<script>

description("Spelling should be disabled when user selects a part of misspelling. " +
            "To test manually, type 'wellcome home.' select 'llco', and context-click on the selection. " +
            "The test suceeds when the context menu has no spell check suggestions.");

initSpellTest("destination", "wellcome home.", function(textNode) {
    spellingMarkerRange = internals.markerRangeForNode(textNode, "spelling", 0);
    shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome");
    shouldBeEqualToString("window.getSelection().toString()", "");

    // Select the text "llco".
    var subWordRange = document.createRange();
    subWordRange.setStart(textNode, 2);
    subWordRange.setEnd(textNode, 6);
    window.getSelection().removeAllRanges();
    window.getSelection().addRange(subWordRange);

    shouldBeEqualToString("window.getSelection().toString()", "llco");

    // Context click on 'llco' to show the context menu.
    var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 40;
    var y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2;
    eventSender.mouseMoveTo(x, y);
    contextMenuElements = eventSender.contextClick();
    // Esc key to hide the context menu.
    eventSender.keyDown(String.fromCharCode(0x001B), null);

    spellingMarkerRange = internals.markerRangeForNode(textNode, "spelling", 0);
    shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome");
    shouldBeEqualToString("window.getSelection().toString()", "llco");
    shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "<separator>");
});

</script>
</body>
</html>