Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / editing / spelling / script-tests / spelling-attribute-at-child.js
1 description('Tests if the spellchecker behaves correctly when child has own '
2     + 'spellcheck attribute.');
3
4 jsTestIsAsync = true;
5
6 if (window.internals) {
7     internals.settings.setUnifiedTextCheckerEnabled(true);
8     internals.settings.setAsynchronousSpellCheckingEnabled(true);
9 }
10
11 var root = document.createElement("div");
12 document.body.appendChild(root);
13
14 function verifyChildSpellingMarker(element)
15 {
16     var testElement = document.createElement("div");
17     testElement.innerHTML = element.markup;
18     root.appendChild(testElement);
19
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, ' ');
25
26     if (window.internals) {
27         debug(escapeHTML(testElement.innerHTML));
28
29         shouldBecomeEqual("internals.hasSpellingMarker(document, 1, 2)", element.shouldBeMisspelled ? "true" : "false", function() {
30             debug("");
31             done();
32         });
33     } else
34         done();
35 }
36
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 }
47 ];
48
49 function done()
50 {
51     var nextTestCase = testCases.shift();
52     if (nextTestCase)
53         return setTimeout(verifyChildSpellingMarker(nextTestCase), 0);
54
55     finishJSTest();
56 }
57 done();
58
59 var successfullyParsed = true;