OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 loop_runner->Run(); | 769 loop_runner->Run(); |
770 base::FilePath download_dir = DownloadPrefs::FromDownloadManager( | 770 base::FilePath download_dir = DownloadPrefs::FromDownloadManager( |
771 GetDownloadManager())->DownloadPath(); | 771 GetDownloadManager())->DownloadPath(); |
772 base::FilePath filename = download_dir.AppendASCII("dataurl.txt"); | 772 base::FilePath filename = download_dir.AppendASCII("dataurl.txt"); |
773 ASSERT_TRUE(base::PathExists(filename)); | 773 ASSERT_TRUE(base::PathExists(filename)); |
774 std::string contents; | 774 std::string contents; |
775 EXPECT_TRUE(base::ReadFileToString(filename, &contents)); | 775 EXPECT_TRUE(base::ReadFileToString(filename, &contents)); |
776 EXPECT_EQ("foo", contents); | 776 EXPECT_EQ("foo", contents); |
777 } | 777 } |
778 | 778 |
| 779 // Test that we don't crash when the page contains an iframe that |
| 780 // was handled as a download (http://crbug.com/42212). |
| 781 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, SaveDownloadableIFrame) { |
| 782 GURL url = URLRequestMockHTTPJob::GetMockUrl( |
| 783 base::FilePath(FILE_PATH_LITERAL("downloads")) |
| 784 .AppendASCII("iframe-src-is-a-download.htm")); |
| 785 ui_test_utils::NavigateToURL(browser(), url); |
| 786 |
| 787 // Wait for and then dismiss the non-save-page-as-related download item |
| 788 // (the one associated with downloading of "thisdayinhistory.xls" file). |
| 789 VerifySavePackageExpectations(browser(), url); |
| 790 GetDownloadManager()->RemoveAllDownloads(); |
| 791 |
| 792 base::FilePath full_file_name, dir; |
| 793 SaveCurrentTab(url, content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, |
| 794 "iframe-src-is-a-download", 2, &dir, &full_file_name); |
| 795 ASSERT_FALSE(HasFailure()); |
| 796 |
| 797 EXPECT_TRUE(base::PathExists(full_file_name)); |
| 798 } |
| 799 |
779 class SavePageSitePerProcessBrowserTest : public SavePageBrowserTest { | 800 class SavePageSitePerProcessBrowserTest : public SavePageBrowserTest { |
780 public: | 801 public: |
781 SavePageSitePerProcessBrowserTest() {} | 802 SavePageSitePerProcessBrowserTest() {} |
782 | 803 |
783 protected: | 804 protected: |
784 void SetUpCommandLine(base::CommandLine* command_line) override { | 805 void SetUpCommandLine(base::CommandLine* command_line) override { |
785 SavePageBrowserTest::SetUpCommandLine(command_line); | 806 SavePageBrowserTest::SetUpCommandLine(command_line); |
786 | 807 |
787 // TODO(lukasza): Enable --site-per-process once crbug.com/526786 is fixed. | 808 // TODO(lukasza): Enable --site-per-process once crbug.com/526786 is fixed. |
788 // (currently, when the line below is uncommented out, the test crashes | 809 // (currently, when the line below is uncommented out, the test crashes |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 ASSERT_TRUE(base::ReadFileToString(full_file_name, &main_contents)); | 866 ASSERT_TRUE(base::ReadFileToString(full_file_name, &main_contents)); |
846 EXPECT_THAT(main_contents, | 867 EXPECT_THAT(main_contents, |
847 HasSubstr("<iframe src=\"./iframes_files/a.html\"></iframe>")); | 868 HasSubstr("<iframe src=\"./iframes_files/a.html\"></iframe>")); |
848 EXPECT_THAT(main_contents, | 869 EXPECT_THAT(main_contents, |
849 HasSubstr("<iframe src=\"./iframes_files/b.html\"></iframe>")); | 870 HasSubstr("<iframe src=\"./iframes_files/b.html\"></iframe>")); |
850 EXPECT_THAT(main_contents, | 871 EXPECT_THAT(main_contents, |
851 HasSubstr("<img src=\"./iframes_files/1.png\">")); | 872 HasSubstr("<img src=\"./iframes_files/1.png\">")); |
852 } | 873 } |
853 | 874 |
854 } // namespace | 875 } // namespace |
OLD | NEW |