11 <script src=
"../editing.js" language=
"JavaScript" type=
"text/JavaScript" ></script>
12 <script src=
"../../resources/js-test.js"></script>
15 <div id=
"container"></div>
17 description("Tests spelling and grammar markers for misspellings.");
21 if (window
.internals
) {
22 internals
.settings
.setUnifiedTextCheckerEnabled(true);
23 internals
.settings
.setAsynchronousSpellCheckingEnabled(true);
26 function createEditableElement(parent
) {
27 var e
= document
.createElement('div');
28 e
.setAttribute("contentEditable", "true");
29 e
.className
= 'editing';
31 parent
.appendChild(e
);
35 function typeText(elem
, text
) {
37 for (var i
= 0; i
< text
.length
; ++i
)
38 typeCharacterCommand(text
[i
]);
41 var container
= document
.getElementById('container');
43 var elementWithGrammarIssue
= createEditableElement(container
);
44 typeText(elementWithGrammarIssue
, 'I have a issue.');
46 var elementWithSpellingIssue
= createEditableElement(container
);
47 typeText(elementWithSpellingIssue
, 'zz.');
49 var elementWithGrammarAndSpellingIssue
= createEditableElement(container
);
50 typeText(elementWithGrammarAndSpellingIssue
, 'orange,zz,apple.');
55 function verifyMarkers(e
, misspellings
) {
56 if (!window
.internals
)
59 var n
= misspellings
.shift();
63 shouldBecomeEqual('internals.markerCountForNode(element.firstChild, next.marker)', '1', function() {
64 range
= internals
.markerRangeForNode(element
.firstChild
, next
.marker
, 0);
65 shouldBe('range.toString()', 'next.issue');
66 verifyMarkers(element
, misspellings
);
73 { marker
:'grammar', issue
:'a' },
74 { marker
:'spelling', issue
:'zz' },
75 { marker
:'grammar', issue
:'orange,zz,apple.' }
79 function() { verifyMarkers(elementWithGrammarIssue
, misspellings
.slice(0, 1)) },
80 function() { verifyMarkers(elementWithSpellingIssue
, misspellings
.slice(1, 2)) },
81 function() { verifyMarkers(elementWithGrammarAndSpellingIssue
, misspellings
.slice(1, 3)) },
86 var next
= tests
.shift();
88 return window
.setTimeout(next
, 0);