Commit db03c662 authored by Vasilii Sukhanov's avatar Vasilii Sukhanov Committed by Commit Bot

Don't process password forms for file: and blob: URLs.

Bug: 887914
Change-Id: I76658cd1d001653da0f32f2d955646f8cd365d64
Reviewed-on: https://chromium-review.googlesource.com/1256777Reviewed-by: default avatarVadym Doroshenko <dvadym@chromium.org>
Commit-Queue: Vasilii Sukhanov <vasilii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595876}
parent ccdc07b7
...@@ -3535,6 +3535,31 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, ...@@ -3535,6 +3535,31 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest,
EXPECT_FALSE(prompt_observer->IsSavePromptAvailable()); EXPECT_FALSE(prompt_observer->IsSavePromptAvailable());
} }
// Verify that there is no renderer kill when filling out a password on a
// blob: URL.
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest,
NoRendererKillWithBlobURLFrames) {
// Start from a page without a password form.
NavigateToFile("/password/other.html");
GURL submit_url(embedded_test_server()->GetURL("/password/done.html"));
std::string form_html = GeneratePasswordFormForAction(submit_url);
std::string navigate_to_blob_url =
"location.href = URL.createObjectURL(new Blob([\"" + form_html +
"\"], { type: 'text/html' }));";
NavigationObserver observer(WebContents());
ASSERT_TRUE(content::ExecuteScript(WebContents(), navigate_to_blob_url));
observer.Wait();
// Fill in the password and submit the form. This shouldn't bring up a save
// password prompt and shouldn't result in a renderer kill.
std::string fill_and_submit =
"document.getElementById('password_field').value = 'random';"
"document.getElementById('testform').submit();";
ASSERT_TRUE(content::ExecuteScript(WebContents(), fill_and_submit));
EXPECT_FALSE(BubbleObserver(WebContents()).IsSavePromptAvailable());
}
// Test that for HTTP auth (i.e., credentials not put through web forms) the // Test that for HTTP auth (i.e., credentials not put through web forms) the
// password manager works even though it should be disabled on the previous // password manager works even though it should be disabled on the previous
// page. // page.
......
...@@ -1074,7 +1074,9 @@ bool PasswordAutofillAgent::FrameCanAccessPasswordManager() { ...@@ -1074,7 +1074,9 @@ bool PasswordAutofillAgent::FrameCanAccessPasswordManager() {
// about:blank or about:srcdoc frames should not be allowed to use password // about:blank or about:srcdoc frames should not be allowed to use password
// manager. See https://crbug.com/756587. // manager. See https://crbug.com/756587.
WebLocalFrame* frame = render_frame()->GetWebFrame(); WebLocalFrame* frame = render_frame()->GetWebFrame();
if (frame->GetDocument().Url().ProtocolIs(url::kAboutScheme)) blink::WebURL url = frame->GetDocument().Url();
if (url.ProtocolIs(url::kAboutScheme) || url.ProtocolIs(url::kBlobScheme) ||
url.ProtocolIs(url::kFileScheme))
return false; return false;
return frame->GetSecurityOrigin().CanAccessPasswordManager(); return frame->GetSecurityOrigin().CanAccessPasswordManager();
} }
......
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