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

Side by Side Diff: chrome/browser/prerender/prerender_browsertest.cc

Issue 2447143002: Stop prerendering of a site if it uses the Credential Manager API. (Closed)
Patch Set: rebase Created 4 years, 1 month 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 <stddef.h> 5 #include <stddef.h>
6 #include <deque> 6 #include <deque>
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <unordered_map> 9 #include <unordered_map>
10 #include <utility> 10 #include <utility>
(...skipping 22 matching lines...) Expand all
33 #include "chrome/browser/browsing_data/browsing_data_remover.h" 33 #include "chrome/browser/browsing_data/browsing_data_remover.h"
34 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" 34 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h"
35 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" 35 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h"
36 #include "chrome/browser/chrome_content_browser_client.h" 36 #include "chrome/browser/chrome_content_browser_client.h"
37 #include "chrome/browser/chrome_notification_types.h" 37 #include "chrome/browser/chrome_notification_types.h"
38 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 38 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
39 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h" 39 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h"
40 #include "chrome/browser/extensions/extension_apitest.h" 40 #include "chrome/browser/extensions/extension_apitest.h"
41 #include "chrome/browser/external_protocol/external_protocol_handler.h" 41 #include "chrome/browser/external_protocol/external_protocol_handler.h"
42 #include "chrome/browser/net/prediction_options.h" 42 #include "chrome/browser/net/prediction_options.h"
43 #include "chrome/browser/password_manager/password_store_factory.h"
43 #include "chrome/browser/predictors/autocomplete_action_predictor.h" 44 #include "chrome/browser/predictors/autocomplete_action_predictor.h"
44 #include "chrome/browser/predictors/autocomplete_action_predictor_factory.h" 45 #include "chrome/browser/predictors/autocomplete_action_predictor_factory.h"
45 #include "chrome/browser/prerender/prerender_contents.h" 46 #include "chrome/browser/prerender/prerender_contents.h"
46 #include "chrome/browser/prerender/prerender_field_trial.h" 47 #include "chrome/browser/prerender/prerender_field_trial.h"
47 #include "chrome/browser/prerender/prerender_handle.h" 48 #include "chrome/browser/prerender/prerender_handle.h"
48 #include "chrome/browser/prerender/prerender_link_manager.h" 49 #include "chrome/browser/prerender/prerender_link_manager.h"
49 #include "chrome/browser/prerender/prerender_link_manager_factory.h" 50 #include "chrome/browser/prerender/prerender_link_manager_factory.h"
50 #include "chrome/browser/prerender/prerender_manager.h" 51 #include "chrome/browser/prerender/prerender_manager.h"
51 #include "chrome/browser/prerender/prerender_manager_factory.h" 52 #include "chrome/browser/prerender/prerender_manager_factory.h"
52 #include "chrome/browser/prerender/prerender_test_utils.h" 53 #include "chrome/browser/prerender/prerender_test_utils.h"
(...skipping 12 matching lines...) Expand all
65 #include "chrome/common/chrome_features.h" 66 #include "chrome/common/chrome_features.h"
66 #include "chrome/common/chrome_paths.h" 67 #include "chrome/common/chrome_paths.h"
67 #include "chrome/common/chrome_switches.h" 68 #include "chrome/common/chrome_switches.h"
68 #include "chrome/test/base/ui_test_utils.h" 69 #include "chrome/test/base/ui_test_utils.h"
69 #include "components/content_settings/core/browser/host_content_settings_map.h" 70 #include "components/content_settings/core/browser/host_content_settings_map.h"
70 #include "components/favicon/content/content_favicon_driver.h" 71 #include "components/favicon/content/content_favicon_driver.h"
71 #include "components/favicon/core/favicon_driver_observer.h" 72 #include "components/favicon/core/favicon_driver_observer.h"
72 #include "components/omnibox/browser/omnibox_edit_model.h" 73 #include "components/omnibox/browser/omnibox_edit_model.h"
73 #include "components/omnibox/browser/omnibox_popup_model.h" 74 #include "components/omnibox/browser/omnibox_popup_model.h"
74 #include "components/omnibox/browser/omnibox_view.h" 75 #include "components/omnibox/browser/omnibox_view.h"
76 #include "components/password_manager/core/browser/password_bubble_experiment.h"
77 #include "components/password_manager/core/browser/password_manager_test_utils.h "
78 #include "components/password_manager/core/browser/test_password_store.h"
75 #include "components/safe_browsing_db/database_manager.h" 79 #include "components/safe_browsing_db/database_manager.h"
76 #include "components/safe_browsing_db/util.h" 80 #include "components/safe_browsing_db/util.h"
77 #include "components/variations/entropy_provider.h" 81 #include "components/variations/entropy_provider.h"
78 #include "components/variations/variations_associated_data.h" 82 #include "components/variations/variations_associated_data.h"
79 #include "content/public/browser/browser_message_filter.h" 83 #include "content/public/browser/browser_message_filter.h"
80 #include "content/public/browser/devtools_agent_host.h" 84 #include "content/public/browser/devtools_agent_host.h"
81 #include "content/public/browser/navigation_controller.h" 85 #include "content/public/browser/navigation_controller.h"
82 #include "content/public/browser/navigation_entry.h" 86 #include "content/public/browser/navigation_entry.h"
83 #include "content/public/browser/notification_service.h" 87 #include "content/public/browser/notification_service.h"
84 #include "content/public/browser/render_frame_host.h" 88 #include "content/public/browser/render_frame_host.h"
(...skipping 3097 matching lines...) Expand 10 before | Expand all | Expand 10 after
3182 // page that doesn't contain the POST body). 3186 // page that doesn't contain the POST body).
3183 std::string body; 3187 std::string body;
3184 EXPECT_TRUE(ExecuteScriptAndExtractString( 3188 EXPECT_TRUE(ExecuteScriptAndExtractString(
3185 web_contents, 3189 web_contents,
3186 "window.domAutomationController.send(" 3190 "window.domAutomationController.send("
3187 "document.getElementsByTagName('pre')[0].innerText);", 3191 "document.getElementsByTagName('pre')[0].innerText);",
3188 &body)); 3192 &body));
3189 EXPECT_EQ("text=value\n", body); 3193 EXPECT_EQ("text=value\n", body);
3190 } 3194 }
3191 3195
3196 // Prerenders a page that tries to automatically sign user in via the Credential
3197 // Manager API. The page should be killed.
3198 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, AutosigninInPrerenderer) {
3199 // Set up a credential in the password store.
3200 PasswordStoreFactory::GetInstance()->SetTestingFactory(
3201 current_browser()->profile(),
3202 password_manager::BuildPasswordStore<
3203 content::BrowserContext, password_manager::TestPasswordStore>);
3204 scoped_refptr<password_manager::TestPasswordStore> password_store =
3205 static_cast<password_manager::TestPasswordStore*>(
3206 PasswordStoreFactory::GetForProfile(
3207 current_browser()->profile(),
3208 ServiceAccessType::IMPLICIT_ACCESS).get());
3209 autofill::PasswordForm signin_form;
3210 signin_form.signon_realm = embedded_test_server()->base_url().spec();
3211 signin_form.password_value = base::ASCIIToUTF16("password");
3212 signin_form.username_value = base::ASCIIToUTF16("user");
3213 signin_form.origin = embedded_test_server()->base_url();
3214 signin_form.skip_zero_click = false;
3215 password_store->AddLogin(signin_form);
3216 // Enable 'auto signin' for the profile.
3217 password_bubble_experiment::RecordAutoSignInPromptFirstRunExperienceWasShown(
3218 browser()->profile()->GetPrefs());
3219
3220 // Intercept the successful landing page where a signed in user ends up.
3221 // It should never load as the API is suppressed.
3222 GURL done_url = embedded_test_server()->GetURL("/password/done.html");
3223 base::FilePath empty_file = ui_test_utils::GetTestFilePath(
3224 base::FilePath(), base::FilePath(FILE_PATH_LITERAL("empty.html")));
3225 RequestCounter done_counter;
3226 BrowserThread::PostTask(
3227 BrowserThread::IO, FROM_HERE,
3228 base::Bind(&CreateCountingInterceptorOnIO,
3229 done_url, empty_file, done_counter.AsWeakPtr()));
3230 PrerenderTestURL("/password/autosignin.html",
3231 FINAL_STATUS_CREDENTIAL_MANAGER_API, 0);
3232 EXPECT_EQ(0, done_counter.count());
3233 }
3234
3192 class PrerenderIncognitoBrowserTest : public PrerenderBrowserTest { 3235 class PrerenderIncognitoBrowserTest : public PrerenderBrowserTest {
3193 public: 3236 public:
3194 void SetUpOnMainThread() override { 3237 void SetUpOnMainThread() override {
3195 Profile* normal_profile = current_browser()->profile(); 3238 Profile* normal_profile = current_browser()->profile();
3196 set_browser(OpenURLOffTheRecord(normal_profile, GURL("about:blank"))); 3239 set_browser(OpenURLOffTheRecord(normal_profile, GURL("about:blank")));
3197 PrerenderBrowserTest::SetUpOnMainThread(); 3240 PrerenderBrowserTest::SetUpOnMainThread();
3198 } 3241 }
3199 }; 3242 };
3200 3243
3201 // Checks that prerendering works in incognito mode. 3244 // Checks that prerendering works in incognito mode.
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
3337 browser()->tab_strip_model()->GetActiveWebContents(); 3380 browser()->tab_strip_model()->GetActiveWebContents();
3338 bool display_test_result = false; 3381 bool display_test_result = false;
3339 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(web_contents, 3382 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(web_contents,
3340 "DidDisplayReallyPass()", 3383 "DidDisplayReallyPass()",
3341 &display_test_result)); 3384 &display_test_result));
3342 ASSERT_TRUE(display_test_result); 3385 ASSERT_TRUE(display_test_result);
3343 } 3386 }
3344 #endif // !defined(DISABLE_NACL) 3387 #endif // !defined(DISABLE_NACL)
3345 3388
3346 } // namespace prerender 3389 } // namespace prerender
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/chrome_password_manager_client.cc ('k') | chrome/browser/prerender/prerender_final_status.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698