3 document.getElementById("console").innerHTML += (msg + "\n");
6 function verifySpellTest(nretry, opt_doNotFinishTest)
8 var node = window.destination;
9 if (window.destination.childNodes.length > 0)
10 node = window.destination.childNodes[0];
11 if (nretry && !internals.markerCountForNode(node, "spelling")) {
12 window.setTimeout(function() { verifySpellTest(nretry - 1, opt_doNotFinishTest); }, 0);
15 testFunctionCallback(node);
16 if (!opt_doNotFinishTest)
20 function initSpellTest(testElementId, testText, testFunction, opt_doNotFinishTest)
22 if (!window.internals || !window.testRunner) {
23 log("FAIL Incomplete test environment");
26 testFunctionCallback = testFunction;
28 internals.settings.setAsynchronousSpellCheckingEnabled(true);
29 internals.settings.setSmartInsertDeleteEnabled(true);
30 internals.settings.setSelectTrailingWhitespaceEnabled(false);
31 internals.settings.setUnifiedTextCheckerEnabled(true);
32 internals.settings.setEditingBehavior("win");
33 window.destination = document.getElementById(testElementId);
34 window.destination.focus();
35 document.execCommand("InsertText", false, testText);
36 window.setTimeout(function() { verifySpellTest(10, opt_doNotFinishTest); }, 0);
39 function findFirstTextNode(node)
41 function iterToFindFirstTextNode(node)
43 if (node instanceof Text)
46 var childNodes = node.childNodes;
47 for (var i = 0; i < childNodes.length; ++i) {
48 var n = iterToFindFirstTextNode(childNodes[i]);
56 if (node instanceof HTMLInputElement || node instanceof HTMLTextAreaElement) {
57 return iterToFindFirstTextNode(internals.shadowRoot(node));
59 return iterToFindFirstTextNode(node);
63 function typeText(elem, text)
66 for (var i = 0; i < text.length; ++i) {
67 typeCharacterCommand(text[i]);