Chromium Code Reviews| Index: chrome/renderer/autofill/autofill_renderer_browsertest.cc |
| diff --git a/chrome/renderer/autofill/autofill_renderer_browsertest.cc b/chrome/renderer/autofill/autofill_renderer_browsertest.cc |
| index c1a5f5a4dcfd58d2ca40130ada8b1b734465c9d0..e4f8138c46eccd41d99395672487bad75426c924 100644 |
| --- a/chrome/renderer/autofill/autofill_renderer_browsertest.cc |
| +++ b/chrome/renderer/autofill/autofill_renderer_browsertest.cc |
| @@ -173,4 +173,50 @@ TEST_F(ChromeRenderViewTest, FillFormElement) { |
| EXPECT_EQ(firstname.value(), WebKit::WebString::fromUTF8("David")); |
| } |
| +TEST_F(ChromeRenderViewTest, ShowAutofillWarning) { |
|
Dan Beam
2012/11/06 02:24:11
btw, I don't have a ton of experience with these k
Ilya Sherman
2012/11/06 03:45:08
Yeah, I haven't figured out how to write great tes
|
| + // Don't want any delay for form state sync changes. This will still post a |
|
Dan Beam
2012/11/06 02:22:17
nit: shouldn't this be a double space?
Ilya Sherman
2012/11/06 03:45:08
Done.
|
| + // message so updates will get coalesced, but as soon as we spin the message |
| + // loop, it will generate an update. |
| + SendContentStateImmediately(); |
| + |
| + LoadHTML("<form method=\"POST\" autocomplete=\"Off\">" |
| + " <input id=\"firstname\" autocomplete=\"OFF\"/>" |
| + " <input id=\"middlename\"/>" |
| + " <input id=\"lastname\"/>" |
| + "</form>"); |
| + |
| + // Verify that "QueryFormFieldAutofill" isn't sent prior to a user |
| + // interaction. |
| + const IPC::Message* message0 = render_thread_->sink().GetFirstMessageMatching( |
| + AutofillHostMsg_QueryFormFieldAutofill::ID); |
| + EXPECT_EQ(static_cast<IPC::Message*>(NULL), message0); |
| + |
| + WebFrame* web_frame = GetMainFrame(); |
| + WebDocument document = web_frame->document(); |
| + WebInputElement firstname = |
| + document.getElementById("firstname").to<WebInputElement>(); |
| + WebInputElement middlename = |
| + document.getElementById("middlename").to<WebInputElement>(); |
| + |
| + // Simulate attempting to Autofill the form from the first element, which |
| + // specifies autocomplete="off". This should still not trigger an IPC, as we |
| + // don't show warnings for elements that have autocomplete="off". |
| + autofill_agent_->InputElementClicked(firstname, true, true); |
| + const IPC::Message* message1 = render_thread_->sink().GetFirstMessageMatching( |
| + AutofillHostMsg_QueryFormFieldAutofill::ID); |
| + EXPECT_EQ(static_cast<IPC::Message*>(NULL), message1); |
| + |
| + // Simulate attempting to Autofill the form from the second element, which |
| + // does not specify autocomplete="off". This *should* trigger an IPC, as we |
| + // *do* show warnings for elements that don't themselves set |
| + // autocomplete="off", but for which the form does. |
| + autofill_agent_->InputElementClicked(middlename, true, true); |
| + const IPC::Message* message2 = render_thread_->sink().GetFirstMessageMatching( |
| + AutofillHostMsg_QueryFormFieldAutofill::ID); |
| + ASSERT_NE(static_cast<IPC::Message*>(NULL), message2); |
| + // TODO(isherman): It would be nice to verify here that the message includes |
| + // the correct data. I'm not sure how to extract that information from an |
| + // IPC::Message though. |
| +} |
| + |
| } // namespace autofill |