| 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/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/test/base/chrome_render_view_test.h" | 8 #include "chrome/test/base/chrome_render_view_test.h" |
| 9 #include "components/autofill/content/common/autofill_messages.h" | 9 #include "components/autofill/content/common/autofill_messages.h" |
| 10 #include "components/autofill/content/renderer/autofill_agent.h" | 10 #include "components/autofill/content/renderer/autofill_agent.h" |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 TEST_F(RequestAutocompleteRendererTest, MainFrameNavigateCancels) { | 272 TEST_F(RequestAutocompleteRendererTest, MainFrameNavigateCancels) { |
| 273 // Pretend that the top-level frame navigated. A cancel should be sent. | 273 // Pretend that the top-level frame navigated. A cancel should be sent. |
| 274 NavigateFrame(GetMainFrame()); | 274 NavigateFrame(GetMainFrame()); |
| 275 EXPECT_TRUE(render_thread_->sink().GetFirstMessageMatching( | 275 EXPECT_TRUE(render_thread_->sink().GetFirstMessageMatching( |
| 276 AutofillHostMsg_CancelRequestAutocomplete::ID)); | 276 AutofillHostMsg_CancelRequestAutocomplete::ID)); |
| 277 } | 277 } |
| 278 | 278 |
| 279 TEST_F(RequestAutocompleteRendererTest, NoCancelOnSubframeNavigateAfterDone) { | 279 TEST_F(RequestAutocompleteRendererTest, NoCancelOnSubframeNavigateAfterDone) { |
| 280 // Pretend that the dialog was cancelled. | 280 // Pretend that the dialog was cancelled. |
| 281 autofill_agent_->OnRequestAutocompleteResult( | 281 autofill_agent_->OnRequestAutocompleteResult( |
| 282 WebFormElement::AutocompleteResultErrorCancel, FormData()); | 282 WebFormElement::AutocompleteResultErrorCancel, |
| 283 base::ASCIIToUTF16("Print me to the console"), |
| 284 FormData()); |
| 283 | 285 |
| 284 // Additional navigations should not crash nor send cancels. | 286 // Additional navigations should not crash nor send cancels. |
| 285 NavigateFrame(invoking_frame()); | 287 NavigateFrame(invoking_frame()); |
| 286 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( | 288 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( |
| 287 AutofillHostMsg_CancelRequestAutocomplete::ID)); | 289 AutofillHostMsg_CancelRequestAutocomplete::ID)); |
| 288 } | 290 } |
| 289 | 291 |
| 290 TEST_F(RequestAutocompleteRendererTest, NoCancelOnMainFrameNavigateAfterDone) { | 292 TEST_F(RequestAutocompleteRendererTest, NoCancelOnMainFrameNavigateAfterDone) { |
| 291 // Pretend that the dialog was cancelled. | 293 // Pretend that the dialog was cancelled. |
| 292 autofill_agent_->OnRequestAutocompleteResult( | 294 autofill_agent_->OnRequestAutocompleteResult( |
| 293 WebFormElement::AutocompleteResultErrorCancel, FormData()); | 295 WebFormElement::AutocompleteResultErrorCancel, |
| 296 base::ASCIIToUTF16("Print me to the console"), |
| 297 FormData()); |
| 294 | 298 |
| 295 // Additional navigations should not crash nor send cancels. | 299 // Additional navigations should not crash nor send cancels. |
| 296 NavigateFrame(GetMainFrame()); | 300 NavigateFrame(GetMainFrame()); |
| 297 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( | 301 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( |
| 298 AutofillHostMsg_CancelRequestAutocomplete::ID)); | 302 AutofillHostMsg_CancelRequestAutocomplete::ID)); |
| 299 } | 303 } |
| 300 | 304 |
| 301 TEST_F(RequestAutocompleteRendererTest, InvokingTwiceOnlyShowsOnce) { | 305 TEST_F(RequestAutocompleteRendererTest, InvokingTwiceOnlyShowsOnce) { |
| 302 // Attempting to show the requestAutocomplete dialog again should be ignored. | 306 // Attempting to show the requestAutocomplete dialog again should be ignored. |
| 303 autofill_agent_->didRequestAutocomplete(invoking_frame(), invoking_form()); | 307 autofill_agent_->didRequestAutocomplete(invoking_frame(), invoking_form()); |
| 304 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( | 308 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( |
| 305 AutofillHostMsg_RequestAutocomplete::ID)); | 309 AutofillHostMsg_RequestAutocomplete::ID)); |
| 306 } | 310 } |
| 307 | 311 |
| 308 } // namespace autofill | 312 } // namespace autofill |
| OLD | NEW |