Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / spelling / script-tests / spelling-attribute-at-child.js
blobfac1c5239af511488875bdfb9df378c3dea75c78
1 description('Tests if the spellchecker behaves correctly when child has own '
2 + 'spellcheck attribute.');
4 jsTestIsAsync = true;
6 if (window.internals) {
7 internals.settings.setUnifiedTextCheckerEnabled(true);
8 internals.settings.setAsynchronousSpellCheckingEnabled(true);
11 var root = document.createElement("div");
12 document.body.appendChild(root);
14 function verifyChildSpellingMarker(element)
16 var testElement = document.createElement("div");
17 testElement.innerHTML = element.markup;
18 root.appendChild(testElement);
20 var childText = testElement.firstChild.childNodes[1].firstChild;
21 document.getSelection().collapse(childText, 1);
22 document.execCommand("InsertText", false, 'z');
23 document.execCommand("InsertText", false, 'z');
24 document.execCommand("InsertText", false, ' ');
26 if (window.internals) {
27 debug(escapeHTML(testElement.innerHTML));
29 shouldBecomeEqual("internals.hasSpellingMarker(document, 1, 2)", element.shouldBeMisspelled ? "true" : "false", function() {
30 debug("");
31 done();
32 });
33 } else
34 done();
37 var testCases = [
38 { markup: "<div contentEditable>Foo <span spellcheck='false' id='child'>[]</span> Baz</div>", shouldBeMisspelled: false },
39 { markup: "<div contentEditable>Foo <span id='child'>[]</span> Baz</div>", shouldBeMisspelled: true },
40 { markup: "<div contentEditable>Foo <span spellcheck='true' id='child'>[]</span> Baz</div>", shouldBeMisspelled: true },
41 { markup: "<div spellcheck='false' contentEditable>Foo <span spellcheck='false' id='child'>[]</span> Baz</div>", shouldBeMisspelled: false },
42 { markup: "<div spellcheck='false' contentEditable>Foo <span id='child'>[]</span> Baz</div>", shouldBeMisspelled: false },
43 { markup: "<div spellcheck='false' contentEditable>Foo <span spellcheck='true' id='child'>[]</span> Baz</div>", shouldBeMisspelled: true },
44 { markup: "<div spellcheck='true' contentEditable>Foo <span spellcheck='false' id='child'>[]</span> Baz</div>", shouldBeMisspelled: false },
45 { markup: "<div spellcheck='true' contentEditable>Foo <span id='child'>[]</span> Baz</div>", shouldBeMisspelled: true },
46 { markup: "<div spellcheck='true' contentEditable>Foo <span spellcheck='true' id='child'>[]</span> Baz</div>", shouldBeMisspelled: true }
49 function done()
51 var nextTestCase = testCases.shift();
52 if (nextTestCase)
53 return setTimeout(verifyChildSpellingMarker(nextTestCase), 0);
55 finishJSTest();
57 done();
59 var successfullyParsed = true;