OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <title>Spellcheck Attribute Test</title> | 3 <title>Spellcheck Attribute Test</title> |
4 <link rel="help" href="http://damowmow.com/playground/spellcheck.txt"> | 4 <link rel="help" href="http://damowmow.com/playground/spellcheck.txt"> |
| 5 <script src="../editing.js"></script> |
| 6 <script src="resources/util.js"></script> |
5 <script src="../../resources/js-test.js"></script> | 7 <script src="../../resources/js-test.js"></script> |
6 </head> | 8 </head> |
7 <body> | 9 <body> |
8 <p>This tests if the "spellcheck" attribute is implemented as written in its spe
cification. If this test succeeds, you can see forms filled with an invalid word
'zz '. Nevertheless, the 'zz ' is not marked as misspelled in all of them. | |
9 <div id="testRoot"> | 10 <div id="testRoot"> |
10 | 11 |
11 <div spellcheck="true"> | 12 <div spellcheck="true"> |
12 <label>1.1.</label><input id="test1_1" type="text"></input><br/> | 13 <label>1.1.</label><input id="test1_1" type="text"></input><br/> |
13 <label>1.2.</label><input id="test1_2" type="text" spellcheck="true"></input><br
/> | 14 <label>1.2.</label><input id="test1_2" type="text" spellcheck="true"></input><br
/> |
14 <label>1.3.</label><input id="test1_3" type="text" spellcheck="false"></input><b
r/> | 15 <label>1.3.</label><input id="test1_3" type="text" spellcheck="false"></input><b
r/> |
15 <label>1.4.</label><input id="test1_4" type="text" spellcheck="InvalidValue"></i
nput><br/> | 16 <label>1.4.</label><input id="test1_4" type="text" spellcheck="InvalidValue"></i
nput><br/> |
16 <label>1.5.</label><input id="test1_5" type="text" spellcheck></input><br/> | 17 <label>1.5.</label><input id="test1_5" type="text" spellcheck></input><br/> |
17 <label>1.6.</label><input id="test1_6" type="text"></input><br/> | |
18 </div> | 18 </div> |
19 <div spellcheck="false"> | 19 <div spellcheck="false"> |
20 <label>2.1.</label><input id="test2_1" type="text"></input><br/> | 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
/> | 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><b
r/> | 22 <label>2.3.</label><input id="test2_3" type="text" spellcheck="false"></input><b
r/> |
23 <label>2.4.</label><input id="test2_4" type="text" spellcheck="InvalidValue"></i
nput><br/> | 23 <label>2.4.</label><input id="test2_4" type="text" spellcheck="InvalidValue"></i
nput><br/> |
24 <label>2.5.</label><input id="test2_5" type="text" spellcheck></input><br/> | 24 <label>2.5.</label><input id="test2_5" type="text" spellcheck></input><br/> |
25 <label>2.6.</label><input id="test2_6" type="text"></input><br/> | |
26 </div> | 25 </div> |
27 | 26 |
28 <div spellcheck="true"> | 27 <div spellcheck="true"> |
29 <label>3.1.</label><input id="test3_1" type="search"></input><br/> | 28 <label>3.1.</label><input id="test3_1" type="search"></input><br/> |
30 <label>3.2.</label><input id="test3_2" type="search" spellcheck="true"></input><
br/> | 29 <label>3.2.</label><input id="test3_2" type="search" spellcheck="true"></input><
br/> |
31 <label>3.3.</label><input id="test3_3" type="search" spellcheck="false"></input>
<br/> | 30 <label>3.3.</label><input id="test3_3" type="search" spellcheck="false"></input>
<br/> |
32 <label>3.4.</label><input id="test3_4" type="search" spellcheck="InvalidValue"><
/input><br/> | 31 <label>3.4.</label><input id="test3_4" type="search" spellcheck="InvalidValue"><
/input><br/> |
33 <label>3.5.</label><input id="test3_5" type="search" spellcheck></input><br/> | 32 <label>3.5.</label><input id="test3_5" type="search" spellcheck></input><br/> |
34 <label>3.6.</label><input id="test3_6" type="search"></input><br/> | |
35 </div> | 33 </div> |
36 <div spellcheck="false"> | 34 <div spellcheck="false"> |
37 <label>4.1.</label><input id="test4_1" type="search"></input><br/> | 35 <label>4.1.</label><input id="test4_1" type="search"></input><br/> |
38 <label>4.2.</label><input id="test4_2" type="search" spellcheck="true"></input><
br/> | 36 <label>4.2.</label><input id="test4_2" type="search" spellcheck="true"></input><
br/> |
39 <label>4.3.</label><input id="test4_3" type="search" spellcheck="false"></input>
<br/> | 37 <label>4.3.</label><input id="test4_3" type="search" spellcheck="false"></input>
<br/> |
40 <label>4.4.</label><input id="test4_4" type="search" spellcheck="InvalidValue"><
/input><br/> | 38 <label>4.4.</label><input id="test4_4" type="search" spellcheck="InvalidValue"><
/input><br/> |
41 <label>4.5.</label><input id="test4_5" type="search" spellcheck></input><br/> | 39 <label>4.5.</label><input id="test4_5" type="search" spellcheck></input><br/> |
42 <label>4.6.</label><input id="test4_6" type="search"></input><br/> | |
43 </div> | 40 </div> |
44 | 41 |
45 </div> | 42 </div> |
46 <pre id="console"></pre> | |
47 <script> | 43 <script> |
48 function log(msg) { | 44 description('This tests if the "spellcheck" attribute is implemented ' |
49 document.getElementById("console").innerHTML += (msg + "\n"); | 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.'); |
| 48 |
| 49 jsTestIsAsync = true; |
| 50 |
| 51 if (window.internals) { |
| 52 internals.settings.setUnifiedTextCheckerEnabled(true); |
| 53 internals.settings.setAsynchronousSpellCheckingEnabled(true); |
50 } | 54 } |
51 | 55 |
52 function testMarkerForMisspelledWord(id, shouldBeMarked) { | 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 '); |
| 60 |
| 61 var shouldBeMarked; |
| 62 |
| 63 function testMarkerForMisspelledWord(id, isMisspelled) { |
| 64 if (!window.internals) |
| 65 return done(); |
| 66 |
53 var inputElement = document.getElementById(id); | 67 var inputElement = document.getElementById(id); |
| 68 // Spelling markers for input will appear if it's focused. |
54 inputElement.focus(); | 69 inputElement.focus(); |
55 document.execCommand("InsertText", false, 'z'); | |
56 document.execCommand("InsertText", false, 'z'); | |
57 document.execCommand("InsertText", false, ' '); | |
58 | 70 |
59 log("id=" + id + " type=" + inputElement.type + " spellcheck=" + inputElemen
t.spellcheck | 71 debug("id=" + id + " type=" + inputElement.type + " spellcheck=" + inputElem
ent.spellcheck |
60 + " parent's spellcheck=" + inputElement.parentNode.spellcheck); | 72 + " parent's spellcheck=" + inputElement.parentNode.spellcheck); |
61 | 73 |
62 shouldBe("internals.hasSpellingMarker(document, 0, 2)", shouldBeMarked ? "tr
ue" : "false") | 74 shouldBeMarked = isMisspelled; |
| 75 shouldBecomeEqual('internals.hasSpellingMarker(document, 0, 2)', 'shouldBeMa
rked', done); |
63 } | 76 } |
64 | 77 |
65 // For type="text". | 78 var tests = [ |
66 testMarkerForMisspelledWord('test1_1', true); | 79 // For type="text". |
67 testMarkerForMisspelledWord('test1_2', true); | 80 function() { testMarkerForMisspelledWord('test1_1', true); }, |
68 testMarkerForMisspelledWord('test1_3', false); | 81 function() { testMarkerForMisspelledWord('test1_2', true); }, |
69 testMarkerForMisspelledWord('test1_4', true); | 82 function() { testMarkerForMisspelledWord('test1_3', false); }, |
70 testMarkerForMisspelledWord('test1_5', true); | 83 function() { testMarkerForMisspelledWord('test1_4', true); }, |
71 testMarkerForMisspelledWord('test1_6', true); | 84 function() { testMarkerForMisspelledWord('test1_5', true); }, |
72 log(""); | 85 function() { testMarkerForMisspelledWord('test2_1', false); }, |
73 testMarkerForMisspelledWord('test2_1', false); | 86 function() { testMarkerForMisspelledWord('test2_2', true); }, |
74 testMarkerForMisspelledWord('test2_2', true); | 87 function() { testMarkerForMisspelledWord('test2_3', false); }, |
75 testMarkerForMisspelledWord('test2_3', false); | 88 function() { testMarkerForMisspelledWord('test2_4', false); }, |
76 testMarkerForMisspelledWord('test2_4', false); | 89 function() { testMarkerForMisspelledWord('test2_5', true); }, |
77 testMarkerForMisspelledWord('test2_5', true); | 90 // For type="search". |
78 testMarkerForMisspelledWord('test2_6', false); | 91 function() { testMarkerForMisspelledWord('test3_1', true); }, |
79 log(""); | 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); }, |
| 101 ]; |
80 | 102 |
81 // For type="search". | 103 function done() |
82 testMarkerForMisspelledWord('test3_1', true); | 104 { |
83 testMarkerForMisspelledWord('test3_2', true); | 105 var next = tests.shift(); |
84 testMarkerForMisspelledWord('test3_3', false); | 106 if (next) |
85 testMarkerForMisspelledWord('test3_4', true); | 107 return window.setTimeout(next, 0); |
86 testMarkerForMisspelledWord('test3_5', true); | |
87 testMarkerForMisspelledWord('test3_6', true); | |
88 log(""); | |
89 testMarkerForMisspelledWord('test4_1', false); | |
90 testMarkerForMisspelledWord('test4_2', true); | |
91 testMarkerForMisspelledWord('test4_3', false); | |
92 testMarkerForMisspelledWord('test4_4', false); | |
93 testMarkerForMisspelledWord('test4_5', true); | |
94 testMarkerForMisspelledWord('test4_6', false); | |
95 | 108 |
96 if (window.testRunner) { | 109 if (window.testRunner) { |
97 // Cleaning up for expeation text if running on DRT. | 110 // Cleaning up for expectation text if running on DRT. |
98 document.getElementById("testRoot").style.display = "none"; | 111 document.getElementById("testRoot").style.display = "none"; |
| 112 } |
| 113 finishJSTest(); |
99 } | 114 } |
| 115 done(); |
100 </script> | 116 </script> |
101 </body> | 117 </body> |
102 </html> | 118 </html> |
OLD | NEW |