| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/base_switches.h" | 5 #include "base/base_switches.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 " <input id='three'>" | 142 " <input id='three'>" |
| 143 " <input id='four' autocomplete='off'>" | 143 " <input id='four' autocomplete='off'>" |
| 144 " <input type='submit'>" | 144 " <input type='submit'>" |
| 145 "</form>" | 145 "</form>" |
| 146 "<script>" | 146 "<script>" |
| 147 " document.onclick = function() {" | 147 " document.onclick = function() {" |
| 148 " document.getElementById('test_form').submit();" | 148 " document.getElementById('test_form').submit();" |
| 149 " };" | 149 " };" |
| 150 "</script>"; | 150 "</script>"; |
| 151 const char kQueryRequest[] = | 151 const char kQueryRequest[] = |
| 152 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | 152 "<?xml version=\"1.0\"?>\n" |
| 153 "<autofillquery clientversion=\"6.1.1715.1442/en (GGLL)\">" | 153 "<autofillquery clientversion=\"6.1.1715.1442/en (GGLL)\">" |
| 154 "<form signature=\"15916856893790176210\">" | 154 "<form signature=\"15916856893790176210\">" |
| 155 "<field signature=\"2594484045\" name=\"one\" type=\"text\"/>" | 155 "<field signature=\"2594484045\" name=\"one\" type=\"text\"/>" |
| 156 "<field signature=\"2750915947\" name=\"two\" type=\"text\"/>" | 156 "<field signature=\"2750915947\" name=\"two\" type=\"text\"/>" |
| 157 "<field signature=\"3494787134\" name=\"three\" type=\"text\"/>" | 157 "<field signature=\"3494787134\" name=\"three\" type=\"text\"/>" |
| 158 "<field signature=\"1236501728\" name=\"four\" type=\"text\"/></form>" | 158 "<field signature=\"1236501728\" name=\"four\" type=\"text\"/></form>" |
| 159 "</autofillquery>"; | 159 "</autofillquery>\n"; |
| 160 WindowedNetworkObserver query_network_observer(Compress(kQueryRequest)); | 160 WindowedNetworkObserver query_network_observer(Compress(kQueryRequest)); |
| 161 ui_test_utils::NavigateToURL( | 161 ui_test_utils::NavigateToURL( |
| 162 browser(), GURL(std::string(kDataURIPrefix) + kFormHtml)); | 162 browser(), GURL(std::string(kDataURIPrefix) + kFormHtml)); |
| 163 query_network_observer.Wait(); | 163 query_network_observer.Wait(); |
| 164 | 164 |
| 165 // Submit the form, using a simulated mouse click because form submissions not | 165 // Submit the form, using a simulated mouse click because form submissions not |
| 166 // triggered by user gestures are ignored. Expect an upload request upon form | 166 // triggered by user gestures are ignored. Expect an upload request upon form |
| 167 // submission, with form fields matching those from the query request. | 167 // submission, with form fields matching those from the query request. |
| 168 const char kUploadRequest[] = | 168 const char kUploadRequest[] = |
| 169 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | 169 "<?xml version=\"1.0\"?>\n" |
| 170 "<autofillupload clientversion=\"6.1.1715.1442/en (GGLL)\"" | 170 "<autofillupload clientversion=\"6.1.1715.1442/en (GGLL)\"" |
| 171 " formsignature=\"15916856893790176210\"" | 171 " formsignature=\"15916856893790176210\"" |
| 172 " autofillused=\"false\"" | 172 " autofillused=\"false\"" |
| 173 " datapresent=\"1f7e0003780000080004\"" | 173 " datapresent=\"1f7e0003780000080004\"" |
| 174 " actionsignature=\"15724779818122431245\" formname=\"test_form\">" | 174 " actionsignature=\"15724779818122431245\" formname=\"test_form\">" |
| 175 "<field signature=\"2594484045\" name=\"one\" type=\"text\"" | 175 "<field signature=\"2594484045\" name=\"one\" type=\"text\"" |
| 176 " autofilltype=\"2\"/>" | 176 " autofilltype=\"2\"/>" |
| 177 "<field signature=\"2750915947\" name=\"two\" type=\"text\"" | 177 "<field signature=\"2750915947\" name=\"two\" type=\"text\"" |
| 178 " autocomplete=\"off\" autofilltype=\"2\"/>" | 178 " autocomplete=\"off\" autofilltype=\"2\"/>" |
| 179 "<field signature=\"3494787134\" name=\"three\" type=\"text\"" | 179 "<field signature=\"3494787134\" name=\"three\" type=\"text\"" |
| 180 " autofilltype=\"2\"/>" | 180 " autofilltype=\"2\"/>" |
| 181 "<field signature=\"1236501728\" name=\"four\" type=\"text\"" | 181 "<field signature=\"1236501728\" name=\"four\" type=\"text\"" |
| 182 " autocomplete=\"off\" autofilltype=\"2\"/>" | 182 " autocomplete=\"off\" autofilltype=\"2\"/>" |
| 183 "</autofillupload>"; | 183 "</autofillupload>\n"; |
| 184 | 184 |
| 185 WindowedNetworkObserver upload_network_observer(Compress(kUploadRequest)); | 185 WindowedNetworkObserver upload_network_observer(Compress(kUploadRequest)); |
| 186 content::WebContents* web_contents = | 186 content::WebContents* web_contents = |
| 187 browser()->tab_strip_model()->GetActiveWebContents(); | 187 browser()->tab_strip_model()->GetActiveWebContents(); |
| 188 content::SimulateMouseClick( | 188 content::SimulateMouseClick( |
| 189 web_contents, 0, blink::WebMouseEvent::ButtonLeft); | 189 web_contents, 0, blink::WebMouseEvent::ButtonLeft); |
| 190 upload_network_observer.Wait(); | 190 upload_network_observer.Wait(); |
| 191 } | 191 } |
| 192 | 192 |
| 193 // Verify that a site with password fields will query even in the presence | 193 // Verify that a site with password fields will query even in the presence |
| 194 // of user defined autocomplete types. | 194 // of user defined autocomplete types. |
| 195 IN_PROC_BROWSER_TEST_F(AutofillServerTest, | 195 IN_PROC_BROWSER_TEST_F(AutofillServerTest, |
| 196 AlwaysQueryForPasswordFields) { | 196 AlwaysQueryForPasswordFields) { |
| 197 // Load the test page. Expect a query request upon loading the page. | 197 // Load the test page. Expect a query request upon loading the page. |
| 198 const char kDataURIPrefix[] = "data:text/html;charset=utf-8,"; | 198 const char kDataURIPrefix[] = "data:text/html;charset=utf-8,"; |
| 199 const char kFormHtml[] = | 199 const char kFormHtml[] = |
| 200 "<form id='test_form'>" | 200 "<form id='test_form'>" |
| 201 " <input type='text' id='one' autocomplete='username'>" | 201 " <input type='text' id='one' autocomplete='username'>" |
| 202 " <input type='text' id='two' autocomplete='off'>" | 202 " <input type='text' id='two' autocomplete='off'>" |
| 203 " <input type='password' id='three'>" | 203 " <input type='password' id='three'>" |
| 204 " <input type='submit'>" | 204 " <input type='submit'>" |
| 205 "</form>"; | 205 "</form>"; |
| 206 const char kQueryRequest[] = | 206 const char kQueryRequest[] = |
| 207 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | 207 "<?xml version=\"1.0\"?>\n" |
| 208 "<autofillquery clientversion=\"6.1.1715.1442/en (GGLL)\">" | 208 "<autofillquery clientversion=\"6.1.1715.1442/en (GGLL)\">" |
| 209 "<form signature=\"8900697631820480876\">" | 209 "<form signature=\"8900697631820480876\">" |
| 210 "<field signature=\"2594484045\" name=\"one\" type=\"text\"/>" | 210 "<field signature=\"2594484045\" name=\"one\" type=\"text\"/>" |
| 211 "<field signature=\"2750915947\" name=\"two\" type=\"text\"/>" | 211 "<field signature=\"2750915947\" name=\"two\" type=\"text\"/>" |
| 212 "<field signature=\"116843943\" name=\"three\" type=\"password\"/>" | 212 "<field signature=\"116843943\" name=\"three\" type=\"password\"/>" |
| 213 "</form></autofillquery>"; | 213 "</form></autofillquery>\n"; |
| 214 WindowedNetworkObserver query_network_observer(Compress(kQueryRequest)); | 214 WindowedNetworkObserver query_network_observer(Compress(kQueryRequest)); |
| 215 ui_test_utils::NavigateToURL( | 215 ui_test_utils::NavigateToURL( |
| 216 browser(), GURL(std::string(kDataURIPrefix) + kFormHtml)); | 216 browser(), GURL(std::string(kDataURIPrefix) + kFormHtml)); |
| 217 query_network_observer.Wait(); | 217 query_network_observer.Wait(); |
| 218 } | 218 } |
| 219 | 219 |
| 220 } // namespace autofill | 220 } // namespace autofill |
| OLD | NEW |