summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/editing/spelling/grammar-markers.html
blob: 9454a5d6af694c470a4128216c815b6784772e20 (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
<!DOCTYPE html>
<html>
<head>
<script src="../../fast/js/resources/js-test-pre.js"></script>
</head>
<body>
<div id="source" contenteditable="true" spellcheck="false">You has the right.</div>
<div id="target" contenteditable="true" spellcheck="true"></div>

<script>
description('This tests whether WebKit can render grammar markers when pasting text if it has a grammar-checker. To test manually, copy the text in the first div element and paste it to the second div element. This test succeeds when WebKit renders a grammar marker under a word "has".');

jsTestIsAsync = true;

if (window.internals)
    internals.settings.setAsynchronousSpellCheckingEnabled(true);

if (window.testRunner)
    testRunner.dumpAsTextWithPixelResults();

function verifyGrammarMarker(destination, ungrammaticalPhrase)
{
    if (window.internals && internals.hasGrammarMarker(document, destination.innerHTML.indexOf(ungrammaticalPhrase), ungrammaticalPhrase.length)) {
        testPassed("ungrammatical phrase '" + ungrammaticalPhrase + "' on '" + destination.innerHTML + "'");
        return true;
    } else
        return false;
}

var source = document.getElementById('source');
window.getSelection().selectAllChildren(source);
document.execCommand('Copy');
var target = document.getElementById('target');
window.getSelection().selectAllChildren(target);
document.execCommand('Paste');

shouldBecomeEqual('verifyGrammarMarker(target, "has")', 'true', finishJSTest);

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