Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: chrome/renderer/autofill/autofill_renderer_browsertest.cc

Issue 796493004: Remove FrameDetached and FrameWillClose listeners from AutofillAgent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix init order Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/files/file_util.h" 6 #include "base/files/file_util.h"
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/test/base/chrome_render_view_test.h" 9 #include "chrome/test/base/chrome_render_view_test.h"
10 #include "chrome/test/base/ui_test_utils.h" 10 #include "chrome/test/base/ui_test_utils.h"
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 359
360 protected: 360 protected:
361 WebFormElement invoking_form_; 361 WebFormElement invoking_form_;
362 WebLocalFrame* invoking_frame_; 362 WebLocalFrame* invoking_frame_;
363 WebFrame* sibling_frame_; 363 WebFrame* sibling_frame_;
364 364
365 private: 365 private:
366 DISALLOW_COPY_AND_ASSIGN(RequestAutocompleteRendererTest); 366 DISALLOW_COPY_AND_ASSIGN(RequestAutocompleteRendererTest);
367 }; 367 };
368 368
369 TEST_F(RequestAutocompleteRendererTest, SiblingNavigateIgnored) {
370 // Pretend that a sibling frame navigated. No cancel should be sent.
371 NavigateFrame(sibling_frame());
372 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching(
373 AutofillHostMsg_CancelRequestAutocomplete::ID));
374 }
375
376 TEST_F(RequestAutocompleteRendererTest, SubframeNavigateCancels) {
377 // Pretend that the invoking frame navigated. A cancel should be sent.
378 NavigateFrame(invoking_frame());
379 EXPECT_TRUE(render_thread_->sink().GetFirstMessageMatching(
380 AutofillHostMsg_CancelRequestAutocomplete::ID));
381 }
382
383 TEST_F(RequestAutocompleteRendererTest, MainFrameNavigateCancels) {
384 // Pretend that the top-level frame navigated. A cancel should be sent.
385 NavigateFrame(GetMainFrame());
386 EXPECT_TRUE(render_thread_->sink().GetFirstMessageMatching(
387 AutofillHostMsg_CancelRequestAutocomplete::ID));
388 }
389
390 TEST_F(RequestAutocompleteRendererTest, NoCancelOnSubframeNavigateAfterDone) {
391 // Pretend that the dialog was cancelled.
392 SimulateRequestAutocompleteResult(
393 invoking_frame_, WebFormElement::AutocompleteResultErrorCancel,
394 base::ASCIIToUTF16("Print me to the console"));
395
396 // Additional navigations should not crash nor send cancels.
397 NavigateFrame(invoking_frame());
398 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching(
399 AutofillHostMsg_CancelRequestAutocomplete::ID));
400 }
401
402 TEST_F(RequestAutocompleteRendererTest, NoCancelOnMainFrameNavigateAfterDone) {
403 // Pretend that the dialog was cancelled.
404 SimulateRequestAutocompleteResult(
405 invoking_frame_, WebFormElement::AutocompleteResultErrorCancel,
406 base::ASCIIToUTF16("Print me to the console"));
407
408 // Additional navigations should not crash nor send cancels.
409 NavigateFrame(GetMainFrame());
410 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching(
411 AutofillHostMsg_CancelRequestAutocomplete::ID));
412 }
413
414 TEST_F(RequestAutocompleteRendererTest, InvokingTwiceOnlyShowsOnce) { 369 TEST_F(RequestAutocompleteRendererTest, InvokingTwiceOnlyShowsOnce) {
415 // Attempting to show the requestAutocomplete dialog again should be ignored. 370 // Attempting to show the requestAutocomplete dialog again should be ignored.
416 invoking_frame_->autofillClient()->didRequestAutocomplete(invoking_form()); 371 invoking_frame_->autofillClient()->didRequestAutocomplete(invoking_form());
417 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( 372 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching(
418 AutofillHostMsg_RequestAutocomplete::ID)); 373 AutofillHostMsg_RequestAutocomplete::ID));
419 } 374 }
420 375
421 } // namespace autofill 376 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/autofill/chrome_autofill_client.cc ('k') | components/autofill/content/browser/content_autofill_driver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698