| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/strings/string_util.h" | 5 #include "base/strings/string_util.h" |
| 6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
| 7 #include "chrome/test/base/chrome_render_view_test.h" | 7 #include "chrome/test/base/chrome_render_view_test.h" |
| 8 #include "components/autofill/content/common/autofill_messages.h" | 8 #include "components/autofill/content/common/autofill_messages.h" |
| 9 #include "components/autofill/content/renderer/autofill_agent.h" | 9 #include "components/autofill/content/renderer/autofill_agent.h" |
| 10 #include "components/autofill/content/renderer/form_autofill_util.h" | 10 #include "components/autofill/content/renderer/form_autofill_util.h" |
| 11 #include "components/autofill/content/renderer/password_autofill_agent.h" | 11 #include "components/autofill/content/renderer/password_autofill_agent.h" |
| 12 #include "components/autofill/content/renderer/test_password_autofill_agent.h" | 12 #include "components/autofill/content/renderer/test_password_autofill_agent.h" |
| 13 #include "components/autofill/core/common/form_data.h" | 13 #include "components/autofill/core/common/form_data.h" |
| 14 #include "components/autofill/core/common/form_field_data.h" | 14 #include "components/autofill/core/common/form_field_data.h" |
| 15 #include "components/autofill/core/common/password_autofill_util.h" | |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "third_party/WebKit/public/platform/WebString.h" | 16 #include "third_party/WebKit/public/platform/WebString.h" |
| 18 #include "third_party/WebKit/public/platform/WebVector.h" | 17 #include "third_party/WebKit/public/platform/WebVector.h" |
| 19 #include "third_party/WebKit/public/web/WebDocument.h" | 18 #include "third_party/WebKit/public/web/WebDocument.h" |
| 20 #include "third_party/WebKit/public/web/WebElement.h" | 19 #include "third_party/WebKit/public/web/WebElement.h" |
| 21 #include "third_party/WebKit/public/web/WebFormElement.h" | 20 #include "third_party/WebKit/public/web/WebFormElement.h" |
| 22 #include "third_party/WebKit/public/web/WebFrame.h" | 21 #include "third_party/WebKit/public/web/WebFrame.h" |
| 23 #include "third_party/WebKit/public/web/WebInputElement.h" | 22 #include "third_party/WebKit/public/web/WebInputElement.h" |
| 24 #include "third_party/WebKit/public/web/WebNode.h" | 23 #include "third_party/WebKit/public/web/WebNode.h" |
| 25 #include "third_party/WebKit/public/web/WebView.h" | 24 #include "third_party/WebKit/public/web/WebView.h" |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 // the browser was generated. | 294 // the browser was generated. |
| 296 // | 295 // |
| 297 // This is interesting in the specific case of an autocomplete='off' form | 296 // This is interesting in the specific case of an autocomplete='off' form |
| 298 // that also has a remembered username and password | 297 // that also has a remembered username and password |
| 299 // (http://crbug.com/326679). To fix the DCHECK that this case used to hit, | 298 // (http://crbug.com/326679). To fix the DCHECK that this case used to hit, |
| 300 // |true| is returned from ShowSuggestions for all forms with valid | 299 // |true| is returned from ShowSuggestions for all forms with valid |
| 301 // usersnames that are autocomplete='off', prentending that a selection box | 300 // usersnames that are autocomplete='off', prentending that a selection box |
| 302 // has been shown to the user. Of course, it hasn't, so a message is never | 301 // has been shown to the user. Of course, it hasn't, so a message is never |
| 303 // sent to the browser on acceptance, and the DCHECK isn't hit (and nothing | 302 // sent to the browser on acceptance, and the DCHECK isn't hit (and nothing |
| 304 // is filled). | 303 // is filled). |
| 305 // | 304 EXPECT_TRUE(autofill_agent_->password_autofill_agent_->ShowSuggestions( |
| 306 // These tests only make sense in the context of not ignoring | 305 username_element_)); |
| 307 // autocomplete='off', so only test them if the disable autocomplete='off' | |
| 308 // flag is not enabled. | |
| 309 // TODO(jww): Remove this function and callers once autocomplete='off' is | |
| 310 // permanently ignored. | |
| 311 if (!ShouldIgnoreAutocompleteOffForPasswordFields()) { | |
| 312 EXPECT_TRUE(autofill_agent_->password_autofill_agent_->ShowSuggestions( | |
| 313 username_element_)); | |
| 314 | 306 |
| 315 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( | 307 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( |
| 316 AutofillHostMsg_ShowPasswordSuggestions::ID)); | 308 AutofillHostMsg_ShowPasswordSuggestions::ID)); |
| 317 } | |
| 318 } | 309 } |
| 319 | 310 |
| 320 void SimulateKeyDownEvent(const WebInputElement& element, | 311 void SimulateKeyDownEvent(const WebInputElement& element, |
| 321 ui::KeyboardCode key_code) { | 312 ui::KeyboardCode key_code) { |
| 322 blink::WebKeyboardEvent key_event; | 313 blink::WebKeyboardEvent key_event; |
| 323 key_event.windowsKeyCode = key_code; | 314 key_event.windowsKeyCode = key_code; |
| 324 autofill_agent_->textFieldDidReceiveKeyDown(element, key_event); | 315 autofill_agent_->textFieldDidReceiveKeyDown(element, key_event); |
| 325 } | 316 } |
| 326 | 317 |
| 327 void CheckTextFieldsStateForElements(const WebInputElement& username_element, | 318 void CheckTextFieldsStateForElements(const WebInputElement& username_element, |
| (...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1010 &username_onchange_called)); | 1001 &username_onchange_called)); |
| 1011 EXPECT_EQ(1, username_onchange_called); | 1002 EXPECT_EQ(1, username_onchange_called); |
| 1012 ASSERT_TRUE( | 1003 ASSERT_TRUE( |
| 1013 ExecuteJavaScriptAndReturnIntValue( | 1004 ExecuteJavaScriptAndReturnIntValue( |
| 1014 ASCIIToUTF16("passwordOnchangeCalled ? 1 : 0"), | 1005 ASCIIToUTF16("passwordOnchangeCalled ? 1 : 0"), |
| 1015 &password_onchange_called)); | 1006 &password_onchange_called)); |
| 1016 EXPECT_EQ(1, password_onchange_called); | 1007 EXPECT_EQ(1, password_onchange_called); |
| 1017 } | 1008 } |
| 1018 | 1009 |
| 1019 } // namespace autofill | 1010 } // namespace autofill |
| OLD | NEW |