Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / spelling / script-tests / spelling-hasspellingmarker.js
blobf483dc1fc1b4b223b5f6ba1ac745f6aed401e7c2
1 description('This tests if internals.hasSpellingMarker works for differnt type of elements. '
2 + 'This test succeds when there are four elements having "zz ". '
3 + 'However, only the last one should not contatin spelling marker.');
5 jsTestIsAsync = true;
7 if (window.internals) {
8 internals.settings.setUnifiedTextCheckerEnabled(true);
9 internals.settings.setAsynchronousSpellCheckingEnabled(true);
12 var testRoot = document.createElement("div");
13 document.body.insertBefore(testRoot, document.body.firstChild);
15 function addContainer(markup)
17 var contatiner = document.createElement("div");
18 contatiner.innerHTML = markup;
19 testRoot.appendChild(contatiner);
21 return contatiner;
24 function typeMisspelling(contatiner)
26 contatiner.firstChild.focus();
27 typeCharacterCommand('z');
28 typeCharacterCommand('z');
29 typeCharacterCommand(' ');
32 function verifySpellingMarkers(element)
34 var div = addContainer(element.containerMarkup);
35 typeMisspelling(div);
37 if (window.internals)
38 shouldBecomeEqual("internals.hasSpellingMarker(document, 0, 2)", element.isMisspelled ? "true" : "false", done);
39 else
40 done();
43 var testCases = [
44 { containerMarkup: "<textarea></textarea>", isMisspelled: true },
45 { containerMarkup: "<input type='text'></input>", isMisspelled: true },
46 { containerMarkup: "<div contenteditable='true'></div>", isMisspelled: true },
47 { containerMarkup: "<div contentEditable='true' spellcheck='false'></div>", isMisspelled: false }
50 function done()
52 var nextTestCase = testCases.shift();
53 if (nextTestCase)
54 return setTimeout(verifySpellingMarkers(nextTestCase), 0);
56 if (window.internals)
57 testRoot.style.display = "none";
59 finishJSTest();
61 done();
63 var successfullyParsed = true;