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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 loop_runner->Run(); | 755 loop_runner->Run(); |
756 base::FilePath download_dir = DownloadPrefs::FromDownloadManager( | 756 base::FilePath download_dir = DownloadPrefs::FromDownloadManager( |
757 GetDownloadManager())->DownloadPath(); | 757 GetDownloadManager())->DownloadPath(); |
758 base::FilePath filename = download_dir.AppendASCII("dataurl.txt"); | 758 base::FilePath filename = download_dir.AppendASCII("dataurl.txt"); |
759 ASSERT_TRUE(base::PathExists(filename)); | 759 ASSERT_TRUE(base::PathExists(filename)); |
760 std::string contents; | 760 std::string contents; |
761 EXPECT_TRUE(base::ReadFileToString(filename, &contents)); | 761 EXPECT_TRUE(base::ReadFileToString(filename, &contents)); |
762 EXPECT_EQ("foo", contents); | 762 EXPECT_EQ("foo", contents); |
763 } | 763 } |
764 | 764 |
| 765 // If a save-page-complete operation results in creating subresources that would |
| 766 // otherwise be considered dangerous, such files should get a .download |
| 767 // extension appended so that they won't be accidentally executed by the user. |
| 768 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, DangerousSubresources) { |
| 769 GURL url = |
| 770 URLRequestMockHTTPJob::GetMockUrl("/save_page/dubious-subresources.html"); |
| 771 |
| 772 ui_test_utils::NavigateToURL(browser(), url); |
| 773 base::FilePath full_file_name, dir; |
| 774 SaveCurrentTab(url, content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, |
| 775 "dubious-subresources", 2, &dir, &full_file_name); |
| 776 ASSERT_FALSE(HasFailure()); |
| 777 |
| 778 EXPECT_TRUE(base::PathExists(full_file_name)); |
| 779 EXPECT_TRUE(base::PathExists(dir.AppendASCII("not-a-crx.crx.download"))); |
| 780 } |
| 781 |
765 // Test that we don't crash when the page contains an iframe that | 782 // Test that we don't crash when the page contains an iframe that |
766 // was handled as a download (http://crbug.com/42212). | 783 // was handled as a download (http://crbug.com/42212). |
767 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, SaveDownloadableIFrame) { | 784 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, SaveDownloadableIFrame) { |
768 GURL url = URLRequestMockHTTPJob::GetMockUrl( | 785 GURL url = URLRequestMockHTTPJob::GetMockUrl( |
769 "downloads/iframe-src-is-a-download.htm"); | 786 "downloads/iframe-src-is-a-download.htm"); |
770 | 787 |
771 // Wait for and then dismiss the non-save-page-as-related download item | 788 // Wait for and then dismiss the non-save-page-as-related download item |
772 // (the one associated with downloading of "thisdayinhistory.xls" file). | 789 // (the one associated with downloading of "thisdayinhistory.xls" file). |
773 { | 790 { |
774 GURL download_url("http://mock.http/downloads/thisdayinhistory.xls"); | 791 GURL download_url("http://mock.http/downloads/thisdayinhistory.xls"); |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1238 TestOriginalVsSavedPage(save_page_type, url, 1, expected_substrings); | 1255 TestOriginalVsSavedPage(save_page_type, url, 1, expected_substrings); |
1239 } | 1256 } |
1240 | 1257 |
1241 INSTANTIATE_TEST_CASE_P( | 1258 INSTANTIATE_TEST_CASE_P( |
1242 SaveType, | 1259 SaveType, |
1243 SavePageOriginalVsSavedComparisonTest, | 1260 SavePageOriginalVsSavedComparisonTest, |
1244 ::testing::Values(content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, | 1261 ::testing::Values(content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, |
1245 content::SAVE_PAGE_TYPE_AS_MHTML)); | 1262 content::SAVE_PAGE_TYPE_AS_MHTML)); |
1246 | 1263 |
1247 } // namespace | 1264 } // namespace |
OLD | NEW |