Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / spelling / spellcheck-queue.html
blobe28aafcc8919fd685f766aa1eee75f82e1d1237b
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <script src="../../resources/js-test.js"></script>
5 </head>
6 <body>
7 <p id="description"></p>
8 <div id="console"></div>
9 <script>
10 description('For Bug 72939: Asynchronous SpellChecker should consider multiple requests.');
12 jsTestIsAsync = true;
14 if (window.internals)
15 internals.settings.setAsynchronousSpellCheckingEnabled(true);
17 var testRoot = document.createElement("div");
18 document.body.insertBefore(testRoot, document.body.firstChild);
20 var source1 = document.createElement("div");
21 source1.innerHTML = "foo bar";
22 testRoot.appendChild(source1);
24 var source2 = document.createElement("div");
25 source2.innerHTML = "zz apple orange";
26 testRoot.appendChild(source2);
28 function createInput(testRoot) {
29 var e = document.createElement('input');
30 e.setAttribute("type", "text");
31 testRoot.appendChild(e);
33 return e;
36 function createTextArea(testRoot) {
37 var e = document.createElement("textarea");
38 testRoot.appendChild(e);
40 return e;
43 function createContentEditable(testRoot) {
44 var e = document.createElement("div");
45 e.setAttribute("contentEditable", "true");
46 testRoot.appendChild(e);
48 return e;
51 var destinations = [
52 createInput(testRoot),
53 createTextArea(testRoot),
54 createContentEditable(testRoot),
55 createInput(testRoot),
56 createTextArea(testRoot),
57 createContentEditable(testRoot),
58 createInput(testRoot),
59 createTextArea(testRoot),
60 createContentEditable(testRoot),
63 var sel = window.getSelection();
65 var tests = [];
66 for (var i = 0; i < destinations.length; ++i) {
67 var t = function(i) {
68 return function() { verify(source2, destinations[i], ["zz"]); }
69 }(i);
70 tests.push(t);
73 function verifyIfAny()
75 var next = tests.shift();
76 if (next) {
77 next();
78 return;
81 testRoot.style.display = "none";
82 finishJSTest();
85 function findFirstTextNode(node)
87 function iterToFindFirstTextNode(node)
89 if (node instanceof Text)
90 return node;
92 var childNodes = node.childNodes;
93 for (var i = 0; i < childNodes.length; ++i) {
94 var n = iterToFindFirstTextNode(childNodes[i]);
95 if (n)
96 return n;
99 return null;
103 if (node instanceof HTMLInputElement || node instanceof HTMLTextAreaElement)
104 return iterToFindFirstTextNode(internals.shadowRoot(node));
105 else
106 return iterToFindFirstTextNode(node);
109 function verifyMarker(node, expectedMarked)
111 if (!window.testRunner || !window.internals)
112 return false;
114 var textNode = findFirstTextNode(node);
116 var num = internals.markerCountForNode(textNode, "spelling");
117 if (num != expectedMarked.length)
118 return false;
119 for (var i = 0; i < num; ++i) {
120 var range = internals.markerRangeForNode(textNode, "spelling", i);
121 if (range.toString() != expectedMarked[i])
122 return false;
125 return true;
128 function copyAndPaste(source, dest)
130 sel.selectAllChildren(source);
131 document.execCommand("Copy");
133 if (dest instanceof HTMLInputElement || dest instanceof HTMLTextAreaElement) {
134 dest.value = "";
135 dest.focus();
136 } else {
137 dest.innerHTML = "";
138 sel.selectAllChildren(dest);
140 document.execCommand("Paste");
143 function verify(source, dest, expectedMarked)
145 var nretry = 10;
146 var nsleep = 1;
147 function trial() {
148 var verified = verifyMarker(dest, expectedMarked);
149 if (verified) {
150 testPassed(dest.tagName + " has a marker on '" + source.innerHTML + "'");
151 verifyIfAny();
152 return;
155 nretry--;
156 if (0 == nretry) {
157 testFailed(dest.tagName + " should have a marker on for '" + source.innerHTML + "'");
158 verifyIfAny();
159 return;
162 nsleep *= 2;
163 window.setTimeout(trial, nsleep);
165 trial();
169 // paste "foo bar"
170 for (var i = 0; i < destinations.length; ++i)
171 copyAndPaste(source1, destinations[i]);
173 // paste "zz apple orange"
174 for (var i = 0; i < destinations.length; ++i)
175 copyAndPaste(source2, destinations[i]);
177 verifyIfAny();
179 var successfullyParsed = true;
181 </script>
182 </body>
183 </html>