OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 IN_PROC_BROWSER_TEST_F(PPAPIFileChooserTest, | 302 IN_PROC_BROWSER_TEST_F(PPAPIFileChooserTest, |
303 FileChooser_SaveAs_DangerousExecutable_Disallowed) { | 303 FileChooser_SaveAs_DangerousExecutable_Disallowed) { |
304 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 304 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
305 switches::kDisallowUncheckedDangerousDownloads); | 305 switches::kDisallowUncheckedDangerousDownloads); |
306 TestSelectFileDialogFactory test_dialog_factory( | 306 TestSelectFileDialogFactory test_dialog_factory( |
307 TestSelectFileDialogFactory::NOT_REACHED, | 307 TestSelectFileDialogFactory::NOT_REACHED, |
308 TestSelectFileDialogFactory::SelectedFileInfoList()); | 308 TestSelectFileDialogFactory::SelectedFileInfoList()); |
309 RunTestViaHTTP("FileChooser_SaveAsDangerousExecutableDisallowed"); | 309 RunTestViaHTTP("FileChooser_SaveAsDangerousExecutableDisallowed"); |
310 } | 310 } |
311 | 311 |
| 312 IN_PROC_BROWSER_TEST_F(PPAPIFileChooserTest, |
| 313 FileChooser_SaveAs_DangerousExtensionList_Disallowed) { |
| 314 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 315 switches::kDisallowUncheckedDangerousDownloads); |
| 316 TestSelectFileDialogFactory test_dialog_factory( |
| 317 TestSelectFileDialogFactory::NOT_REACHED, |
| 318 TestSelectFileDialogFactory::SelectedFileInfoList()); |
| 319 RunTestViaHTTP("FileChooser_SaveAsDangerousExtensionListDisallowed"); |
| 320 } |
| 321 |
312 // The kDisallowUncheckedDangerousDownloads switch (whose behavior is verified | 322 // The kDisallowUncheckedDangerousDownloads switch (whose behavior is verified |
313 // by the FileChooser_SaveAs_DangerousExecutable_Disallowed test above) should | 323 // by the FileChooser_SaveAs_DangerousExecutable_Disallowed test above) should |
314 // block the file being downloaded. However, the FakeDatabaseManager reports | 324 // block the file being downloaded. However, the FakeDatabaseManager reports |
315 // that the requestors document URL matches the Safe Browsing whitelist. Hence | 325 // that the requestors document URL matches the Safe Browsing whitelist. Hence |
316 // the download succeeds. | 326 // the download succeeds. |
317 IN_PROC_BROWSER_TEST_F(PPAPIFileChooserTestWithSBService, | 327 IN_PROC_BROWSER_TEST_F(PPAPIFileChooserTestWithSBService, |
318 FileChooser_SaveAs_DangerousExecutable_Whitelist) { | 328 FileChooser_SaveAs_DangerousExecutable_Whitelist) { |
319 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 329 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
320 switches::kDisallowUncheckedDangerousDownloads); | 330 switches::kDisallowUncheckedDangerousDownloads); |
321 base::ScopedTempDir temp_dir; | 331 base::ScopedTempDir temp_dir; |
322 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 332 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
323 base::FilePath suggested_filename = temp_dir.path().AppendASCII("foo"); | 333 base::FilePath suggested_filename = temp_dir.path().AppendASCII("foo"); |
324 | 334 |
325 TestSelectFileDialogFactory::SelectedFileInfoList file_info_list; | 335 TestSelectFileDialogFactory::SelectedFileInfoList file_info_list; |
326 file_info_list.push_back( | 336 file_info_list.push_back( |
327 ui::SelectedFileInfo(suggested_filename, suggested_filename)); | 337 ui::SelectedFileInfo(suggested_filename, suggested_filename)); |
328 TestSelectFileDialogFactory test_dialog_factory( | 338 TestSelectFileDialogFactory test_dialog_factory( |
329 TestSelectFileDialogFactory::REPLACE_BASENAME, file_info_list); | 339 TestSelectFileDialogFactory::REPLACE_BASENAME, file_info_list); |
330 | 340 |
331 RunTestViaHTTP("FileChooser_SaveAsDangerousExecutableAllowed"); | 341 RunTestViaHTTP("FileChooser_SaveAsDangerousExecutableAllowed"); |
332 base::FilePath actual_filename = temp_dir.path().AppendASCII("dangerous.exe"); | 342 base::FilePath actual_filename = temp_dir.path().AppendASCII("dangerous.exe"); |
333 | 343 |
334 ASSERT_TRUE(base::PathExists(actual_filename)); | 344 ASSERT_TRUE(base::PathExists(actual_filename)); |
335 std::string file_contents; | 345 std::string file_contents; |
336 ASSERT_TRUE(base::ReadFileToString(actual_filename, &file_contents, 100)); | 346 ASSERT_TRUE(base::ReadFileToString(actual_filename, &file_contents, 100)); |
337 EXPECT_EQ("Hello from PPAPI", file_contents); | 347 EXPECT_EQ("Hello from PPAPI", file_contents); |
338 } | 348 } |
339 | 349 |
340 #endif // FULL_SAFE_BROWSING | 350 #endif // FULL_SAFE_BROWSING |
OLD | NEW |