Upstream version 10.38.222.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / fast / forms / input-autofilled.html
1 <head>
2     <script src="../../resources/js-test.js"></script>
3     <script>
4     function test() {
5         if (window.testRunner) {
6             testRunner.dumpAsText();
7         }
8
9         if (!window.internals) {
10             testFailed('This test requires the test harness to run.');
11             return;
12         }
13
14         var field = document.getElementById('field');
15         var textarea = document.getElementById('textarea');
16         var select = document.getElementById('select');
17
18         var computedStyleField = document.defaultView.getComputedStyle(field);
19         var computedStyleTextarea = document.defaultView.getComputedStyle(textarea);
20         var computedStyleSelect = document.defaultView.getComputedStyle(select);
21         var originalForeground = computedStyleField.color;
22         var originalBackground = computedStyleField.backgroundColor;
23
24         if (originalForeground != computedStyleTextarea.color) {
25             testFailed('Unexpected initial foreground color for <textarea> field.');
26             return;
27         }
28         if (originalForeground != computedStyleTextarea.backgroundColor) {
29             testFailed('Unexpected initial background color for <textarea> field.');
30             return;
31         }
32
33         if (window.internals) {
34             window.internals.setAutofilled(field, true);
35             window.internals.setAutofilled(textarea, true);
36             window.internals.setAutofilled(select, true);
37         }
38
39         // Both the foreground and background colors should change.
40         computedStyleField = document.defaultView.getComputedStyle(field);
41         computedStyleTextarea = document.defaultView.getComputedStyle(textarea);
42         computedStyleSelect = document.defaultView.getComputedStyle(select);
43         if (computedStyleField.color == originalForeground) {
44             testFailed('Foreground color for <input> element did not change when autofilled.');
45             return;
46         }
47         if (computedStyleField.backgroundColor == originalBackground) {
48             testFailed('Background color for <input> element did not change when autofilled.');
49             return;
50         }
51         if (computedStyleTextarea.color == originalForeground) {
52             testFailed('Foreground color for <textarea> element did not change when autofilled.');
53             return;
54         }
55         if (computedStyleTextarea.backgroundColor == originalBackground) {
56             testFailed('Background color for <textarea> element did not change when autofilled.');
57             return;
58         }
59         if (computedStyleSelect.color == originalForeground) {
60             testFailed('Foreground color for <select> element did not change when autofilled.');
61             return;
62         }
63         if (computedStyleSelect.backgroundColor == originalBackground) {
64             testFailed('Background color for <select> element did not change when autofilled.');
65             return;
66         }
67
68         if (window.internals) {
69             window.internals.setAutofilled(field, false);
70             window.internals.setAutofilled(textarea, false);
71             window.internals.setAutofilled(select, false);
72         }
73
74         // Colors should be restored.
75         computedStyleField = document.defaultView.getComputedStyle(field);
76         computedStyleTextarea = document.defaultView.getComputedStyle(textarea);
77         computedStyleSelect = document.defaultView.getComputedStyle(select);
78         if (computedStyleField.color != originalForeground) {
79             testFailed('Foreground color for <input> element did not revert when un-autofilled.');
80             return;
81         }
82         if (computedStyleField.backgroundColor != originalBackground) {
83             testFailed('Background color for <input> element did not revert when un-autofilled.');
84             return;
85         }
86         if (computedStyleTextarea.color != originalForeground) {
87             testFailed('Foreground color for <textarea> element did not revert when un-autofilled.');
88             return;
89         }
90         if (computedStyleTextarea.backgroundColor != originalBackground) {
91             testFailed('Background color for <textarea> element did not revert when un-autofilled.');
92             return;
93         }
94         if (computedStyleSelect.color != originalForeground) {
95             testFailed('Foreground color for <select> element did not revert when un-autofilled.');
96             return;
97         }
98         if (computedStyleSelect.backgroundColor != originalBackground) {
99             testFailed('Background color for <select> element did not revert when un-autofilled.');
100             return;
101         }
102
103         testPassed('');
104     }
105     </script>
106
107     <style>
108     #field, #textarea, #select {
109       color: #FFFFFF;
110       background-color: #FFFFFF;
111     }
112     </style>
113 </head>
114 <body onload="test()">
115     This tests that foreground and background colors properly change for autofilled inputs or select options.  It can only be run using the test harness.<br>
116     <form name="fm">
117         <input type="text" id="field" value="Field value">
118         <textarea id="textarea"></textarea>
119         <select id="select"></select>
120     </form>
121     <div id="console"></div>
122 </body>