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/utf_string_conversions.h" | 5 #include "base/utf_string_conversions.h" |
6 #include "chrome/test/base/chrome_render_view_test.h" | 6 #include "chrome/test/base/chrome_render_view_test.h" |
7 #include "components/autofill/common/autofill_messages.h" | 7 #include "components/autofill/common/autofill_messages.h" |
8 #include "components/autofill/common/form_data.h" | 8 #include "components/autofill/common/form_data.h" |
9 #include "components/autofill/common/form_field_data.h" | 9 #include "components/autofill/common/form_field_data.h" |
| 10 #include "components/autofill/renderer/page_click_listener.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "third_party/WebKit/public/platform/WebString.h" | 12 #include "third_party/WebKit/public/platform/WebString.h" |
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" |
14 | 15 |
15 using WebKit::WebDocument; | 16 using WebKit::WebDocument; |
16 using WebKit::WebFrame; | 17 using WebKit::WebFrame; |
17 using WebKit::WebInputElement; | 18 using WebKit::WebInputElement; |
18 using WebKit::WebString; | 19 using WebKit::WebString; |
19 | 20 |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 WebFrame* web_frame = GetMainFrame(); | 254 WebFrame* web_frame = GetMainFrame(); |
254 WebDocument document = web_frame->document(); | 255 WebDocument document = web_frame->document(); |
255 WebInputElement firstname = | 256 WebInputElement firstname = |
256 document.getElementById("firstname").to<WebInputElement>(); | 257 document.getElementById("firstname").to<WebInputElement>(); |
257 WebInputElement middlename = | 258 WebInputElement middlename = |
258 document.getElementById("middlename").to<WebInputElement>(); | 259 document.getElementById("middlename").to<WebInputElement>(); |
259 | 260 |
260 // Simulate attempting to Autofill the form from the first element, which | 261 // Simulate attempting to Autofill the form from the first element, which |
261 // specifies autocomplete="off". This should still not trigger an IPC, as we | 262 // specifies autocomplete="off". This should still not trigger an IPC, as we |
262 // don't show warnings for elements that have autocomplete="off". | 263 // don't show warnings for elements that have autocomplete="off". |
263 autofill_agent_->InputElementClicked(firstname, true, true); | 264 autofill_agent_->InputElementClicked(firstname, true, true, MOUSE_CLICK); |
264 const IPC::Message* message1 = render_thread_->sink().GetFirstMessageMatching( | 265 const IPC::Message* message1 = render_thread_->sink().GetFirstMessageMatching( |
265 AutofillHostMsg_QueryFormFieldAutofill::ID); | 266 AutofillHostMsg_QueryFormFieldAutofill::ID); |
266 EXPECT_EQ(static_cast<IPC::Message*>(NULL), message1); | 267 EXPECT_EQ(static_cast<IPC::Message*>(NULL), message1); |
267 | 268 |
268 // Simulate attempting to Autofill the form from the second element, which | 269 // Simulate attempting to Autofill the form from the second element, which |
269 // does not specify autocomplete="off". This *should* trigger an IPC, as we | 270 // does not specify autocomplete="off". This *should* trigger an IPC, as we |
270 // *do* show warnings for elements that don't themselves set | 271 // *do* show warnings for elements that don't themselves set |
271 // autocomplete="off", but for which the form does. | 272 // autocomplete="off", but for which the form does. |
272 autofill_agent_->InputElementClicked(middlename, true, true); | 273 autofill_agent_->InputElementClicked(middlename, true, true, MOUSE_CLICK); |
273 const IPC::Message* message2 = render_thread_->sink().GetFirstMessageMatching( | 274 const IPC::Message* message2 = render_thread_->sink().GetFirstMessageMatching( |
274 AutofillHostMsg_QueryFormFieldAutofill::ID); | 275 AutofillHostMsg_QueryFormFieldAutofill::ID); |
275 ASSERT_NE(static_cast<IPC::Message*>(NULL), message2); | 276 ASSERT_NE(static_cast<IPC::Message*>(NULL), message2); |
276 // TODO(isherman): It would be nice to verify here that the message includes | 277 // TODO(isherman): It would be nice to verify here that the message includes |
277 // the correct data. I'm not sure how to extract that information from an | 278 // the correct data. I'm not sure how to extract that information from an |
278 // IPC::Message though. | 279 // IPC::Message though. |
279 } | 280 } |
280 | 281 |
281 } // namespace autofill | 282 } // namespace autofill |
OLD | NEW |