Commit 72d8a481 authored by Nektarios Paisios's avatar Nektarios Paisios Committed by Commit Bot

Revert "Fix wrong password saving when loging to facebook."

This reverts commit ccaa8bf9.

Reason for revert: Possibly broke PasswordManagerBrowserTestBase.PasswordOverridenUpdateBubbleShown in browser_tests 

Original change's description:
> Fix wrong password saving when loging to facebook.
> 
> Facebook.com may perform |SameDocumentNavigation| on login form submit.
> User password will be saved even if it is wrong.
> 
> The changeset disables trigger on action changes.
> 
> Change-Id: I4103661fb9649280862229248f329da23dcc8912
> Bug: 808917
> Reviewed-on: https://chromium-review.googlesource.com/897638
> Reviewed-by: Jochen Eisinger <jochen@chromium.org>
> Reviewed-by: Dominic Battré <battre@chromium.org>
> Commit-Queue: Иван Афанасьев <ivafanas@yandex-team.ru>
> Cr-Commit-Position: refs/heads/master@{#539110}

TBR=battre@chromium.org,vasilii@chromium.org,dvadym@chromium.org,jochen@chromium.org,ivafanas@yandex-team.ru

Change-Id: I097c2922ee9172e7b5cd6f6a291582c28c66c1f7
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 808917
Reviewed-on: https://chromium-review.googlesource.com/937761Reviewed-by: default avatarNektarios Paisios <nektar@chromium.org>
Commit-Queue: Nektarios Paisios <nektar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#539159}
parent 52b69b43
......@@ -492,27 +492,6 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
NoPromptForActionMutation) {
NavigateToFile("/password/password_form_action_mutation.html");
// Need to pay attention for a message that XHR has finished since there
// is no navigation to wait for.
content::DOMMessageQueue message_queue;
BubbleObserver prompt_observer(WebContents());
std::string fill_and_submit =
"document.getElementById('username_action_mutation').value = 'temp';"
"document.getElementById('password_action_mutation').value = 'random';"
"document.getElementById('submit_action_mutation').click()";
ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
std::string message;
while (message_queue.WaitForMessage(&message)) {
if (message == "\"XHR_FINISHED\"")
break;
}
EXPECT_FALSE(prompt_observer.IsSavePromptShownAutomatically());
}
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
NoPromptForFormWithEnteredUsername) {
// Log in, see a form on the landing page. That form is not related to the
......
<!doctype html>
<html>
<head>
<base href="done">
<script>
function state_changed(xhr) {
if (xhr.readyState == 4) {
// Make form action mutation delayed so as that AjaxSucceeded handler
// can be run first. AjaxSucceded handler should start observing form
// mutations by form tracker.
setTimeout(function() {
document.getElementById('form_with_action_mutation').setAttribute('action', 'done.html');
// Event on XHR finish should be sent a bit later to make browser react
// on form action mutation.
setTimeout(function() {
window.domAutomationController.send("XHR_FINISHED");
}, 0)
}, 0);
}
}
function send_xhr() {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() { state_changed(xhr); };
xhr.open("GET", "password_form_action_mutation.html", true);
xhr.send(null);
}
</script>
</head>
<body>
<form method="POST" action="dummy" id="form_with_action_mutation"
onsubmit="send_xhr(); return false;">
<input type="text" id="username_action_mutation" name="username_action_mutation">
<input type="password" id="password_action_mutation" name="password_action_mutation">
<input type="submit" id="submit_action_mutation" name="submit_action_mutation">
</form>
</body>
</html>
......@@ -47,7 +47,7 @@ WebFormElementObserverImpl::ObserverCallback::ObserverCallback(
{
MutationObserverInit init;
init.setAttributes(true);
init.setAttributeFilter({"class", "style"});
init.setAttributeFilter({"action", "class", "style"});
mutation_observer_->observe(element_, init, ASSERT_NO_EXCEPTION);
}
for (Node* node = element_; node->parentElement();
......@@ -83,8 +83,16 @@ void WebFormElementObserverImpl::ObserverCallback::Deliver(
return;
}
} else {
// Either "style" or "class" was modified. Check the computed style.
HTMLElement& element = *ToHTMLElement(record->target());
if (record->attributeName() == "action") {
// If the action was modified, we just assume that the form as
// submitted.
callback_->ElementWasHiddenOrRemoved();
Disconnect();
return;
}
// Otherwise, either "style" or "class" was modified. Check the
// computed style.
CSSComputedStyleDeclaration* style =
CSSComputedStyleDeclaration::Create(&element);
if (style->GetPropertyValue(CSSPropertyDisplay) == "none") {
......
......@@ -11,8 +11,8 @@ class WebFormElementObserverCallback {
public:
virtual ~WebFormElementObserverCallback() = default;
// Invoked when the observed element was either removed from the DOM or it's
// computed style changed to display: none.
// Invoked when the observed element was either removed from the DOM, it's
// action attribute changed, or it's computed style changed to display: none.
virtual void ElementWasHiddenOrRemoved() = 0;
};
......
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