Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / spelling / spellcheck-attribute.html
blob583659a0234efd65342077cdd0cfbaf63aabd624
1 <html>
2 <head>
3 <title>Spellcheck Attribute Test</title>
4 <link rel="help" href="http://damowmow.com/playground/spellcheck.txt">
5 <script src="../editing.js"></script>
6 <script src="resources/util.js"></script>
7 <script src="../../resources/js-test.js"></script>
8 </head>
9 <body>
10 <div id="testRoot">
12 <div spellcheck="true">
13 <label>1.1.</label><input id="test1_1" type="text"></input><br/>
14 <label>1.2.</label><input id="test1_2" type="text" spellcheck="true"></input><br/>
15 <label>1.3.</label><input id="test1_3" type="text" spellcheck="false"></input><br/>
16 <label>1.4.</label><input id="test1_4" type="text" spellcheck="InvalidValue"></input><br/>
17 <label>1.5.</label><input id="test1_5" type="text" spellcheck></input><br/>
18 </div>
19 <div spellcheck="false">
20 <label>2.1.</label><input id="test2_1" type="text"></input><br/>
21 <label>2.2.</label><input id="test2_2" type="text" spellcheck="true"></input><br/>
22 <label>2.3.</label><input id="test2_3" type="text" spellcheck="false"></input><br/>
23 <label>2.4.</label><input id="test2_4" type="text" spellcheck="InvalidValue"></input><br/>
24 <label>2.5.</label><input id="test2_5" type="text" spellcheck></input><br/>
25 </div>
27 <div spellcheck="true">
28 <label>3.1.</label><input id="test3_1" type="search"></input><br/>
29 <label>3.2.</label><input id="test3_2" type="search" spellcheck="true"></input><br/>
30 <label>3.3.</label><input id="test3_3" type="search" spellcheck="false"></input><br/>
31 <label>3.4.</label><input id="test3_4" type="search" spellcheck="InvalidValue"></input><br/>
32 <label>3.5.</label><input id="test3_5" type="search" spellcheck></input><br/>
33 </div>
34 <div spellcheck="false">
35 <label>4.1.</label><input id="test4_1" type="search"></input><br/>
36 <label>4.2.</label><input id="test4_2" type="search" spellcheck="true"></input><br/>
37 <label>4.3.</label><input id="test4_3" type="search" spellcheck="false"></input><br/>
38 <label>4.4.</label><input id="test4_4" type="search" spellcheck="InvalidValue"></input><br/>
39 <label>4.5.</label><input id="test4_5" type="search" spellcheck></input><br/>
40 </div>
42 </div>
43 <script>
44 description('This tests if the "spellcheck" attribute is implemented '
45 + 'as written in its specification. If this test succeeds, you can see '
46 + 'forms filled with an invalid word "zz". Nevertheless, the "zz" is not '
47 + 'marked as misspelled in all of them.');
49 jsTestIsAsync = true;
51 if (window.internals) {
52 internals.settings.setUnifiedTextCheckerEnabled(true);
53 internals.settings.setAsynchronousSpellCheckingEnabled(true);
56 // Type misspelling to all input elements.
57 var inputs = document.getElementsByTagName('input');
58 for (var i = 0; i < inputs.length; i++)
59 typeText(inputs[i], 'zz ');
61 var shouldBeMarked;
63 function testMarkerForMisspelledWord(id, isMisspelled) {
64 if (!window.internals)
65 return done();
67 var inputElement = document.getElementById(id);
68 // Spelling markers for input will appear if it's focused.
69 inputElement.focus();
71 debug("id=" + id + " type=" + inputElement.type + " spellcheck=" + inputElement.spellcheck
72 + " parent's spellcheck=" + inputElement.parentNode.spellcheck);
74 shouldBeMarked = isMisspelled;
75 shouldBecomeEqual('internals.hasSpellingMarker(document, 0, 2)', 'shouldBeMarked', done);
78 var tests = [
79 // For type="text".
80 function() { testMarkerForMisspelledWord('test1_1', true); },
81 function() { testMarkerForMisspelledWord('test1_2', true); },
82 function() { testMarkerForMisspelledWord('test1_3', false); },
83 function() { testMarkerForMisspelledWord('test1_4', true); },
84 function() { testMarkerForMisspelledWord('test1_5', true); },
85 function() { testMarkerForMisspelledWord('test2_1', false); },
86 function() { testMarkerForMisspelledWord('test2_2', true); },
87 function() { testMarkerForMisspelledWord('test2_3', false); },
88 function() { testMarkerForMisspelledWord('test2_4', false); },
89 function() { testMarkerForMisspelledWord('test2_5', true); },
90 // For type="search".
91 function() { testMarkerForMisspelledWord('test3_1', true); },
92 function() { testMarkerForMisspelledWord('test3_2', true); },
93 function() { testMarkerForMisspelledWord('test3_3', false); },
94 function() { testMarkerForMisspelledWord('test3_4', true); },
95 function() { testMarkerForMisspelledWord('test3_5', true); },
96 function() { testMarkerForMisspelledWord('test4_1', false); },
97 function() { testMarkerForMisspelledWord('test4_2', true); },
98 function() { testMarkerForMisspelledWord('test4_3', false); },
99 function() { testMarkerForMisspelledWord('test4_4', false); },
100 function() { testMarkerForMisspelledWord('test4_5', true); },
103 function done()
105 var next = tests.shift();
106 if (next)
107 return window.setTimeout(next, 0);
109 if (window.testRunner) {
110 // Cleaning up for expectation text if running on DRT.
111 document.getElementById("testRoot").style.display = "none";
113 finishJSTest();
115 done();
116 </script>
117 </body>
118 </html>