Commit 7db5401b authored by gcasto's avatar gcasto Committed by Commit bot

[Password Generation] Fix bug where generation would never trigger on iframes

This also fixes a long standing flake in PasswordGenerationInteractiveTest
and adds a new test.

BUG=477147

Review URL: https://codereview.chromium.org/1084063002

Cr-Commit-Position: refs/heads/master@{#326655}
parent 38d002a2
......@@ -132,25 +132,9 @@ class PasswordGenerationInteractiveTest : public InProcessBrowserTest {
TestPopupObserver observer_;
};
#if defined(USE_AURA)
// Enabled on these platforms.
// Disabled due to flakiness, see http://crbug.com/407998
#define MAYBE_PopupShownAndPasswordSelected \
DISABLED_PopupShownAndPasswordSelected
#define MAYBE_PopupShownAndDismissed DISABLED_PopupShownAndDismissed
#define MAYBE_PopupShownAndDismissedByScrolling \
DISABLED_PopupShownAndDismissedByScrolling
#else
// Popup not enabled for these platforms yet.
#define MAYBE_PopupShownAndPasswordSelected \
DISABLED_PopupShownAndPasswordSelected
#define MAYBE_PopupShownAndDismissed DISABLED_PopupShownAndDismissed
#define MAYBE_PopupShownAndDismissedByScrolling \
DISABLED_PopupShownAndDismissedByScrolling
#endif
// Disabled due to flakiness due to resizes, see http://crbug.com/407998.
IN_PROC_BROWSER_TEST_F(PasswordGenerationInteractiveTest,
MAYBE_PopupShownAndPasswordSelected) {
DISABLED_PopupShownAndPasswordSelected) {
FocusPasswordField();
EXPECT_TRUE(GenerationPopupShowing());
SendKeyToPopup(ui::VKEY_DOWN);
......@@ -168,8 +152,9 @@ IN_PROC_BROWSER_TEST_F(PasswordGenerationInteractiveTest,
EXPECT_TRUE(EditingPopupShowing());
}
// Disabled due to flakiness due to resizes, see http://crbug.com/407998.
IN_PROC_BROWSER_TEST_F(PasswordGenerationInteractiveTest,
MAYBE_PopupShownAndDismissed) {
DISABLED_PopupShownAndDismissed) {
FocusPasswordField();
EXPECT_TRUE(GenerationPopupShowing());
......@@ -179,8 +164,9 @@ IN_PROC_BROWSER_TEST_F(PasswordGenerationInteractiveTest,
EXPECT_FALSE(GenerationPopupShowing());
}
// Disabled due to flakiness due to resizes, see http://crbug.com/407998.
IN_PROC_BROWSER_TEST_F(PasswordGenerationInteractiveTest,
MAYBE_PopupShownAndDismissedByScrolling) {
DISABLED_PopupShownAndDismissedByScrolling) {
FocusPasswordField();
EXPECT_TRUE(GenerationPopupShowing());
......@@ -189,3 +175,19 @@ IN_PROC_BROWSER_TEST_F(PasswordGenerationInteractiveTest,
EXPECT_FALSE(GenerationPopupShowing());
}
// Disabled due to flakiness due to resizes, see http://crbug.com/407998.
IN_PROC_BROWSER_TEST_F(PasswordGenerationInteractiveTest,
DISABLED_GenerationTriggeredInIFrame) {
GURL url = embedded_test_server()->GetURL(
"/password/framed_signup_form.html");
ui_test_utils::NavigateToURL(browser(), url);
std::string focus_script =
"var frame = document.getElementById('signup_iframe');"
"var frame_doc = frame.contentDocument;"
"frame_doc.getElementById('password_field').focus();";
ASSERT_TRUE(content::ExecuteScript(GetRenderViewHost(), focus_script));
EXPECT_TRUE(GenerationPopupShowing());
}
<html>
<body>
<iframe src="signup_form.html" id="signup_iframe" name="signup_iframe">
</iframe>
</body>
</html>
......@@ -118,16 +118,16 @@ PasswordGenerationAgent::PasswordGenerationAgent(
PasswordGenerationAgent::~PasswordGenerationAgent() {}
void PasswordGenerationAgent::DidFinishDocumentLoad() {
if (render_frame()->GetWebFrame()->parent())
return;
// In every navigation, the IPC message sent by the password autofill manager
// to query whether the current form is blacklisted or not happens when the
// document load finishes, so we need to clear previous states here before we
// hear back from the browser. We only clear this state on main frame load
// as we don't want subframe loads to clear state that we have received from
// the main frame. Note that we assume there is only one account creation
// form, but there could be multiple password forms in each frame.
// Update stats for main frame navigation.
if (!render_frame()->GetWebFrame()->parent()) {
// In every navigation, the IPC message sent by the password autofill
// manager to query whether the current form is blacklisted or not happens
// when the document load finishes, so we need to clear previous states
// here before we hear back from the browser. We only clear this state on
// main frame load as we don't want subframe loads to clear state that we
// have received from the main frame. Note that we assume there is only one
// account creation form, but there could be multiple password forms in
// each frame.
not_blacklisted_password_form_origins_.clear();
generation_enabled_forms_.clear();
generation_element_.reset();
......@@ -161,6 +161,7 @@ void PasswordGenerationAgent::DidFinishDocumentLoad() {
password_generation::EDITING_POPUP_SHOWN);
}
editing_popup_shown_ = false;
}
FindPossibleGenerationForm();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment