diff options
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/sessions/better_session_restore_browsertest.cc | 50 | ||||
-rw-r--r-- | chrome/test/data/session_restore/post_with_password.html | 21 |
2 files changed, 57 insertions, 14 deletions
diff --git a/chrome/browser/sessions/better_session_restore_browsertest.cc b/chrome/browser/sessions/better_session_restore_browsertest.cc index 8f28775..0d176cb 100644 --- a/chrome/browser/sessions/better_session_restore_browsertest.cc +++ b/chrome/browser/sessions/better_session_restore_browsertest.cc @@ -86,6 +86,7 @@ class BetterSessionRestoreTest : public InProcessBrowserTest { test_files.push_back("cookies.html"); test_files.push_back("local_storage.html"); test_files.push_back("post.html"); + test_files.push_back("post_with_password.html"); test_files.push_back("session_cookies.html"); test_files.push_back("session_storage.html"); FilePath test_file_dir; @@ -240,13 +241,6 @@ IN_PROC_BROWSER_TEST_F(ContinueWhereILeftOffTest, PRE_Post) { browser(), GURL(fake_server_address_ + test_path_ + "post.html")); string16 final_title = title_watcher.WaitAndGetTitle(); EXPECT_EQ(title_pass_, final_title); - if (g_last_upload_bytes.Get().find("posted-text") == std::string::npos || - g_last_upload_bytes.Get().find("text-entered") == std::string::npos) { - // For debugging why this test fails. - LOG(ERROR) << "Got uploaded bytes:"; - LOG(ERROR) << g_last_upload_bytes.Get(); - LOG(ERROR) << "Going to fail the test."; - } EXPECT_TRUE(g_last_upload_bytes.Get().find("posted-text") != std::string::npos); EXPECT_TRUE(g_last_upload_bytes.Get().find("text-entered") != @@ -255,15 +249,43 @@ IN_PROC_BROWSER_TEST_F(ContinueWhereILeftOffTest, PRE_Post) { IN_PROC_BROWSER_TEST_F(ContinueWhereILeftOffTest, Post) { CheckReloadedPageRestored(); - if (g_last_upload_bytes.Get().find("posted-text") == std::string::npos || - g_last_upload_bytes.Get().find("text-entered") == std::string::npos) { - // For debugging why this test fails. - LOG(ERROR) << "Got uploaded bytes:"; - LOG(ERROR) << g_last_upload_bytes.Get(); - LOG(ERROR) << "Going to fail the test."; - } EXPECT_TRUE(g_last_upload_bytes.Get().find("posted-text") != std::string::npos); EXPECT_TRUE(g_last_upload_bytes.Get().find("text-entered") != std::string::npos); } + +IN_PROC_BROWSER_TEST_F(ContinueWhereILeftOffTest, PRE_PostWithPassword) { + SessionStartupPref::SetStartupPref( + browser()->profile(), SessionStartupPref(SessionStartupPref::LAST)); + content::WebContents* web_contents = + chrome::GetActiveWebContents(browser()); + content::TitleWatcher title_watcher(web_contents, title_pass_); + ui_test_utils::NavigateToURL( + browser(), + GURL(fake_server_address_ + test_path_ + + "post_with_password.html")); + string16 final_title = title_watcher.WaitAndGetTitle(); + EXPECT_EQ(title_pass_, final_title); + EXPECT_TRUE(g_last_upload_bytes.Get().find("posted-text") != + std::string::npos); + EXPECT_TRUE(g_last_upload_bytes.Get().find("text-entered") != + std::string::npos); + EXPECT_TRUE(g_last_upload_bytes.Get().find("posted-password") != + std::string::npos); + EXPECT_TRUE(g_last_upload_bytes.Get().find("password-entered") != + std::string::npos); +} + +IN_PROC_BROWSER_TEST_F(ContinueWhereILeftOffTest, PostWithPassword) { + CheckReloadedPageRestored(); + // The form data contained passwords, so it's removed completely. + EXPECT_TRUE(g_last_upload_bytes.Get().find("posted-text") == + std::string::npos); + EXPECT_TRUE(g_last_upload_bytes.Get().find("text-entered") == + std::string::npos); + EXPECT_TRUE(g_last_upload_bytes.Get().find("posted-password") == + std::string::npos); + EXPECT_TRUE(g_last_upload_bytes.Get().find("password-entered") == + std::string::npos); +} diff --git a/chrome/test/data/session_restore/post_with_password.html b/chrome/test/data/session_restore/post_with_password.html new file mode 100644 index 0000000..3f4a446 --- /dev/null +++ b/chrome/test/data/session_restore/post_with_password.html @@ -0,0 +1,21 @@ +<!DOCTYPE html> +<html> +<head> +<script> +function onLoad() { + document.getElementById('posted-text').value = 'text-entered'; + document.getElementById('posted-password').value = 'password-entered'; + document.getElementById('form-to-submit').submit(); +} +</script> +</head> +<body onload="setTimeout(onLoad, 0);"> +<form id="form-to-submit" action="posted.php" method="post" + enctype="multipart/form-data"> +Text to input: <input id="posted-text" type="text" name="posted-text"/><br> +Password to input: +<input id="posted-password" type="password" name="posted-password"/><br> +<input type="submit" value="Submit" /> +</form> +</body> +</html> |