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

Side by Side Diff: components/autofill/content/browser/content_autofill_driver_unittest.cc

Issue 2422363002: Trigger HTTP-bad warning when querying credit card autofill (Closed)
Patch Set: add missing blank line Created 4 years, 2 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/autofill/content/browser/content_autofill_driver.h" 5 #include "components/autofill/content/browser/content_autofill_driver.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
11 #include <utility> 11 #include <utility>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/run_loop.h" 15 #include "base/run_loop.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "components/autofill/core/browser/autofill_external_delegate.h" 17 #include "components/autofill/core/browser/autofill_external_delegate.h"
18 #include "components/autofill/core/browser/autofill_manager.h" 18 #include "components/autofill/core/browser/autofill_manager.h"
19 #include "components/autofill/core/browser/autofill_test_utils.h" 19 #include "components/autofill/core/browser/autofill_test_utils.h"
20 #include "components/autofill/core/browser/test_autofill_client.h" 20 #include "components/autofill/core/browser/test_autofill_client.h"
21 #include "components/autofill/core/common/autofill_switches.h" 21 #include "components/autofill/core/common/autofill_switches.h"
22 #include "components/autofill/core/common/form_data_predictions.h" 22 #include "components/autofill/core/common/form_data_predictions.h"
23 #include "content/public/browser/browser_context.h" 23 #include "content/public/browser/browser_context.h"
24 #include "content/public/browser/navigation_details.h" 24 #include "content/public/browser/navigation_details.h"
25 #include "content/public/browser/navigation_entry.h"
26 #include "content/public/browser/ssl_status.h"
25 #include "content/public/browser/storage_partition.h" 27 #include "content/public/browser/storage_partition.h"
26 #include "content/public/browser/web_contents.h" 28 #include "content/public/browser/web_contents.h"
27 #include "content/public/common/frame_navigate_params.h" 29 #include "content/public/common/frame_navigate_params.h"
28 #include "content/public/test/test_renderer_host.h" 30 #include "content/public/test/test_renderer_host.h"
29 #include "mojo/public/cpp/bindings/binding_set.h" 31 #include "mojo/public/cpp/bindings/binding_set.h"
30 #include "services/service_manager/public/cpp/interface_provider.h" 32 #include "services/service_manager/public/cpp/interface_provider.h"
31 #include "testing/gmock/include/gmock/gmock.h" 33 #include "testing/gmock/include/gmock/gmock.h"
32 #include "testing/gtest/include/gtest/gtest.h" 34 #include "testing/gtest/include/gtest/gtest.h"
33 35
34 namespace autofill { 36 namespace autofill {
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 442
441 base::RunLoop run_loop; 443 base::RunLoop run_loop;
442 fake_agent_.SetQuitLoopClosure(run_loop.QuitClosure()); 444 fake_agent_.SetQuitLoopClosure(run_loop.QuitClosure());
443 driver_->RendererShouldPreviewFieldWithValue(input_value); 445 driver_->RendererShouldPreviewFieldWithValue(input_value);
444 run_loop.RunUntilIdle(); 446 run_loop.RunUntilIdle();
445 447
446 EXPECT_TRUE(fake_agent_.GetString16PreviewFieldWithValue(&output_value)); 448 EXPECT_TRUE(fake_agent_.GetString16PreviewFieldWithValue(&output_value));
447 EXPECT_EQ(input_value, output_value); 449 EXPECT_EQ(input_value, output_value);
448 } 450 }
449 451
452 // Tests that credit card form interactions are recorded on the current
453 // NavigationEntry's SSLStatus if the page is HTTP.
454 TEST_F(ContentAutofillDriverTest, CreditCardFormInteraction) {
455 GURL url("http://example.test");
456 NavigateAndCommit(url);
457 driver_->DidInteractWithCreditCardForm();
458
459 content::NavigationEntry* entry =
460 web_contents()->GetController().GetVisibleEntry();
461 ASSERT_TRUE(entry);
462 EXPECT_EQ(url, entry->GetURL());
463 EXPECT_TRUE(!!(entry->GetSSL().content_status &
464 content::SSLStatus::DISPLAYED_CREDIT_CARD_FIELD_ON_HTTP));
465 }
466
467 // Tests that credit card form interactions are *not* recorded on the current
468 // NavigationEntry's SSLStatus if the page is *not* HTTP.
469 TEST_F(ContentAutofillDriverTest, CreditCardFormInteractionOnHTTPS) {
470 GURL url("https://example.test");
471 NavigateAndCommit(url);
472 driver_->DidInteractWithCreditCardForm();
473
474 content::NavigationEntry* entry =
475 web_contents()->GetController().GetVisibleEntry();
476 ASSERT_TRUE(entry);
477 EXPECT_EQ(url, entry->GetURL());
478 EXPECT_FALSE(!!(entry->GetSSL().content_status &
479 content::SSLStatus::DISPLAYED_CREDIT_CARD_FIELD_ON_HTTP));
480 }
481
450 } // namespace autofill 482 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/content/browser/content_autofill_driver.cc ('k') | components/autofill/core/browser/autofill_driver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698