Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Side by Side Diff: chrome/browser/download/download_browsertest.cc

Issue 2124373002: [PPAPI] Quarantine files that are writeable by a Pepper plugin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@consolidate-file-metadata
Patch Set: Address comments. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/test/test_file_util_win.cc ('k') | chrome/test/ppapi/ppapi_filechooser_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/browser/download/download_browsertest.h" 5 #include "chrome/browser/download/download_browsertest.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <sstream> 8 #include <sstream>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 #include "content/public/browser/download_url_parameters.h" 84 #include "content/public/browser/download_url_parameters.h"
85 #include "content/public/browser/notification_source.h" 85 #include "content/public/browser/notification_source.h"
86 #include "content/public/browser/render_frame_host.h" 86 #include "content/public/browser/render_frame_host.h"
87 #include "content/public/browser/render_view_host.h" 87 #include "content/public/browser/render_view_host.h"
88 #include "content/public/browser/render_widget_host.h" 88 #include "content/public/browser/render_widget_host.h"
89 #include "content/public/browser/resource_context.h" 89 #include "content/public/browser/resource_context.h"
90 #include "content/public/browser/web_contents.h" 90 #include "content/public/browser/web_contents.h"
91 #include "content/public/common/content_features.h" 91 #include "content/public/common/content_features.h"
92 #include "content/public/common/content_switches.h" 92 #include "content/public/common/content_switches.h"
93 #include "content/public/common/context_menu_params.h" 93 #include "content/public/common/context_menu_params.h"
94 #include "content/public/common/quarantine.h"
94 #include "content/public/test/browser_test_utils.h" 95 #include "content/public/test/browser_test_utils.h"
95 #include "content/public/test/download_test_observer.h" 96 #include "content/public/test/download_test_observer.h"
96 #include "content/public/test/test_file_error_injector.h" 97 #include "content/public/test/test_file_error_injector.h"
97 #include "content/public/test/test_navigation_observer.h" 98 #include "content/public/test/test_navigation_observer.h"
98 #include "extensions/browser/extension_dialog_auto_confirm.h" 99 #include "extensions/browser/extension_dialog_auto_confirm.h"
99 #include "extensions/browser/extension_system.h" 100 #include "extensions/browser/extension_system.h"
100 #include "extensions/common/feature_switch.h" 101 #include "extensions/common/feature_switch.h"
101 #include "net/base/filename_util.h" 102 #include "net/base/filename_util.h"
102 #include "net/test/embedded_test_server/embedded_test_server.h" 103 #include "net/test/embedded_test_server/embedded_test_server.h"
103 #include "net/test/embedded_test_server/http_request.h" 104 #include "net/test/embedded_test_server/http_request.h"
(...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 1170
1170 // Download the file and wait. We do not expect the Select File dialog. 1171 // Download the file and wait. We do not expect the Select File dialog.
1171 DownloadAndWait(browser(), url); 1172 DownloadAndWait(browser(), url);
1172 1173
1173 // Check state. 1174 // Check state.
1174 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 1175 EXPECT_EQ(1, browser()->tab_strip_model()->count());
1175 base::FilePath file(FILE_PATH_LITERAL("download-test1.lib")); 1176 base::FilePath file(FILE_PATH_LITERAL("download-test1.lib"));
1176 CheckDownload(browser(), file, file); 1177 CheckDownload(browser(), file, file);
1177 } 1178 }
1178 1179
1179 #if defined(OS_WIN) 1180 #if defined(OS_WIN) || defined(OS_LINUX)
1180 // Download a file and confirm that the zone identifier (on windows) 1181 // Download a file and confirm that the file is correctly quarantined.
1181 // is set to internet. 1182 //
1182 IN_PROC_BROWSER_TEST_F(DownloadTest, CheckInternetZone_DependsOnLocalConfig) { 1183 // TODO(asanka): We should enable the test on Mac as well, but currently
1184 // |browser_tests| aren't run from a process that has LSFileQuarantineEnabled
1185 // bit set.
1186 IN_PROC_BROWSER_TEST_F(DownloadTest, Quarantine_DependsOnLocalConfig) {
1183 GURL url(URLRequestMockHTTPJob::GetMockUrl(kDownloadTest1Path)); 1187 GURL url(URLRequestMockHTTPJob::GetMockUrl(kDownloadTest1Path));
1184 1188
1185 // Download the file and wait. We do not expect the Select File dialog. 1189 // Download the file and wait. We do not expect the Select File dialog.
1186 DownloadAndWait(browser(), url); 1190 DownloadAndWait(browser(), url);
1187 1191
1188 // Check state. Special file state must be checked before CheckDownload, 1192 // Check state. Special file state must be checked before CheckDownload,
1189 // as CheckDownload will delete the output file. 1193 // as CheckDownload will delete the output file.
1190 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 1194 EXPECT_EQ(1, browser()->tab_strip_model()->count());
1191 base::FilePath file(FILE_PATH_LITERAL("download-test1.lib")); 1195 base::FilePath file(FILE_PATH_LITERAL("download-test1.lib"));
1192 base::FilePath downloaded_file(DestinationFile(browser(), file)); 1196 base::FilePath downloaded_file(DestinationFile(browser(), file));
1193 if (base::VolumeSupportsADS(downloaded_file)) 1197 EXPECT_TRUE(content::IsFileQuarantined(downloaded_file, url, GURL()));
1194 EXPECT_TRUE(base::HasInternetZoneIdentifier(downloaded_file));
1195 CheckDownload(browser(), file, file); 1198 CheckDownload(browser(), file, file);
1196 } 1199 }
1200 #endif
1201
1202 #if defined(OS_WIN)
1203 // A couple of Windows specific tests to make sure we respect OS specific
1204 // restrictions on Mark-Of-The-Web can be applied. While Chrome doesn't directly
1205 // apply these policies, Chrome still needs to make sure the correct APIs are
1206 // invoked during the download process that result in the expected MOTW
1207 // behavior.
1197 1208
1198 // Downloading a file from the local host shouldn't cause the application of a 1209 // Downloading a file from the local host shouldn't cause the application of a
1199 // zone identifier. 1210 // zone identifier.
1200 IN_PROC_BROWSER_TEST_F(DownloadTest, CheckLocalhostZone_DependsOnLocalConfig) { 1211 IN_PROC_BROWSER_TEST_F(DownloadTest, CheckLocalhostZone_DependsOnLocalConfig) {
1201 embedded_test_server()->ServeFilesFromDirectory(GetTestDataDirectory()); 1212 embedded_test_server()->ServeFilesFromDirectory(GetTestDataDirectory());
1202 ASSERT_TRUE(embedded_test_server()->Start()); 1213 ASSERT_TRUE(embedded_test_server()->Start());
1203 1214
1204 // Assumes that localhost maps to 127.0.0.1. Otherwise the test will fail 1215 // Assumes that localhost maps to 127.0.0.1. Otherwise the test will fail
1205 // since EmbeddedTestServer is listening on that address. 1216 // since EmbeddedTestServer is listening on that address.
1206 GURL url = 1217 GURL url =
1207 embedded_test_server()->GetURL("localhost", "/downloads/a_zip_file.zip"); 1218 embedded_test_server()->GetURL("localhost", "/downloads/a_zip_file.zip");
1208 DownloadAndWait(browser(), url); 1219 DownloadAndWait(browser(), url);
1209 base::FilePath file(FILE_PATH_LITERAL("a_zip_file.zip")); 1220 base::FilePath file(FILE_PATH_LITERAL("a_zip_file.zip"));
1210 base::FilePath downloaded_file(DestinationFile(browser(), file)); 1221 base::FilePath downloaded_file(DestinationFile(browser(), file));
1211 EXPECT_FALSE(base::HasInternetZoneIdentifier(downloaded_file)); 1222 EXPECT_FALSE(content::IsFileQuarantined(downloaded_file, GURL(), GURL()));
1212 } 1223 }
1213 1224
1214 // Same as the test above, but uses a file:// URL to a local file. 1225 // Same as the test above, but uses a file:// URL to a local file.
1215 IN_PROC_BROWSER_TEST_F(DownloadTest, CheckLocalFileZone_DependsOnLocalConfig) { 1226 IN_PROC_BROWSER_TEST_F(DownloadTest, CheckLocalFileZone_DependsOnLocalConfig) {
1216 base::FilePath source_file = GetTestDataDirectory() 1227 base::FilePath source_file = GetTestDataDirectory()
1217 .AppendASCII("downloads") 1228 .AppendASCII("downloads")
1218 .AppendASCII("a_zip_file.zip"); 1229 .AppendASCII("a_zip_file.zip");
1219 1230
1220 GURL url = net::FilePathToFileURL(source_file); 1231 GURL url = net::FilePathToFileURL(source_file);
1221 DownloadAndWait(browser(), url); 1232 DownloadAndWait(browser(), url);
1222 base::FilePath file(FILE_PATH_LITERAL("a_zip_file.zip")); 1233 base::FilePath file(FILE_PATH_LITERAL("a_zip_file.zip"));
1223 base::FilePath downloaded_file(DestinationFile(browser(), file)); 1234 base::FilePath downloaded_file(DestinationFile(browser(), file));
1224 EXPECT_FALSE(base::HasInternetZoneIdentifier(downloaded_file)); 1235 EXPECT_FALSE(content::IsFileQuarantined(downloaded_file, GURL(), GURL()));
1225 } 1236 }
1226 #endif 1237 #endif
1227 1238
1228 // Put up a Select File dialog when the file is downloaded, due to 1239 // Put up a Select File dialog when the file is downloaded, due to
1229 // downloads preferences settings. 1240 // downloads preferences settings.
1230 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadMimeTypeSelect) { 1241 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadMimeTypeSelect) {
1231 // Re-enable prompting. 1242 // Re-enable prompting.
1232 browser()->profile()->GetPrefs()->SetBoolean( 1243 browser()->profile()->GetPrefs()->SetBoolean(
1233 prefs::kPromptForDownload, true); 1244 prefs::kPromptForDownload, true);
1234 GURL url(URLRequestMockHTTPJob::GetMockUrl(kDownloadTest1Path)); 1245 GURL url(URLRequestMockHTTPJob::GetMockUrl(kDownloadTest1Path));
(...skipping 2491 matching lines...) Expand 10 before | Expand all | Expand 10 after
3726 browser(), 1, 3737 browser(), 1,
3727 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY)); 3738 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY));
3728 ui_test_utils::NavigateToURL(browser(), extension_url); 3739 ui_test_utils::NavigateToURL(browser(), extension_url);
3729 3740
3730 observer->WaitForFinished(); 3741 observer->WaitForFinished();
3731 3742
3732 // Download shelf should close. 3743 // Download shelf should close.
3733 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); 3744 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible());
3734 } 3745 }
3735 #endif // defined(OS_CHROMEOS) 3746 #endif // defined(OS_CHROMEOS)
OLDNEW
« no previous file with comments | « base/test/test_file_util_win.cc ('k') | chrome/test/ppapi/ppapi_filechooser_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698