Index: chrome/renderer/autofill/password_autofill_agent_browsertest.cc |
diff --git a/chrome/renderer/autofill/password_autofill_agent_browsertest.cc b/chrome/renderer/autofill/password_autofill_agent_browsertest.cc |
index bec975b9156f5ac7d7fe1efed8757a6954ce7b8d..0953ad255654942eb9a1bc790eae74697aaae871 100644 |
--- a/chrome/renderer/autofill/password_autofill_agent_browsertest.cc |
+++ b/chrome/renderer/autofill/password_autofill_agent_browsertest.cc |
@@ -12,6 +12,7 @@ |
#include "components/autofill/content/renderer/test_password_autofill_agent.h" |
#include "components/autofill/core/common/form_data.h" |
#include "components/autofill/core/common/form_field_data.h" |
+#include "content/public/renderer/render_frame.h" |
#include "testing/gtest/include/gtest/gtest.h" |
#include "third_party/WebKit/public/platform/WebString.h" |
#include "third_party/WebKit/public/platform/WebVector.h" |
@@ -178,13 +179,21 @@ class PasswordAutofillAgentTest : public ChromeRenderViewTest { |
void SimulateOnFillPasswordForm( |
const PasswordFormFillData& fill_data) { |
AutofillMsg_FillPasswordForm msg(0, kPasswordFillFormDataId, fill_data); |
- static_cast<content::RenderViewObserver*>(password_autofill_agent_) |
+ static_cast<content::RenderFrameObserver*>(password_autofill_agent_) |
->OnMessageReceived(msg); |
} |
+ // As above, but fills for an iframe. |
+ void SimulateOnFillPasswordFormForFrame( |
+ WebFrame* frame, |
+ const PasswordFormFillData& fill_data) { |
+ AutofillMsg_FillPasswordForm msg(0, kPasswordFillFormDataId, fill_data); |
+ content::RenderFrame::FromWebFrame(frame)->OnMessageReceived(msg); |
+ } |
+ |
void SendVisiblePasswordForms() { |
- static_cast<content::RenderViewObserver*>(password_autofill_agent_) |
- ->DidFinishLoad(GetMainFrame()); |
+ static_cast<content::RenderFrameObserver*>(password_autofill_agent_) |
+ ->DidFinishLoad(); |
} |
void SetUp() override { |
@@ -280,10 +289,11 @@ class PasswordAutofillAgentTest : public ChromeRenderViewTest { |
input_frame->document().frame()->view()->advanceFocus(false); |
if (move_caret_to_end) |
input.setSelectionRange(new_value.length(), new_value.length()); |
- if (is_user_input) |
- password_autofill_agent_->FirstUserGestureObserved(); |
- static_cast<blink::WebAutofillClient*>(autofill_agent_) |
- ->textFieldDidChange(input); |
+ if (is_user_input) { |
+ AutofillMsg_FirstUserGestureObservedInTab msg(0); |
+ content::RenderFrame::FromWebFrame(input_frame)->OnMessageReceived(msg); |
+ } |
+ input_frame->toWebLocalFrame()->autofillClient()->textFieldDidChange(input); |
// Processing is delayed because of a Blink bug: |
// https://bugs.webkit.org/show_bug.cgi?id=16976 |
// See PasswordAutofillAgent::TextDidChangeInTextField() for details. |
@@ -308,7 +318,7 @@ class PasswordAutofillAgentTest : public ChromeRenderViewTest { |
->FormControlElementClicked(username_input, false); |
AutofillMsg_FillPasswordSuggestion msg(0, username, password); |
- static_cast<content::RenderViewObserver*>(autofill_agent_) |
+ static_cast<content::RenderFrameObserver*>(autofill_agent_) |
->OnMessageReceived(msg); |
} |
@@ -852,12 +862,13 @@ TEST_F(PasswordAutofillAgentTest, IframeNoFillTest) { |
fill_data_.origin = GURL(origin); |
fill_data_.action = GURL(origin); |
- SimulateOnFillPasswordForm(fill_data_); |
- |
// Retrieve the input elements from the iframe since that is where we want to |
// test the autofill. |
WebFrame* iframe = GetMainFrame()->findChildByName(kIframeName); |
ASSERT_TRUE(iframe); |
+ |
+ SimulateOnFillPasswordFormForFrame(iframe, fill_data_); |
+ |
WebDocument document = iframe->document(); |
WebElement username_element = document.getElementById(kUsernameName); |
@@ -901,7 +912,7 @@ TEST_F(PasswordAutofillAgentTest, GestureRequiredTest) { |
CheckTextFieldsDOMState(kAliceUsername, true, std::string(), true); |
// Simulate a user click so that the password field's real value is filled. |
- SimulateElementClick(kUsernameName); |
+ password_autofill_agent_->FirstUserGestureObserved(); |
vabr (Chromium)
2014/11/25 15:56:57
This is decreasing the scope of the test: before i
Evan Stade
2014/11/25 21:07:40
turns out I can revert this.
|
CheckTextFieldsDOMState(kAliceUsername, true, kAlicePassword, true); |
} |
@@ -950,7 +961,7 @@ TEST_F(PasswordAutofillAgentTest, |
// EXPECT_EQ(0, password_onchange_called); |
// Simulate a user click so that the password field's real value is filled. |
- SimulateElementClick(kUsernameName); |
+ password_autofill_agent_->FirstUserGestureObserved(); |
CheckTextFieldsDOMState(kAliceUsername, true, kAlicePassword, true); |
// Now, a JavaScript onChange event should have been triggered for the |
@@ -1403,7 +1414,7 @@ TEST_F(PasswordAutofillAgentTest, |
// Simulate that the password value was cleared by the site's JavaScript |
// before submit. |
password_element_.setValue(WebString()); |
- static_cast<content::RenderViewObserver*>(password_autofill_agent_) |
+ static_cast<content::RenderViewObserver*>(&password_autofill_agent_->legacy_) |
->WillSubmitForm(GetMainFrame(), username_element_.form()); |
// Observe that the PasswordAutofillAgent still remembered the last non-empty |
@@ -1424,7 +1435,7 @@ TEST_F(PasswordAutofillAgentTest, |
// Simulate that the user actually cleared the password again. |
SimulateInputChangeForElement( |
"", true, GetMainFrame(), password_element_, true); |
- static_cast<content::RenderViewObserver*>(password_autofill_agent_) |
+ static_cast<content::RenderViewObserver*>(&password_autofill_agent_->legacy_) |
->WillSubmitForm(GetMainFrame(), username_element_.form()); |
// Observe that the PasswordAutofillAgent respects the user having cleared the |
@@ -1453,7 +1464,7 @@ TEST_F(PasswordAutofillAgentTest, |
// Simulate that the password value was cleared by the site's JavaScript |
// before submit. |
password_element_.setValue(WebString()); |
- static_cast<content::RenderViewObserver*>(password_autofill_agent_) |
+ static_cast<content::RenderViewObserver*>(&password_autofill_agent_->legacy_) |
->WillSubmitForm(GetMainFrame(), username_element_.form()); |
// Observe that the PasswordAutofillAgent still remembered the last non-empty |
@@ -1507,6 +1518,7 @@ TEST_F(PasswordAutofillAgentTest, |
ClearUsernameAndPasswordFields(); |
// The user enters a password |
+ password_autofill_agent_->FirstUserGestureObserved(); |
vabr (Chromium)
2014/11/25 15:56:57
Why is this needed? User-entered passwords should
Evan Stade
2014/11/25 21:07:40
Setting the value doesn't call FirstUserGestureObs
|
SimulateInputChangeForElement("someOtherPassword", |
/*move_caret_to_end=*/true, |
GetMainFrame(), |