Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / spelling / spellcheck-async.html
blob4d7d7cdc4527328821e98c47cd3bd73795543bc7
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../resources/js-test.js"></script>
5 <script src="../editing.js"></script>
6 <style>
7 .editing {
8 border: 2px solid red;
9 padding: 6px;
10 font-size: 18px;
12 </style>
13 </head>
14 <body>
15 <pre id="description"></pre>
16 <pre id="console"></pre>
17 <div id="container"></div>
19 <script>
20 description("Test for Unified Spell Checker & Async Spell Checker.");
22 jsTestIsAsync = true;
24 if (window.internals) {
25 internals.settings.setAsynchronousSpellCheckingEnabled(true);
26 internals.settings.setUnifiedTextCheckerEnabled(true);
29 var container = document.getElementById('container');
30 function removeChildren(node) {
31 while (node.firstChild)
32 node.removeChild(node.firstChild);
35 var testData = [
36 { text: 'zz', marked: ['zz'] },
37 { text: 'apple,zz,orange', marked: ['zz'] },
38 { text: 'zz,zz', marked: ['zz','zz'] },
39 { text: 'zz zz zz', marked: ['zz', 'zz', 'zz'] },
40 { text: ' zz zz zz ', marked: ['zz', 'zz', 'zz'] },
41 { text: 'zz apple orange', marked: ['zz'] },
42 { text: 'apple zz orange', marked: ['zz'] },
43 { text: 'apple orange zz', marked: ['zz'] },
44 { text: 'zzz', marked: [] },
45 { text: 'I would like to sleep, zzz', marked: [] }
48 var testNo = 0;
49 function doTestIfAny() {
50 var next = testData.shift();
51 if (next)
52 return window.setTimeout(function(){ doTest(++testNo, next.text, next.marked); }, 0);
54 // No more tests.
55 removeChildren(container);
56 finishJSTest();
59 function createEditableElement(id) {
60 var e = document.createElement('div');
61 e.setAttribute("contentEditable", "true");
62 e.className = 'editing';
63 e.id = id;
65 return e;
68 function typeText(e, text) {
69 e.focus();
70 for (var i = 0; i < text.length; ++i) {
71 typeCharacterCommand(text[i]);
73 typeCharacterCommand('.');
76 function doTest(testNo, text, marked) {
77 removeChildren(container);
78 var id = "spelling" + testNo;
79 var e = createEditableElement(id);
80 container.appendChild(e);
82 typeText(e, text);
84 if (!window.internals)
85 return;
87 tryVerify(10, id, text, marked, 1);
90 function tryVerify(restTry, id, text, marked, nsleep) {
91 // No more try.
92 if (restTry <= 0) {
93 testFailed('text : "' + text + '" should have markers: [' + marked + ']');
94 setTimeout(doTestIfAny, 0);
95 return;
98 var success = true;
99 var e = document.getElementById(id);
100 var numMarked = internals.markerCountForNode(e.firstChild, "spelling");
101 var success = numMarked == marked.length;
103 if (success) {
104 for (var i = 0; i < numMarked; ++i) {
105 var range = internals.markerRangeForNode(e.firstChild, "spelling", i);
106 if (range.toString() != marked[i])
107 success = false;
111 if (success) {
112 testPassed('text : "' + text + '" has markers: [' + marked + ']');
113 setTimeout(doTestIfAny, 0);
114 } else {
115 // Type '.' to invoke asynchronouse spell checking again.
116 typeCharacterCommand('.');
117 setTimeout(function() { tryVerify(restTry - 1, id, text, marked, nsleep * 2); }, nsleep);
121 doTestIfAny();
123 var successfullyParsed = true;
124 </script>
125 </body>
126 </html>