Hide password saving UI for automated tests.
BUG=chromedriver:1015 Review-Url: https://codereview.chromium.org/2722293004 Cr-Commit-Position: refs/heads/master@{#454935}
This commit is contained in:
chrome/browser/password_manager
@ -208,6 +208,12 @@ bool ChromePasswordManagerClient::IsPasswordManagementEnabledForCurrentPage()
|
||||
|
||||
bool ChromePasswordManagerClient::IsSavingAndFillingEnabledForCurrentPage()
|
||||
const {
|
||||
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
||||
switches::kEnableAutomation)) {
|
||||
// Disable the password saving UI for automated tests. It obscures the
|
||||
// page, and there is no API to access (or dismiss) UI bubbles/infobars.
|
||||
return false;
|
||||
}
|
||||
// TODO(melandory): remove saving_and_filling_passwords_enabled_ check from
|
||||
// here once we decide to switch to new settings behavior for everyone.
|
||||
return *saving_and_filling_passwords_enabled_ && !IsOffTheRecord() &&
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/macros.h"
|
||||
#include "base/metrics/field_trial.h"
|
||||
#include "base/run_loop.h"
|
||||
@ -17,6 +18,7 @@
|
||||
#include "chrome/browser/metrics/chrome_metrics_service_accessor.h"
|
||||
#include "chrome/browser/sync/profile_sync_service_factory.h"
|
||||
#include "chrome/browser/sync/profile_sync_test_util.h"
|
||||
#include "chrome/common/chrome_switches.h"
|
||||
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
|
||||
#include "chrome/test/base/testing_profile.h"
|
||||
#include "components/autofill/content/common/autofill_agent.mojom.h"
|
||||
@ -363,6 +365,15 @@ TEST_F(ChromePasswordManagerClientTest, SavingAndFillingEnabledConditionsTest) {
|
||||
profile()->ForceIncognito(false);
|
||||
}
|
||||
|
||||
TEST_F(ChromePasswordManagerClientTest, SavingDependsOnAutomation) {
|
||||
// Test that saving passwords UI is disabled for automated tests.
|
||||
ChromePasswordManagerClient* client = GetClient();
|
||||
EXPECT_TRUE(client->IsSavingAndFillingEnabledForCurrentPage());
|
||||
base::CommandLine::ForCurrentProcess()->AppendSwitch(
|
||||
switches::kEnableAutomation);
|
||||
EXPECT_FALSE(client->IsSavingAndFillingEnabledForCurrentPage());
|
||||
}
|
||||
|
||||
TEST_F(ChromePasswordManagerClientTest, GetLastCommittedEntryURL_Empty) {
|
||||
EXPECT_EQ(GURL::EmptyGURL(), GetClient()->GetLastCommittedEntryURL());
|
||||
}
|
||||
|
Reference in New Issue
Block a user