OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <body> | 3 <body> |
4 <script src="../resources/testharness.js"></script> | 4 <script src="../resources/testharness.js"></script> |
5 <script src="../resources/testharnessreport.js"></script> | 5 <script src="../resources/testharnessreport.js"></script> |
6 <script> | 6 <script> |
7 | 7 |
8 test(function() { | 8 test(function() { |
9 assert_true('orientation' in window.screen); | 9 assert_true('autocapitalize' in document.createElement('input')); |
10 assert_true('angle' in window.screen.orientation); | 10 }, "Test that the autocapitalize is avaible on HTMLInputElement.") |
11 assert_true('type' in window.screen.orientation); | |
12 assert_true('lock' in window.screen.orientation); | |
13 assert_true('unlock' in window.screen.orientation); | |
14 assert_true('onchange' in window.screen.orientation); | |
15 }, "Test that the Screen Orientation API is present.") | |
16 | 11 |
17 test(function() { | 12 test(function() { |
18 assert_equals(typeof(screen.orientation), "object"); | 13 assert_true('autocapitalize' in document.createElement('textarea')); |
19 assert_equals(typeof(screen.orientation.angle), "number"); | 14 }, "Test that the autocapitalize is avaible on HTMLTextAreaElement.") |
20 assert_equals(typeof(screen.orientation.type), "string"); | |
21 assert_equals(typeof(screen.orientation.lock), "function"); | |
22 assert_equals(typeof(screen.orientation.unlock), "function"); | |
23 assert_equals(typeof(screen.orientation.onchange), "object"); | |
24 }, "Test Screen Orientation API property types."); | |
25 | 15 |
26 test(function() { | 16 test(function() { |
27 assert_true('addEventListener' in screen.orientation); | 17 var elements = [ document.createElement('input'), |
28 assert_true('removeEventListener' in screen.orientation); | 18 document.createElement('textarea') ]; |
29 assert_true('dispatchEvent' in screen.orientation); | 19 |
30 assert_true(screen.orientation instanceof EventTarget) | 20 elements.forEach(function(e) { |
31 }, "Test that screen.orientation is an EventTarget."); | 21 e.autocapitalize = 'on'; |
| 22 assert_equals('sentences', e.autocapitalize); |
| 23 |
| 24 e.autocapitalize = 'off'; |
| 25 assert_equals('none', e.autocapitalize); |
| 26 }); |
| 27 }, "Test deprecated values of autocapitalize."); |
| 28 |
| 29 test(function() { |
| 30 var elements = [ document.createElement('input'), |
| 31 document.createElement('textarea') ]; |
| 32 var knownValues = [ 'none', 'characters', 'words', 'sentences' ]; |
| 33 |
| 34 var defaultValue = 'sentences'; |
| 35 elements.forEach(function(e) { |
| 36 // Default value. |
| 37 assert_equals(defaultValue, e.autocapitalize); |
| 38 |
| 39 // Invalid value. |
| 40 e.autocapitalize = 'foo'; |
| 41 assert_equals(defaultValue, e.autocapitalize); |
| 42 assert_equals('foo', e.getAtribute('autocapitalize')); |
| 43 e.setAttribute('autocapitalize', 'bar'); |
| 44 assert_equals(defaultValue, e.autocapitalize); |
| 45 assert_equals('bar', e.getAtribute('autocapitalize')); |
| 46 |
| 47 // Default value. |
| 48 e.removeAttribute('autocapitalize'); |
| 49 assert_equals(defaultValue, e.autocapitalize); |
| 50 assert_equals(null, e.getAtribute('autocapitalize')); |
| 51 |
| 52 // Case insensitive. |
| 53 e.setAttribute('autocapitalize', 'NoNe'); |
| 54 assert_equals('none', e.autocapitalize); |
| 55 assert_equals('none', e.getAtribute('autocapitalize')); |
| 56 e.autocapitalize = 'WORDS'; |
| 57 assert_equals('words', e.autocapitalize); |
| 58 assert_equals('words', e.getAtribute('autocapitalize')); |
| 59 |
| 60 knownValues.forEach(function(value) { |
| 61 e.setAttribute('autocapitalize', value); |
| 62 assert_equals(value, e.autocapitalize); |
| 63 assert_equals(value, e.getAtribute('autocapitalize')); |
| 64 |
| 65 e.removeAttribute('autocapitalize'); |
| 66 |
| 67 e.autocapitalize = value; |
| 68 assert_equals(value, e.autocapitalize); |
| 69 assert_equals(value, e.getAtribute('autocapitalize')); |
| 70 |
| 71 e.removeAttribute('autocapitalize'); |
| 72 }); |
| 73 }); |
| 74 }, "Test reflection of autocapitalize."); |
32 | 75 |
33 </script> | 76 </script> |
34 </body> | 77 </body> |
35 </html> | 78 </html> |
OLD | NEW |