OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/file_path.h" | 5 #include "base/file_path.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/scoped_temp_dir.h" | 9 #include "base/scoped_temp_dir.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
11 #include "base/string_util.h" | |
11 #include "base/test/test_file_util.h" | 12 #include "base/test/test_file_util.h" |
12 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
13 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/download/download_crx_util.h" | 15 #include "chrome/browser/download/download_crx_util.h" |
15 #include "chrome/browser/download/download_file_manager.h" | 16 #include "chrome/browser/download/download_file_manager.h" |
16 #include "chrome/browser/download/download_history.h" | 17 #include "chrome/browser/download/download_history.h" |
17 #include "chrome/browser/download/download_item.h" | 18 #include "chrome/browser/download/download_item.h" |
18 #include "chrome/browser/download/download_manager.h" | 19 #include "chrome/browser/download/download_manager.h" |
19 #include "chrome/browser/download/download_prefs.h" | 20 #include "chrome/browser/download/download_prefs.h" |
20 #include "chrome/browser/download/download_shelf.h" | 21 #include "chrome/browser/download/download_shelf.h" |
21 #include "chrome/browser/download/download_util.h" | 22 #include "chrome/browser/download/download_util.h" |
22 #include "chrome/browser/extensions/extension_install_ui.h" | 23 #include "chrome/browser/extensions/extension_install_ui.h" |
23 #include "chrome/browser/extensions/extension_service.h" | 24 #include "chrome/browser/extensions/extension_service.h" |
24 #include "chrome/browser/history/download_history_info.h" | 25 #include "chrome/browser/history/download_history_info.h" |
25 #include "chrome/browser/history/history.h" | 26 #include "chrome/browser/history/history.h" |
26 #include "chrome/browser/prefs/pref_service.h" | 27 #include "chrome/browser/prefs/pref_service.h" |
27 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
28 #include "chrome/browser/ui/browser.h" | 29 #include "chrome/browser/ui/browser.h" |
29 #include "chrome/browser/ui/browser_list.h" | 30 #include "chrome/browser/ui/browser_list.h" |
30 #include "chrome/browser/ui/browser_window.h" | 31 #include "chrome/browser/ui/browser_window.h" |
31 #include "chrome/browser/ui/webui/active_downloads_ui.h" | 32 #include "chrome/browser/ui/webui/active_downloads_ui.h" |
32 #include "chrome/common/chrome_notification_types.h" | 33 #include "chrome/common/chrome_notification_types.h" |
33 #include "chrome/common/chrome_paths.h" | 34 #include "chrome/common/chrome_paths.h" |
34 #include "chrome/common/pref_names.h" | 35 #include "chrome/common/pref_names.h" |
36 #include "chrome/common/random.h" | |
35 #include "chrome/common/url_constants.h" | 37 #include "chrome/common/url_constants.h" |
36 #include "chrome/test/base/in_process_browser_test.h" | 38 #include "chrome/test/base/in_process_browser_test.h" |
37 #include "chrome/test/base/ui_test_utils.h" | 39 #include "chrome/test/base/ui_test_utils.h" |
38 #include "content/browser/cancelable_request.h" | 40 #include "content/browser/cancelable_request.h" |
39 #include "content/browser/net/url_request_mock_http_job.h" | 41 #include "content/browser/net/url_request_mock_http_job.h" |
40 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 42 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
41 #include "content/browser/tab_contents/tab_contents.h" | 43 #include "content/browser/tab_contents/tab_contents.h" |
42 #include "content/browser/net/url_request_slow_download_job.h" | 44 #include "content/browser/net/url_request_slow_download_job.h" |
43 #include "content/common/page_transition_types.h" | 45 #include "content/common/page_transition_types.h" |
44 #include "net/base/net_util.h" | 46 #include "net/base/net_util.h" |
47 #include "net/url_request/url_request_filter.h" | |
45 #include "testing/gtest/include/gtest/gtest.h" | 48 #include "testing/gtest/include/gtest/gtest.h" |
46 | 49 |
47 namespace { | 50 namespace { |
48 | 51 |
49 // IDs and paths of CRX files used in tests. | 52 // IDs and paths of CRX files used in tests. |
50 const char kGoodCrxId[] = "ldnnhddmnhbkjipkidpdiheffobcpfmf"; | 53 const char kGoodCrxId[] = "ldnnhddmnhbkjipkidpdiheffobcpfmf"; |
51 const FilePath kGoodCrxPath(FILE_PATH_LITERAL("extensions/good.crx")); | 54 const FilePath kGoodCrxPath(FILE_PATH_LITERAL("extensions/good.crx")); |
52 | 55 |
53 const char kLargeThemeCrxId[] = "pjpgmfcmabopnnfonnhmdjglfpjjfkbf"; | 56 const char kLargeThemeCrxId[] = "pjpgmfcmabopnnfonnhmdjglfpjjfkbf"; |
54 const FilePath kLargeThemePath(FILE_PATH_LITERAL("extensions/theme2.crx")); | 57 const FilePath kLargeThemePath(FILE_PATH_LITERAL("extensions/theme2.crx")); |
55 | 58 |
59 // The test file used in SavePageBrowserTest.SaveFolder3. | |
60 static const FilePath kTestFile(FILE_PATH_LITERAL("download-test1.lib")); | |
61 | |
56 // Action a test should take if a dangerous download is encountered. | 62 // Action a test should take if a dangerous download is encountered. |
57 enum DangerousDownloadAction { | 63 enum DangerousDownloadAction { |
58 ON_DANGEROUS_DOWNLOAD_ACCEPT, // Accept the download | 64 ON_DANGEROUS_DOWNLOAD_ACCEPT, // Accept the download |
59 ON_DANGEROUS_DOWNLOAD_DENY, // Deny the download | 65 ON_DANGEROUS_DOWNLOAD_DENY, // Deny the download |
60 ON_DANGEROUS_DOWNLOAD_FAIL // Fail if a dangerous download is seen | 66 ON_DANGEROUS_DOWNLOAD_FAIL // Fail if a dangerous download is seen |
61 }; | 67 }; |
62 | 68 |
63 // Fake user click on "Accept". | 69 // Fake user click on "Accept". |
64 void AcceptDangerousDownload(scoped_refptr<DownloadManager> download_manager, | 70 void AcceptDangerousDownload(scoped_refptr<DownloadManager> download_manager, |
65 int32 download_id) { | 71 int32 download_id) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 ~DownloadsObserver() { | 127 ~DownloadsObserver() { |
122 std::set<DownloadItem*>::iterator it = downloads_observed_.begin(); | 128 std::set<DownloadItem*>::iterator it = downloads_observed_.begin(); |
123 for (; it != downloads_observed_.end(); ++it) | 129 for (; it != downloads_observed_.end(); ++it) |
124 (*it)->RemoveObserver(this); | 130 (*it)->RemoveObserver(this); |
125 | 131 |
126 download_manager_->RemoveObserver(this); | 132 download_manager_->RemoveObserver(this); |
127 } | 133 } |
128 | 134 |
129 // State accessors. | 135 // State accessors. |
130 bool select_file_dialog_seen() { return select_file_dialog_seen_; } | 136 bool select_file_dialog_seen() { return select_file_dialog_seen_; } |
137 const FilePath& suggested_path() { return suggested_path_; } | |
131 | 138 |
132 // Wait for whatever state was specified in the constructor. | 139 // Wait for whatever state was specified in the constructor. |
133 void WaitForFinished() { | 140 void WaitForFinished() { |
134 if (!IsFinished()) { | 141 if (!IsFinished()) { |
135 waiting_ = true; | 142 waiting_ = true; |
136 ui_test_utils::RunMessageLoop(); | 143 ui_test_utils::RunMessageLoop(); |
137 waiting_ = false; | 144 waiting_ = false; |
138 } | 145 } |
139 } | 146 } |
140 | 147 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
233 // If it is finished and we are observing it, stop. | 240 // If it is finished and we are observing it, stop. |
234 if (finished_it != finished_downloads_.end() && | 241 if (finished_it != finished_downloads_.end() && |
235 observed_it != downloads_observed_.end()) { | 242 observed_it != downloads_observed_.end()) { |
236 (*it)->RemoveObserver(this); | 243 (*it)->RemoveObserver(this); |
237 downloads_observed_.erase(observed_it); | 244 downloads_observed_.erase(observed_it); |
238 continue; | 245 continue; |
239 } | 246 } |
240 } | 247 } |
241 } | 248 } |
242 | 249 |
243 virtual void SelectFileDialogDisplayed(int32 /* id */) { | 250 virtual void SelectFileDialogDisplayed( |
251 int32 /* id */, const FilePath& suggested_path) { | |
244 select_file_dialog_seen_ = true; | 252 select_file_dialog_seen_ = true; |
253 suggested_path_ = suggested_path; | |
245 SignalIfFinished(); | 254 SignalIfFinished(); |
246 } | 255 } |
247 | 256 |
248 virtual size_t NumDangerousDownloadsSeen() const { | 257 virtual size_t NumDangerousDownloadsSeen() const { |
249 return dangerous_downloads_seen_.size(); | 258 return dangerous_downloads_seen_.size(); |
250 } | 259 } |
251 | 260 |
252 private: | 261 private: |
253 // Called when we know that a download item is in a final state. | 262 // Called when we know that a download item is in a final state. |
254 // Note that this is not the same as it first transitioning in to the | 263 // Note that this is not the same as it first transitioning in to the |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
310 | 319 |
311 // True if we've seen the select file dialog. | 320 // True if we've seen the select file dialog. |
312 bool select_file_dialog_seen_; | 321 bool select_file_dialog_seen_; |
313 | 322 |
314 // Action to take if a dangerous download is encountered. | 323 // Action to take if a dangerous download is encountered. |
315 DangerousDownloadAction dangerous_download_action_; | 324 DangerousDownloadAction dangerous_download_action_; |
316 | 325 |
317 // Holds the download ids which were dangerous. | 326 // Holds the download ids which were dangerous. |
318 std::set<int32> dangerous_downloads_seen_; | 327 std::set<int32> dangerous_downloads_seen_; |
319 | 328 |
329 // The suggested file path in the select file dialog. | |
330 FilePath suggested_path_; | |
331 | |
320 DISALLOW_COPY_AND_ASSIGN(DownloadsObserver); | 332 DISALLOW_COPY_AND_ASSIGN(DownloadsObserver); |
321 }; | 333 }; |
322 | 334 |
323 // WaitForFlush() returns after: | 335 // WaitForFlush() returns after: |
324 // * There are no IN_PROGRESS download items remaining on the | 336 // * There are no IN_PROGRESS download items remaining on the |
325 // DownloadManager. | 337 // DownloadManager. |
326 // * There have been two round trip messages through the file and | 338 // * There have been two round trip messages through the file and |
327 // IO threads. | 339 // IO threads. |
328 // This almost certainly means that a Download cancel has propagated through | 340 // This almost certainly means that a Download cancel has propagated through |
329 // the system. | 341 // the system. |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
485 ResourceDispatcherHost* resource_dispatcher_host_; | 497 ResourceDispatcherHost* resource_dispatcher_host_; |
486 DownloadFileManager* download_file_manager_; | 498 DownloadFileManager* download_file_manager_; |
487 int rdh_pending_requests_; | 499 int rdh_pending_requests_; |
488 int dfm_pending_downloads_; | 500 int dfm_pending_downloads_; |
489 | 501 |
490 DISALLOW_COPY_AND_ASSIGN(CancelTestDataCollector); | 502 DISALLOW_COPY_AND_ASSIGN(CancelTestDataCollector); |
491 }; | 503 }; |
492 | 504 |
493 class DownloadTest : public InProcessBrowserTest { | 505 class DownloadTest : public InProcessBrowserTest { |
494 public: | 506 public: |
495 enum SelectExpectation { | |
496 EXPECT_NO_SELECT_DIALOG = -1, | |
497 EXPECT_NOTHING, | |
498 EXPECT_SELECT_DIALOG | |
499 }; | |
500 | |
501 DownloadTest() { | 507 DownloadTest() { |
502 EnableDOMAutomation(); | 508 EnableDOMAutomation(); |
503 } | 509 } |
504 | 510 |
505 // Returning false indicates a failure of the setup, and should be asserted | 511 // Returning false indicates a failure of the setup, and should be asserted |
506 // in the caller. | 512 // in the caller. |
507 virtual bool InitialSetup(bool prompt_for_download) { | 513 virtual bool InitialSetup(bool prompt_for_download) { |
508 bool have_test_dir = PathService::Get(chrome::DIR_TEST_DATA, &test_dir_); | 514 bool have_test_dir = PathService::Get(chrome::DIR_TEST_DATA, &test_dir_); |
509 EXPECT_TRUE(have_test_dir); | 515 EXPECT_TRUE(have_test_dir); |
510 if (!have_test_dir) | 516 if (!have_test_dir) |
(...skipping 27 matching lines...) Expand all Loading... | |
538 SIZE_TEST_TYPE_UNKNOWN, | 544 SIZE_TEST_TYPE_UNKNOWN, |
539 }; | 545 }; |
540 | 546 |
541 // Location of the file source (the place from which it is downloaded). | 547 // Location of the file source (the place from which it is downloaded). |
542 FilePath OriginFile(FilePath file) { | 548 FilePath OriginFile(FilePath file) { |
543 return test_dir_.Append(file); | 549 return test_dir_.Append(file); |
544 } | 550 } |
545 | 551 |
546 // Location of the file destination (place to which it is downloaded). | 552 // Location of the file destination (place to which it is downloaded). |
547 FilePath DestinationFile(Browser* browser, FilePath file) { | 553 FilePath DestinationFile(Browser* browser, FilePath file) { |
548 return GetDownloadDirectory(browser).Append(file); | 554 return GetDownloadSaveDirectory(browser).Append(file); |
549 } | 555 } |
550 | 556 |
551 // Must be called after browser creation. Creates a temporary | 557 // Must be called after browser creation. Creates a temporary |
552 // directory for downloads that is auto-deleted on destruction. | 558 // directory for downloads that is auto-deleted on destruction. |
553 // Returning false indicates a failure of the function, and should be asserted | 559 // Returning false indicates a failure of the function, and should be asserted |
554 // in the caller. | 560 // in the caller. |
555 bool CreateAndSetDownloadsDirectory(Browser* browser) { | 561 bool CreateAndSetDownloadsDirectory(Browser* browser) { |
556 if (!browser) | 562 if (!browser) |
557 return false; | 563 return false; |
558 | 564 |
559 if (!downloads_directory_.CreateUniqueTempDir()) | 565 if (!downloads_directory_.CreateUniqueTempDir()) |
560 return false; | 566 return false; |
561 | 567 |
562 browser->profile()->GetPrefs()->SetFilePath( | 568 browser->profile()->GetPrefs()->SetFilePath( |
563 prefs::kDownloadDefaultDirectory, | 569 prefs::kDownloadDefaultDirectory, |
564 downloads_directory_.path()); | 570 downloads_directory_.path()); |
565 | 571 |
566 return true; | 572 return true; |
567 } | 573 } |
568 | 574 |
575 // Delete the default folder for downloaded files. | |
576 bool DeleteDownloadsDirectory() { | |
577 return downloads_directory_.Delete(); | |
578 } | |
579 | |
569 DownloadPrefs* GetDownloadPrefs(Browser* browser) { | 580 DownloadPrefs* GetDownloadPrefs(Browser* browser) { |
570 return browser->profile()->GetDownloadManager()->download_prefs(); | 581 return browser->profile()->GetDownloadManager()->download_prefs(); |
571 } | 582 } |
572 | 583 |
573 FilePath GetDownloadDirectory(Browser* browser) { | 584 FilePath GetDownloadSaveDirectory(Browser* browser) { |
574 DownloadManager* download_mananger = | 585 DownloadManager* download_mananger = |
575 browser->profile()->GetDownloadManager(); | 586 browser->profile()->GetDownloadManager(); |
576 return download_mananger->download_prefs()->download_path(); | 587 return download_mananger->download_prefs()->download_path(); |
577 } | 588 } |
578 | 589 |
579 // Create a DownloadsObserver that will wait for the | 590 // Create a DownloadsObserver that will wait for the |
580 // specified number of downloads to finish. | 591 // specified number of downloads to finish. |
581 DownloadsObserver* CreateWaiter(Browser* browser, int num_downloads) { | 592 // If |finish_on_select_file| is true, the object will also be |
593 // considered finished when the select file dialog is displayed. | |
594 DownloadsObserver* CreateWaiter(Browser* browser, | |
595 int num_downloads, | |
596 bool finish_on_select_file) { | |
582 DownloadManager* download_manager = | 597 DownloadManager* download_manager = |
583 browser->profile()->GetDownloadManager(); | 598 browser->profile()->GetDownloadManager(); |
584 return new DownloadsObserver( | 599 return new DownloadsObserver( |
585 download_manager, num_downloads, | 600 download_manager, num_downloads, |
586 DownloadItem::COMPLETE, // Really done | 601 DownloadItem::COMPLETE, // Really done |
587 false, // Bail on select file | 602 finish_on_select_file, // Bail on select file |
588 ON_DANGEROUS_DOWNLOAD_FAIL); | 603 ON_DANGEROUS_DOWNLOAD_FAIL); |
589 } | 604 } |
590 | 605 |
591 // Create a DownloadsObserver that will wait for the | 606 // Create a DownloadsObserver that will wait for the |
592 // specified number of downloads to start. | 607 // specified number of downloads to start. |
593 DownloadsObserver* CreateInProgressWaiter(Browser* browser, | 608 DownloadsObserver* CreateInProgressWaiter(Browser* browser, |
594 int num_downloads) { | 609 int num_downloads) { |
595 DownloadManager* download_manager = | 610 DownloadManager* download_manager = |
596 browser->profile()->GetDownloadManager(); | 611 browser->profile()->GetDownloadManager(); |
597 return new DownloadsObserver( | 612 return new DownloadsObserver( |
(...skipping 16 matching lines...) Expand all Loading... | |
614 return new DownloadsObserver( | 629 return new DownloadsObserver( |
615 download_manager, num_downloads, | 630 download_manager, num_downloads, |
616 final_state, | 631 final_state, |
617 true, // Bail on select file | 632 true, // Bail on select file |
618 dangerous_download_action); | 633 dangerous_download_action); |
619 } | 634 } |
620 | 635 |
621 // Download |url|, then wait for the download to finish. | 636 // Download |url|, then wait for the download to finish. |
622 // |disposition| indicates where the navigation occurs (current tab, new | 637 // |disposition| indicates where the navigation occurs (current tab, new |
623 // foreground tab, etc). | 638 // foreground tab, etc). |
624 // |expectation| indicates whether or not a Select File dialog should be | 639 // |expect_file_dialog| indicates whether a select file dialog should be |
625 // open when the download is finished, or if we don't care. | 640 // open when the download is finished, or if we don't care. |
626 // If the dialog appears, the routine exits. The only effect |expectation| | 641 // If the dialog appears, the routine exits. The only effect |
627 // has is whether or not the test succeeds. | 642 // |expect_file_dialog| has is whether or not the test succeeds. |
643 // |expected_suggested_path| is the path expected to be suggested in the | |
644 // select file dialog. This |expected_suggested_path| must be specified | |
645 // if |expect_file_dialog| is true. If |expect_file_dialog| is false, | |
646 // |expected_suggested_path| is ignored. | |
628 // |browser_test_flags| indicate what to wait for, and is an OR of 0 or more | 647 // |browser_test_flags| indicate what to wait for, and is an OR of 0 or more |
629 // values in the ui_test_utils::BrowserTestWaitFlags enum. | 648 // values in the ui_test_utils::BrowserTestWaitFlags enum. |
630 void DownloadAndWaitWithDisposition(Browser* browser, | 649 void DownloadAndWaitWithDisposition(Browser* browser, |
631 const GURL& url, | 650 const GURL& url, |
632 WindowOpenDisposition disposition, | 651 WindowOpenDisposition disposition, |
633 SelectExpectation expectation, | 652 bool expect_file_dialog, |
653 const FilePath& expected_suggested_path, | |
634 int browser_test_flags) { | 654 int browser_test_flags) { |
635 // Setup notification, navigate, and block. | 655 // Setup notification, navigate, and block. |
636 scoped_ptr<DownloadsObserver> observer(CreateWaiter(browser, 1)); | 656 scoped_ptr<DownloadsObserver> observer( |
657 CreateWaiter(browser, 1, expect_file_dialog)); | |
637 // This call will block until the condition specified by | 658 // This call will block until the condition specified by |
638 // |browser_test_flags|, but will not wait for the download to finish. | 659 // |browser_test_flags|, but will not wait for the download to finish. |
639 ui_test_utils::NavigateToURLWithDisposition(browser, | 660 ui_test_utils::NavigateToURLWithDisposition(browser, |
640 url, | 661 url, |
641 disposition, | 662 disposition, |
642 browser_test_flags); | 663 browser_test_flags); |
643 // Waits for the download to complete. | 664 // Waits for the download to complete. |
644 observer->WaitForFinished(); | 665 observer->WaitForFinished(); |
645 | 666 |
646 // If specified, check the state of the select file dialog. | 667 // Checks if the select file dialog was displayed as expected. |
647 if (expectation != EXPECT_NOTHING) { | 668 // If displayed, checks the suggested path in the dialog. |
648 EXPECT_EQ(expectation == EXPECT_SELECT_DIALOG, | 669 if (expect_file_dialog) { |
649 observer->select_file_dialog_seen()); | 670 EXPECT_TRUE(observer->select_file_dialog_seen()); |
671 EXPECT_EQ(observer->suggested_path(), expected_suggested_path); | |
672 } else { | |
673 EXPECT_FALSE(observer->select_file_dialog_seen()); | |
650 } | 674 } |
651 } | 675 } |
652 | 676 |
653 // Download a file in the current tab, then wait for the download to finish. | 677 // Download a file in the current tab, then wait for the download to finish. |
654 void DownloadAndWait(Browser* browser, | 678 // Expect that no select file dialog is displayed. |
655 const GURL& url, | 679 void DownloadAndWait(Browser* browser, const GURL& url) { |
656 SelectExpectation expectation) { | |
657 DownloadAndWaitWithDisposition( | 680 DownloadAndWaitWithDisposition( |
658 browser, | 681 browser, url, CURRENT_TAB, false, FilePath(), |
659 url, | |
660 CURRENT_TAB, | |
661 expectation, | |
662 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 682 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
663 } | 683 } |
664 | 684 |
685 // Download a file in the current tab, then wait for the download to finish. | |
686 // Expect that a select file dialog suggesting |expected_suggested_path| | |
687 // is displayed. | |
688 void DownloadAndWaitWithDialog(Browser* browser, const GURL& url, | |
689 const FilePath& expected_suggested_path) { | |
690 DownloadAndWaitWithDisposition( | |
691 browser, url, CURRENT_TAB, true, expected_suggested_path, | |
692 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | |
693 } | |
694 | |
665 // Should only be called when the download is known to have finished | 695 // Should only be called when the download is known to have finished |
666 // (in error or not). | 696 // (in error or not). |
667 // Returning false indicates a failure of the function, and should be asserted | 697 // Returning false indicates a failure of the function, and should be asserted |
668 // in the caller. | 698 // in the caller. |
669 bool CheckDownload(Browser* browser, | 699 bool CheckDownload(Browser* browser, |
670 const FilePath& downloaded_filename, | 700 const FilePath& downloaded_filename, |
671 const FilePath& origin_filename) { | 701 const FilePath& origin_filename) { |
672 // Find the path to which the data will be downloaded. | 702 // Find the path to which the data will be downloaded. |
673 FilePath downloaded_file(DestinationFile(browser, downloaded_filename)); | 703 FilePath downloaded_file(DestinationFile(browser, downloaded_filename)); |
674 | 704 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
717 // |expected_title_finished| need to be checked. | 747 // |expected_title_finished| need to be checked. |
718 FilePath filename; | 748 FilePath filename; |
719 net::FileURLToFilePath(url, &filename); | 749 net::FileURLToFilePath(url, &filename); |
720 string16 expected_title_in_progress( | 750 string16 expected_title_in_progress( |
721 ASCIIToUTF16(partial_indication) + filename.LossyDisplayName()); | 751 ASCIIToUTF16(partial_indication) + filename.LossyDisplayName()); |
722 string16 expected_title_finished( | 752 string16 expected_title_finished( |
723 ASCIIToUTF16(total_indication) + filename.LossyDisplayName()); | 753 ASCIIToUTF16(total_indication) + filename.LossyDisplayName()); |
724 | 754 |
725 // Download a partial web page in a background tab and wait. | 755 // Download a partial web page in a background tab and wait. |
726 // The mock system will not complete until it gets a special URL. | 756 // The mock system will not complete until it gets a special URL. |
727 scoped_ptr<DownloadsObserver> observer(CreateWaiter(browser, 1)); | 757 scoped_ptr<DownloadsObserver> observer(CreateWaiter(browser, 1, false)); |
728 ui_test_utils::NavigateToURL(browser, url); | 758 ui_test_utils::NavigateToURL(browser, url); |
729 | 759 |
730 // TODO(ahendrickson): check download status text before downloading. | 760 // TODO(ahendrickson): check download status text before downloading. |
731 // Need to: | 761 // Need to: |
732 // - Add a member function to the |DownloadShelf| interface class, that | 762 // - Add a member function to the |DownloadShelf| interface class, that |
733 // indicates how many members it has. | 763 // indicates how many members it has. |
734 // - Add a member function to |DownloadShelf| to get the status text | 764 // - Add a member function to |DownloadShelf| to get the status text |
735 // of a given member (for example, via the name in |DownloadItemView|'s | 765 // of a given member (for example, via the name in |DownloadItemView|'s |
736 // GetAccessibleState() member function), by index. | 766 // GetAccessibleState() member function), by index. |
737 // - Iterate over browser->window()->GetDownloadShelf()'s members | 767 // - Iterate over browser->window()->GetDownloadShelf()'s members |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
799 exists = true; | 829 exists = true; |
800 break; | 830 break; |
801 } | 831 } |
802 } | 832 } |
803 EXPECT_TRUE(exists); | 833 EXPECT_TRUE(exists); |
804 #else | 834 #else |
805 EXPECT_EQ(expected_non_cros, browser->window()->IsDownloadShelfVisible()); | 835 EXPECT_EQ(expected_non_cros, browser->window()->IsDownloadShelfVisible()); |
806 // TODO: Check for filename match in download shelf. | 836 // TODO: Check for filename match in download shelf. |
807 #endif | 837 #endif |
808 } | 838 } |
839 | |
809 static void ExpectWindowCountAfterDownload(size_t expected) { | 840 static void ExpectWindowCountAfterDownload(size_t expected) { |
810 #if defined(OS_CHROMEOS) | 841 #if defined(OS_CHROMEOS) |
811 // On ChromeOS, a download panel is created to display | 842 // On ChromeOS, a download panel is created to display |
812 // download information, and this counts as a window. | 843 // download information, and this counts as a window. |
813 expected++; | 844 expected++; |
814 #endif | 845 #endif |
815 EXPECT_EQ(expected, BrowserList::size()); | 846 EXPECT_EQ(expected, BrowserList::size()); |
816 } | 847 } |
817 | 848 |
849 // Returns "src/chrome/test/data/{kTestFile}", whatever URL is given. | |
850 static net::URLRequestJob* FactoryForTestFile( | |
851 net::URLRequest* request, const std::string& scheme) { | |
852 FilePath test_dir; | |
853 if (!PathService::Get(chrome::DIR_TEST_DATA, &test_dir)) | |
854 NOTREACHED(); | |
Paweł Hajdan Jr.
2011/08/12 17:00:59
This is a browser_test, please use gtest macros. E
haraken1
2011/08/15 00:44:15
Done.
| |
855 return new URLRequestMockHTTPJob(request, test_dir.Append(kTestFile)); | |
856 } | |
857 | |
818 private: | 858 private: |
819 // Location of the test data. | 859 // Location of the test data. |
820 FilePath test_dir_; | 860 FilePath test_dir_; |
821 | 861 |
822 // Location of the downloads directory for these tests | 862 // Location of the downloads directory for these tests |
823 ScopedTempDir downloads_directory_; | 863 ScopedTempDir downloads_directory_; |
824 }; | 864 }; |
825 | 865 |
826 // Get History Information. | 866 // Get History Information. |
827 class DownloadsHistoryDataCollector { | 867 class DownloadsHistoryDataCollector { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
942 // Files for these tests are found in DIR_TEST_DATA (currently | 982 // Files for these tests are found in DIR_TEST_DATA (currently |
943 // "chrome\test\data\", see chrome_paths.cc). | 983 // "chrome\test\data\", see chrome_paths.cc). |
944 // Mock responses have extension .mock-http-headers appended to the file name. | 984 // Mock responses have extension .mock-http-headers appended to the file name. |
945 | 985 |
946 // Download a file due to the associated MIME type. | 986 // Download a file due to the associated MIME type. |
947 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadMimeType) { | 987 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadMimeType) { |
948 ASSERT_TRUE(InitialSetup(false)); | 988 ASSERT_TRUE(InitialSetup(false)); |
949 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 989 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
950 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | 990 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); |
951 | 991 |
952 // Download the file and wait. We do not expect the Select File dialog. | 992 // Download the file and wait. |
953 DownloadAndWait(browser(), url, EXPECT_NO_SELECT_DIALOG); | 993 DownloadAndWait(browser(), url); |
954 | 994 |
955 // Check state. | 995 // Check state. |
956 EXPECT_EQ(1, browser()->tab_count()); | 996 EXPECT_EQ(1, browser()->tab_count()); |
957 CheckDownload(browser(), file, file); | 997 CheckDownload(browser(), file, file); |
958 CheckDownloadUI(browser(), true, true, file); | 998 CheckDownloadUI(browser(), true, true, file); |
959 } | 999 } |
960 | 1000 |
1001 // Checks if a file is saved to the user's "Downloads" folder | |
1002 // in the following situation: | |
1003 // The default folder for downloaded files does not exist. | |
1004 // The user's "Downloads" folder exists. | |
1005 // | |
1006 // This test creates and deletes a file on the user's real "Downloads" folder, | |
1007 // which is globally shared among all tests on the testing environment. | |
1008 // Therefore, if we run browser tests in parallel, the file created by one | |
1009 // browser test may be deleted by another broswer test when the file name | |
1010 // conflicts. In order to avoid this problem, we use a special mock URL | |
1011 // "http://mock.testfile.http/<random path>" for this download test. | |
1012 // Since we redirect "http://mock.testfile.http/<random path>" to | |
1013 // "chrome/test/data/{kTestFile}" using FactoryForTestFile(), | |
1014 // "chrome/test/data/{kTestFile}" is used for the file to be downloaded. | |
1015 // Then, the downloaded file is saved as a name "Downloads/<random path>", | |
1016 // which is a unique file name in the user's real "Downloads" folder. | |
1017 // | |
1018 // Ideally, in the first place, we should not use the user's "Downloads" folder. | |
1019 // Instead, we should create a temporary "Downloads" folder for each test. | |
1020 // However, we concluded that creating temporary "Downloads" folder for each | |
1021 // test requires very invasive code changes to many places. See also here: | |
1022 // http://codereview.chromium.org/6973052/ | |
1023 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadFolder) { | |
1024 ASSERT_TRUE(InitialSetup(false)); | |
1025 FilePath file(kTestFile); | |
1026 | |
1027 // Redirects "http://mock.testfile.http/<random path>" | |
1028 // to "src/chrome/test/data/{kTestFile}", whatever the <random path> is. | |
1029 std::string kMockHostnameForTestFile = "mock.testfile.http"; | |
1030 net::URLRequestFilter* filter = net::URLRequestFilter::GetInstance(); | |
1031 filter->AddHostnameHandler( | |
1032 "http", kMockHostnameForTestFile, FactoryForTestFile); | |
1033 std::string random_string = Generate128BitRandomBase64String(); | |
1034 RemoveChars(random_string, "/", &random_string); | |
1035 GURL url("http://" + kMockHostnameForTestFile + "/" + random_string); | |
1036 | |
1037 FilePath::StringType basename; | |
1038 #if defined(OS_WIN) | |
1039 basename = UTF8ToWide(random_string); | |
1040 #else | |
1041 basename = random_string; | |
1042 #endif | |
1043 FilePath default_download_dir = | |
1044 download_util::GetDefaultDownloadDirectoryFromPathService(); | |
1045 FilePath downloaded_file = default_download_dir.Append(basename); | |
1046 // Make sure that the target file does not exist. | |
1047 file_util::Delete(downloaded_file, false); | |
Paweł Hajdan Jr.
2011/08/12 17:00:59
Check return value, applies to all file_util funct
haraken1
2011/08/15 00:44:15
This Delete() can fail when the file does not exis
| |
1048 // Make sure that the temporary file does not exist. | |
1049 FilePath temporary_file = default_download_dir.Append( | |
1050 basename + FILE_PATH_LITERAL(".crdownload")); | |
1051 std::cout << temporary_file.value() << std::endl; | |
Paweł Hajdan Jr.
2011/08/12 17:00:59
Don't use cout directly, but rather the LOG macros
haraken1
2011/08/15 00:44:15
Sorry, removed this cout. This cout is just for my
| |
1052 file_util::Delete(temporary_file, false); | |
1053 | |
1054 // Delete the default folder for downloaded files. | |
1055 ASSERT_TRUE(DeleteDownloadsDirectory()); | |
1056 ASSERT_FALSE(file_util::PathExists(GetDownloadSaveDirectory(browser()))); | |
1057 | |
1058 // Download the file and wait. | |
1059 DownloadAndWaitWithDialog(browser(), url, downloaded_file); | |
1060 | |
1061 EXPECT_FALSE(file_util::PathExists(downloaded_file)); | |
1062 EXPECT_FALSE(file_util::PathExists(GetDownloadSaveDirectory(browser()))); | |
1063 EXPECT_EQ(1, browser()->tab_count()); | |
1064 | |
1065 // Clean up the generated files. | |
1066 file_util::Delete(downloaded_file, false); | |
1067 file_util::Delete(temporary_file, false); | |
1068 } | |
1069 | |
961 #if defined(OS_WIN) | 1070 #if defined(OS_WIN) |
962 // Download a file and confirm that the zone identifier (on windows) | 1071 // Download a file and confirm that the zone identifier (on windows) |
963 // is set to internet. | 1072 // is set to internet. |
964 IN_PROC_BROWSER_TEST_F(DownloadTest, CheckInternetZone) { | 1073 IN_PROC_BROWSER_TEST_F(DownloadTest, CheckInternetZone) { |
965 ASSERT_TRUE(InitialSetup(false)); | 1074 ASSERT_TRUE(InitialSetup(false)); |
966 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 1075 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
967 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | 1076 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); |
968 | 1077 |
969 // Download the file and wait. We do not expect the Select File dialog. | 1078 // Download the file and wait. |
970 DownloadAndWait(browser(), url, EXPECT_NO_SELECT_DIALOG); | 1079 DownloadAndWait(browser(), url); |
971 | 1080 |
972 // Check state. Special file state must be checked before CheckDownload, | 1081 // Check state. Special file state must be checked before CheckDownload, |
973 // as CheckDownload will delete the output file. | 1082 // as CheckDownload will delete the output file. |
974 EXPECT_EQ(1, browser()->tab_count()); | 1083 EXPECT_EQ(1, browser()->tab_count()); |
975 FilePath downloaded_file(DestinationFile(browser(), file)); | 1084 FilePath downloaded_file(DestinationFile(browser(), file)); |
976 if (file_util::VolumeSupportsADS(downloaded_file)) | 1085 if (file_util::VolumeSupportsADS(downloaded_file)) |
977 EXPECT_TRUE(file_util::HasInternetZoneIdentifier(downloaded_file)); | 1086 EXPECT_TRUE(file_util::HasInternetZoneIdentifier(downloaded_file)); |
978 CheckDownload(browser(), file, file); | 1087 CheckDownload(browser(), file, file); |
979 CheckDownloadUI(browser(), true, true, file); | 1088 CheckDownloadUI(browser(), true, true, file); |
980 } | 1089 } |
981 #endif | 1090 #endif |
982 | 1091 |
983 // Put up a Select File dialog when the file is downloaded, due to its MIME | 1092 // Put up a select file dialog when the file is downloaded, due to its MIME |
984 // type. | 1093 // type. |
985 // | 1094 // |
986 // This test runs correctly, but leaves behind turds in the test user's | 1095 // This test runs correctly, but leaves behind turds in the test user's |
987 // download directory because of http://crbug.com/62099. No big loss; it | 1096 // download directory because of http://crbug.com/62099. No big loss; it |
988 // was primarily confirming DownloadsObserver wait on select file dialog | 1097 // was primarily confirming DownloadsObserver wait on select file dialog |
989 // functionality anyway. | 1098 // functionality anyway. |
990 IN_PROC_BROWSER_TEST_F(DownloadTest, DISABLED_DownloadMimeTypeSelect) { | 1099 IN_PROC_BROWSER_TEST_F(DownloadTest, DISABLED_DownloadMimeTypeSelect) { |
991 ASSERT_TRUE(InitialSetup(true)); | 1100 ASSERT_TRUE(InitialSetup(true)); |
992 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 1101 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
993 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | 1102 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); |
1103 FilePath file_path(DestinationFile(browser(), file)); | |
994 | 1104 |
995 // Download the file and wait. We expect the Select File dialog to appear | 1105 // Download the file and wait. We expect the select file dialog to appear |
996 // due to the MIME type. | 1106 // due to the MIME type. |
997 DownloadAndWait(browser(), url, EXPECT_SELECT_DIALOG); | 1107 DownloadAndWaitWithDialog(browser(), url, file_path); |
998 | 1108 |
999 // Check state. | 1109 // Check state. |
1000 EXPECT_EQ(1, browser()->tab_count()); | 1110 EXPECT_EQ(1, browser()->tab_count()); |
1001 // Since we exited while the Select File dialog was visible, there should not | 1111 // Since we exited while the select file dialog was visible, there should not |
1002 // be anything in the download shelf and so it should not be visible. | 1112 // be anything in the download shelf and so it should not be visible. |
1003 CheckDownloadUI(browser(), false, false, FilePath()); | 1113 CheckDownloadUI(browser(), false, false, FilePath()); |
1004 } | 1114 } |
1005 | 1115 |
1006 // Access a file with a viewable mime-type, verify that a download | 1116 // Access a file with a viewable mime-type, verify that a download |
1007 // did not initiate. | 1117 // did not initiate. |
1008 IN_PROC_BROWSER_TEST_F(DownloadTest, NoDownload) { | 1118 IN_PROC_BROWSER_TEST_F(DownloadTest, NoDownload) { |
1009 ASSERT_TRUE(InitialSetup(false)); | 1119 ASSERT_TRUE(InitialSetup(false)); |
1010 FilePath file(FILE_PATH_LITERAL("download-test2.html")); | 1120 FilePath file(FILE_PATH_LITERAL("download-test2.html")); |
1011 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | 1121 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); |
(...skipping 14 matching lines...) Expand all Loading... | |
1026 // download tab opened and the file exists as the filename specified in the | 1136 // download tab opened and the file exists as the filename specified in the |
1027 // header. This also ensures we properly handle empty file downloads. | 1137 // header. This also ensures we properly handle empty file downloads. |
1028 // The download shelf should be visible in the current tab. | 1138 // The download shelf should be visible in the current tab. |
1029 IN_PROC_BROWSER_TEST_F(DownloadTest, ContentDisposition) { | 1139 IN_PROC_BROWSER_TEST_F(DownloadTest, ContentDisposition) { |
1030 ASSERT_TRUE(InitialSetup(false)); | 1140 ASSERT_TRUE(InitialSetup(false)); |
1031 FilePath file(FILE_PATH_LITERAL("download-test3.gif")); | 1141 FilePath file(FILE_PATH_LITERAL("download-test3.gif")); |
1032 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | 1142 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); |
1033 FilePath download_file(FILE_PATH_LITERAL("download-test3-attachment.gif")); | 1143 FilePath download_file(FILE_PATH_LITERAL("download-test3-attachment.gif")); |
1034 | 1144 |
1035 // Download a file and wait. | 1145 // Download a file and wait. |
1036 DownloadAndWait(browser(), url, EXPECT_NO_SELECT_DIALOG); | 1146 DownloadAndWait(browser(), url); |
1037 | 1147 |
1038 CheckDownload(browser(), download_file, file); | 1148 CheckDownload(browser(), download_file, file); |
1039 | 1149 |
1040 // Check state. | 1150 // Check state. |
1041 EXPECT_EQ(1, browser()->tab_count()); | 1151 EXPECT_EQ(1, browser()->tab_count()); |
1042 CheckDownloadUI(browser(), true, true, download_file); | 1152 CheckDownloadUI(browser(), true, true, download_file); |
1043 } | 1153 } |
1044 | 1154 |
1045 #if !defined(OS_CHROMEOS) // Download shelf is not per-window on ChromeOS. | 1155 #if !defined(OS_CHROMEOS) // Download shelf is not per-window on ChromeOS. |
1046 // Test that the download shelf is per-window by starting a download in one | 1156 // Test that the download shelf is per-window by starting a download in one |
1047 // tab, opening a second tab, closing the shelf, going back to the first tab, | 1157 // tab, opening a second tab, closing the shelf, going back to the first tab, |
1048 // and checking that the shelf is closed. | 1158 // and checking that the shelf is closed. |
1049 IN_PROC_BROWSER_TEST_F(DownloadTest, PerWindowShelf) { | 1159 IN_PROC_BROWSER_TEST_F(DownloadTest, PerWindowShelf) { |
1050 ASSERT_TRUE(InitialSetup(false)); | 1160 ASSERT_TRUE(InitialSetup(false)); |
1051 FilePath file(FILE_PATH_LITERAL("download-test3.gif")); | 1161 FilePath file(FILE_PATH_LITERAL("download-test3.gif")); |
1052 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | 1162 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); |
1053 FilePath download_file(FILE_PATH_LITERAL("download-test3-attachment.gif")); | 1163 FilePath download_file(FILE_PATH_LITERAL("download-test3-attachment.gif")); |
1054 | 1164 |
1055 // Download a file and wait. | 1165 // Download a file and wait. |
1056 DownloadAndWait(browser(), url, EXPECT_NO_SELECT_DIALOG); | 1166 DownloadAndWait(browser(), url); |
1057 | 1167 |
1058 CheckDownload(browser(), download_file, file); | 1168 CheckDownload(browser(), download_file, file); |
1059 | 1169 |
1060 // Check state. | 1170 // Check state. |
1061 EXPECT_EQ(1, browser()->tab_count()); | 1171 EXPECT_EQ(1, browser()->tab_count()); |
1062 CheckDownloadUI(browser(), true, true, download_file); | 1172 CheckDownloadUI(browser(), true, true, download_file); |
1063 | 1173 |
1064 // Open a second tab and wait. | 1174 // Open a second tab and wait. |
1065 EXPECT_NE(static_cast<TabContentsWrapper*>(NULL), | 1175 EXPECT_NE(static_cast<TabContentsWrapper*>(NULL), |
1066 browser()->AddSelectedTabWithURL(GURL(), PageTransition::TYPED)); | 1176 browser()->AddSelectedTabWithURL(GURL(), PageTransition::TYPED)); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1111 int window_count = BrowserList::size(); | 1221 int window_count = BrowserList::size(); |
1112 EXPECT_EQ(2, window_count); | 1222 EXPECT_EQ(2, window_count); |
1113 | 1223 |
1114 // Download a file in the Incognito window and wait. | 1224 // Download a file in the Incognito window and wait. |
1115 CreateAndSetDownloadsDirectory(incognito); | 1225 CreateAndSetDownloadsDirectory(incognito); |
1116 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 1226 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
1117 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | 1227 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); |
1118 // Since |incognito| is a separate browser, we have to set it up explicitly. | 1228 // Since |incognito| is a separate browser, we have to set it up explicitly. |
1119 incognito->profile()->GetPrefs()->SetBoolean(prefs::kPromptForDownload, | 1229 incognito->profile()->GetPrefs()->SetBoolean(prefs::kPromptForDownload, |
1120 false); | 1230 false); |
1121 DownloadAndWait(incognito, url, EXPECT_NO_SELECT_DIALOG); | 1231 DownloadAndWait(incognito, url); |
1122 | 1232 |
1123 // We should still have 2 windows. | 1233 // We should still have 2 windows. |
1124 ExpectWindowCountAfterDownload(2); | 1234 ExpectWindowCountAfterDownload(2); |
1125 | 1235 |
1126 // Verify that the download shelf is showing for the Incognito window. | 1236 // Verify that the download shelf is showing for the Incognito window. |
1127 CheckDownloadUI(incognito, true, true, file); | 1237 CheckDownloadUI(incognito, true, true, file); |
1128 | 1238 |
1129 #if !defined(OS_MACOSX) | 1239 #if !defined(OS_MACOSX) |
1130 // On Mac OS X, the UI window close is delayed until the outermost | 1240 // On Mac OS X, the UI window close is delayed until the outermost |
1131 // message loop runs. So it isn't possible to get a BROWSER_CLOSED | 1241 // message loop runs. So it isn't possible to get a BROWSER_CLOSED |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1178 ASSERT_TRUE(InitialSetup(false)); | 1288 ASSERT_TRUE(InitialSetup(false)); |
1179 | 1289 |
1180 // Download a file in a new background tab and wait. The tab is automatically | 1290 // Download a file in a new background tab and wait. The tab is automatically |
1181 // closed when the download begins. | 1291 // closed when the download begins. |
1182 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 1292 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
1183 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | 1293 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); |
1184 DownloadAndWaitWithDisposition( | 1294 DownloadAndWaitWithDisposition( |
1185 browser(), | 1295 browser(), |
1186 url, | 1296 url, |
1187 NEW_BACKGROUND_TAB, | 1297 NEW_BACKGROUND_TAB, |
1188 EXPECT_NO_SELECT_DIALOG, | 1298 false, |
1299 FilePath(), | |
1189 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 1300 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
1190 | 1301 |
1191 // When the download finishes, we should still have one tab. | 1302 // When the download finishes, we should still have one tab. |
1192 CheckDownloadUI(browser(), true, true, file); | 1303 CheckDownloadUI(browser(), true, true, file); |
1193 EXPECT_EQ(1, browser()->tab_count()); | 1304 EXPECT_EQ(1, browser()->tab_count()); |
1194 | 1305 |
1195 CheckDownload(browser(), file, file); | 1306 CheckDownload(browser(), file, file); |
1196 } | 1307 } |
1197 | 1308 |
1198 // Open a web page in the current tab, then download a file in another tab via | 1309 // Open a web page in the current tab, then download a file in another tab via |
(...skipping 11 matching lines...) Expand all Loading... | |
1210 GURL url(URLRequestMockHTTPJob::GetMockUrl(file1)); | 1321 GURL url(URLRequestMockHTTPJob::GetMockUrl(file1)); |
1211 | 1322 |
1212 // Open a web page and wait. | 1323 // Open a web page and wait. |
1213 ui_test_utils::NavigateToURL(browser(), url); | 1324 ui_test_utils::NavigateToURL(browser(), url); |
1214 | 1325 |
1215 // Download a file in a new tab and wait (via Javascript). | 1326 // Download a file in a new tab and wait (via Javascript). |
1216 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 1327 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
1217 DownloadAndWaitWithDisposition(browser(), | 1328 DownloadAndWaitWithDisposition(browser(), |
1218 GURL("javascript:openNew()"), | 1329 GURL("javascript:openNew()"), |
1219 CURRENT_TAB, | 1330 CURRENT_TAB, |
1220 EXPECT_NO_SELECT_DIALOG, | 1331 false, |
1332 FilePath(), | |
1221 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); | 1333 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); |
1222 | 1334 |
1223 // When the download finishes, we should have two tabs. | 1335 // When the download finishes, we should have two tabs. |
1224 CheckDownloadUI(browser(), true, true, file); | 1336 CheckDownloadUI(browser(), true, true, file); |
1225 EXPECT_EQ(2, browser()->tab_count()); | 1337 EXPECT_EQ(2, browser()->tab_count()); |
1226 | 1338 |
1227 CheckDownload(browser(), file, file); | 1339 CheckDownload(browser(), file, file); |
1228 } | 1340 } |
1229 | 1341 |
1230 // Open a web page in the current tab, open another tab via a Javascript call, | 1342 // Open a web page in the current tab, open another tab via a Javascript call, |
(...skipping 21 matching lines...) Expand all Loading... | |
1252 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); | 1364 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); |
1253 | 1365 |
1254 EXPECT_EQ(2, browser()->tab_count()); | 1366 EXPECT_EQ(2, browser()->tab_count()); |
1255 | 1367 |
1256 // Download a file and wait. | 1368 // Download a file and wait. |
1257 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 1369 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
1258 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | 1370 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); |
1259 DownloadAndWaitWithDisposition(browser(), | 1371 DownloadAndWaitWithDisposition(browser(), |
1260 url, | 1372 url, |
1261 CURRENT_TAB, | 1373 CURRENT_TAB, |
1262 EXPECT_NO_SELECT_DIALOG, | 1374 false, |
1375 FilePath(), | |
1263 ui_test_utils::BROWSER_TEST_NONE); | 1376 ui_test_utils::BROWSER_TEST_NONE); |
1264 | 1377 |
1265 // When the download finishes, we should have two tabs. | 1378 // When the download finishes, we should have two tabs. |
1266 CheckDownloadUI(browser(), true, true, file); | 1379 CheckDownloadUI(browser(), true, true, file); |
1267 EXPECT_EQ(2, browser()->tab_count()); | 1380 EXPECT_EQ(2, browser()->tab_count()); |
1268 | 1381 |
1269 CheckDownload(browser(), file, file); | 1382 CheckDownload(browser(), file, file); |
1270 } | 1383 } |
1271 | 1384 |
1272 // Open a web page in the current tab, then download a file via Javascript, | 1385 // Open a web page in the current tab, then download a file via Javascript, |
(...skipping 12 matching lines...) Expand all Loading... | |
1285 | 1398 |
1286 // Open a web page and wait. | 1399 // Open a web page and wait. |
1287 ui_test_utils::NavigateToURL(browser(), url); | 1400 ui_test_utils::NavigateToURL(browser(), url); |
1288 | 1401 |
1289 // Download a file and wait. | 1402 // Download a file and wait. |
1290 // The file to download is "download-test1.lib". | 1403 // The file to download is "download-test1.lib". |
1291 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 1404 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
1292 DownloadAndWaitWithDisposition(browser(), | 1405 DownloadAndWaitWithDisposition(browser(), |
1293 GURL("javascript:openNew()"), | 1406 GURL("javascript:openNew()"), |
1294 CURRENT_TAB, | 1407 CURRENT_TAB, |
1295 EXPECT_NO_SELECT_DIALOG, | 1408 false, |
1409 FilePath(), | |
1296 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); | 1410 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); |
1297 | 1411 |
1298 // When the download finishes, we should still have one tab. | 1412 // When the download finishes, we should still have one tab. |
1299 CheckDownloadUI(browser(), true, true, file); | 1413 CheckDownloadUI(browser(), true, true, file); |
1300 EXPECT_EQ(1, browser()->tab_count()); | 1414 EXPECT_EQ(1, browser()->tab_count()); |
1301 | 1415 |
1302 CheckDownload(browser(), file, file); | 1416 CheckDownload(browser(), file, file); |
1303 } | 1417 } |
1304 | 1418 |
1305 // Open a web page in the current tab, then call Javascript via a button to | 1419 // Open a web page in the current tab, then call Javascript via a button to |
(...skipping 14 matching lines...) Expand all Loading... | |
1320 ui_test_utils::NavigateToURL(browser(), url); | 1434 ui_test_utils::NavigateToURL(browser(), url); |
1321 | 1435 |
1322 // Download a file in a new tab and wait. The tab will automatically close | 1436 // Download a file in a new tab and wait. The tab will automatically close |
1323 // when the download begins. | 1437 // when the download begins. |
1324 // The file to download is "download-test1.lib". | 1438 // The file to download is "download-test1.lib". |
1325 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 1439 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
1326 DownloadAndWaitWithDisposition( | 1440 DownloadAndWaitWithDisposition( |
1327 browser(), | 1441 browser(), |
1328 GURL("javascript:document.getElementById('form').submit()"), | 1442 GURL("javascript:document.getElementById('form').submit()"), |
1329 CURRENT_TAB, | 1443 CURRENT_TAB, |
1330 EXPECT_NO_SELECT_DIALOG, | 1444 false, |
1445 FilePath(), | |
1331 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); | 1446 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); |
1332 | 1447 |
1333 // When the download finishes, we should still have one tab. | 1448 // When the download finishes, we should still have one tab. |
1334 CheckDownloadUI(browser(), true, true, file); | 1449 CheckDownloadUI(browser(), true, true, file); |
1335 EXPECT_EQ(1, browser()->tab_count()); | 1450 EXPECT_EQ(1, browser()->tab_count()); |
1336 | 1451 |
1337 CheckDownload(browser(), file, file); | 1452 CheckDownload(browser(), file, file); |
1338 } | 1453 } |
1339 | 1454 |
1340 // Download a file in a new window. | 1455 // Download a file in a new window. |
1341 // Verify that we have 2 windows, and the download shelf is not visible in the | 1456 // Verify that we have 2 windows, and the download shelf is not visible in the |
1342 // first window, but is visible in the second window. | 1457 // first window, but is visible in the second window. |
1343 // Close the new window. | 1458 // Close the new window. |
1344 // Verify that we have 1 window, and the download shelf is not visible. | 1459 // Verify that we have 1 window, and the download shelf is not visible. |
1345 // | 1460 // |
1346 // Regression test for http://crbug.com/44454 | 1461 // Regression test for http://crbug.com/44454 |
1347 IN_PROC_BROWSER_TEST_F(DownloadTest, NewWindow) { | 1462 IN_PROC_BROWSER_TEST_F(DownloadTest, NewWindow) { |
1348 ASSERT_TRUE(InitialSetup(false)); | 1463 ASSERT_TRUE(InitialSetup(false)); |
1349 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 1464 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
1350 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | 1465 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); |
1351 #if !defined(OS_MACOSX) | 1466 #if !defined(OS_MACOSX) |
1352 // See below. | 1467 // See below. |
1353 Browser* first_browser = browser(); | 1468 Browser* first_browser = browser(); |
1354 #endif | 1469 #endif |
1355 | 1470 |
1356 // Download a file in a new window and wait. | 1471 // Download a file in a new window and wait. |
1357 DownloadAndWaitWithDisposition(browser(), | 1472 DownloadAndWaitWithDisposition(browser(), |
1358 url, | 1473 url, |
1359 NEW_WINDOW, | 1474 NEW_WINDOW, |
1360 EXPECT_NO_SELECT_DIALOG, | 1475 false, |
1476 FilePath(), | |
1361 ui_test_utils::BROWSER_TEST_NONE); | 1477 ui_test_utils::BROWSER_TEST_NONE); |
1362 | 1478 |
1363 // When the download finishes, the download shelf SHOULD NOT be visible in | 1479 // When the download finishes, the download shelf SHOULD NOT be visible in |
1364 // the first window. | 1480 // the first window. |
1365 ExpectWindowCountAfterDownload(2); | 1481 ExpectWindowCountAfterDownload(2); |
1366 EXPECT_EQ(1, browser()->tab_count()); | 1482 EXPECT_EQ(1, browser()->tab_count()); |
1367 // Download shelf should close. Download panel stays open on ChromeOS. | 1483 // Download shelf should close. Download panel stays open on ChromeOS. |
1368 CheckDownloadUI(browser(), false, true, file); | 1484 CheckDownloadUI(browser(), false, true, file); |
1369 | 1485 |
1370 // The download shelf SHOULD be visible in the second window. | 1486 // The download shelf SHOULD be visible in the second window. |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1457 | 1573 |
1458 // Confirm a download makes it into the history properly. | 1574 // Confirm a download makes it into the history properly. |
1459 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadHistoryCheck) { | 1575 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadHistoryCheck) { |
1460 ASSERT_TRUE(InitialSetup(false)); | 1576 ASSERT_TRUE(InitialSetup(false)); |
1461 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 1577 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
1462 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | 1578 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); |
1463 FilePath origin_file(OriginFile(file)); | 1579 FilePath origin_file(OriginFile(file)); |
1464 int64 origin_size; | 1580 int64 origin_size; |
1465 file_util::GetFileSize(origin_file, &origin_size); | 1581 file_util::GetFileSize(origin_file, &origin_size); |
1466 | 1582 |
1467 // Download the file and wait. We do not expect the Select File dialog. | 1583 // Download the file and wait. |
1468 DownloadAndWait(browser(), url, EXPECT_NO_SELECT_DIALOG); | 1584 DownloadAndWait(browser(), url); |
1469 | 1585 |
1470 // Get details of what downloads have just happened. | 1586 // Get details of what downloads have just happened. |
1471 std::vector<DownloadItem*> downloads; | 1587 std::vector<DownloadItem*> downloads; |
1472 GetDownloads(browser(), &downloads); | 1588 GetDownloads(browser(), &downloads); |
1473 ASSERT_EQ(1u, downloads.size()); | 1589 ASSERT_EQ(1u, downloads.size()); |
1474 int64 db_handle = downloads[0]->db_handle(); | 1590 int64 db_handle = downloads[0]->db_handle(); |
1475 | 1591 |
1476 // Check state. | 1592 // Check state. |
1477 EXPECT_EQ(1, browser()->tab_count()); | 1593 EXPECT_EQ(1, browser()->tab_count()); |
1478 CheckDownload(browser(), file, file); | 1594 CheckDownload(browser(), file, file); |
(...skipping 16 matching lines...) Expand all Loading... | |
1495 // Test for crbug.com/14505. This tests that chrome:// urls are still functional | 1611 // Test for crbug.com/14505. This tests that chrome:// urls are still functional |
1496 // after download of a file while viewing another chrome://. | 1612 // after download of a file while viewing another chrome://. |
1497 IN_PROC_BROWSER_TEST_F(DownloadTest, ChromeURLAfterDownload) { | 1613 IN_PROC_BROWSER_TEST_F(DownloadTest, ChromeURLAfterDownload) { |
1498 ASSERT_TRUE(InitialSetup(false)); | 1614 ASSERT_TRUE(InitialSetup(false)); |
1499 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 1615 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
1500 GURL download_url(URLRequestMockHTTPJob::GetMockUrl(file)); | 1616 GURL download_url(URLRequestMockHTTPJob::GetMockUrl(file)); |
1501 GURL flags_url(chrome::kChromeUIFlagsURL); | 1617 GURL flags_url(chrome::kChromeUIFlagsURL); |
1502 GURL extensions_url(chrome::kChromeUIExtensionsURL); | 1618 GURL extensions_url(chrome::kChromeUIExtensionsURL); |
1503 | 1619 |
1504 ui_test_utils::NavigateToURL(browser(), flags_url); | 1620 ui_test_utils::NavigateToURL(browser(), flags_url); |
1505 DownloadAndWait(browser(), download_url, EXPECT_NO_SELECT_DIALOG); | 1621 DownloadAndWait(browser(), download_url); |
1506 ui_test_utils::NavigateToURL(browser(), extensions_url); | 1622 ui_test_utils::NavigateToURL(browser(), extensions_url); |
1507 TabContents* contents = browser()->GetSelectedTabContents(); | 1623 TabContents* contents = browser()->GetSelectedTabContents(); |
1508 ASSERT_TRUE(contents); | 1624 ASSERT_TRUE(contents); |
1509 bool webui_responded = false; | 1625 bool webui_responded = false; |
1510 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 1626 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
1511 contents->render_view_host(), | 1627 contents->render_view_host(), |
1512 L"", | 1628 L"", |
1513 L"window.domAutomationController.send(window.webui_responded_);", | 1629 L"window.domAutomationController.send(window.webui_responded_);", |
1514 &webui_responded)); | 1630 &webui_responded)); |
1515 EXPECT_TRUE(webui_responded); | 1631 EXPECT_TRUE(webui_responded); |
(...skipping 16 matching lines...) Expand all Loading... | |
1532 ASSERT_TRUE(contents); | 1648 ASSERT_TRUE(contents); |
1533 bool result = false; | 1649 bool result = false; |
1534 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 1650 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
1535 contents->render_view_host(), | 1651 contents->render_view_host(), |
1536 L"", | 1652 L"", |
1537 L"window.onunload = function() { var do_nothing = 0; }; " | 1653 L"window.onunload = function() { var do_nothing = 0; }; " |
1538 L"window.domAutomationController.send(true);", | 1654 L"window.domAutomationController.send(true);", |
1539 &result)); | 1655 &result)); |
1540 EXPECT_TRUE(result); | 1656 EXPECT_TRUE(result); |
1541 | 1657 |
1542 DownloadAndWait(browser(), download_url, EXPECT_NO_SELECT_DIALOG); | 1658 DownloadAndWait(browser(), download_url); |
1543 | 1659 |
1544 ui_test_utils::WindowedNotificationObserver signal( | 1660 ui_test_utils::WindowedNotificationObserver signal( |
1545 chrome::NOTIFICATION_BROWSER_CLOSED, | 1661 chrome::NOTIFICATION_BROWSER_CLOSED, |
1546 Source<Browser>(browser())); | 1662 Source<Browser>(browser())); |
1547 browser()->CloseWindow(); | 1663 browser()->CloseWindow(); |
1548 signal.Wait(); | 1664 signal.Wait(); |
1549 } | 1665 } |
1550 | 1666 |
1551 // Test to make sure the 'download' attribute in anchor tag is respected. | 1667 // Test to make sure the 'download' attribute in anchor tag is respected. |
1552 IN_PROC_BROWSER_TEST_F(DownloadTest, AnchorDownloadTag) { | 1668 IN_PROC_BROWSER_TEST_F(DownloadTest, AnchorDownloadTag) { |
1553 ASSERT_TRUE(InitialSetup(false)); | 1669 ASSERT_TRUE(InitialSetup(false)); |
1554 FilePath file(FILE_PATH_LITERAL("download-anchor-attrib.html")); | 1670 FilePath file(FILE_PATH_LITERAL("download-anchor-attrib.html")); |
1555 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | 1671 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); |
1556 | 1672 |
1557 // Create a download, wait until it's complete, and confirm | 1673 // Create a download, wait until it's complete, and confirm |
1558 // we're in the expected state. | 1674 // we're in the expected state. |
1559 scoped_ptr<DownloadsObserver> observer(CreateWaiter(browser(), 1)); | 1675 scoped_ptr<DownloadsObserver> observer(CreateWaiter(browser(), 1, false)); |
1560 ui_test_utils::NavigateToURL(browser(), url); | 1676 ui_test_utils::NavigateToURL(browser(), url); |
1561 observer->WaitForFinished(); | 1677 observer->WaitForFinished(); |
1562 | 1678 |
1563 // Confirm the downloaded data exists. | 1679 // Confirm the downloaded data exists. |
1564 FilePath downloaded_file = GetDownloadDirectory(browser()); | 1680 FilePath downloaded_file( |
1565 downloaded_file = downloaded_file.Append(FILE_PATH_LITERAL("a_red_dot.png")); | 1681 DestinationFile(browser(), FilePath(FILE_PATH_LITERAL("a_red_dot.png")))); |
1566 EXPECT_TRUE(file_util::PathExists(downloaded_file)); | 1682 EXPECT_TRUE(file_util::PathExists(downloaded_file)); |
1567 } | 1683 } |
1568 | 1684 |
1569 // Test to make sure auto-open works. | 1685 // Test to make sure auto-open works. |
1570 IN_PROC_BROWSER_TEST_F(DownloadTest, AutoOpen) { | 1686 IN_PROC_BROWSER_TEST_F(DownloadTest, AutoOpen) { |
1571 ASSERT_TRUE(InitialSetup(false)); | 1687 ASSERT_TRUE(InitialSetup(false)); |
1572 FilePath file(FILE_PATH_LITERAL("download-autoopen.txt")); | 1688 FilePath file(FILE_PATH_LITERAL("download-autoopen.txt")); |
1573 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | 1689 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); |
1574 | 1690 |
1575 ASSERT_TRUE( | 1691 ASSERT_TRUE( |
1576 GetDownloadPrefs(browser())->EnableAutoOpenBasedOnExtension(file)); | 1692 GetDownloadPrefs(browser())->EnableAutoOpenBasedOnExtension(file)); |
1577 | 1693 |
1578 // Mock out external opening on all downloads until end of test. | 1694 // Mock out external opening on all downloads until end of test. |
1579 MockDownloadOpeningObserver observer( | 1695 MockDownloadOpeningObserver observer( |
1580 browser()->profile()->GetDownloadManager()); | 1696 browser()->profile()->GetDownloadManager()); |
1581 | 1697 |
1582 DownloadAndWait(browser(), url, EXPECT_NO_SELECT_DIALOG); | 1698 DownloadAndWait(browser(), url); |
1583 | 1699 |
1584 // Find the download and confirm it was opened. | 1700 // Find the download and confirm it was opened. |
1585 std::vector<DownloadItem*> downloads; | 1701 std::vector<DownloadItem*> downloads; |
1586 browser()->profile()->GetDownloadManager()->SearchDownloads( | 1702 browser()->profile()->GetDownloadManager()->SearchDownloads( |
1587 string16(), &downloads); | 1703 string16(), &downloads); |
1588 ASSERT_EQ(1u, downloads.size()); | 1704 ASSERT_EQ(1u, downloads.size()); |
1589 EXPECT_EQ(DownloadItem::COMPLETE, downloads[0]->state()); | 1705 EXPECT_EQ(DownloadItem::COMPLETE, downloads[0]->state()); |
1590 EXPECT_TRUE(downloads[0]->opened()); | 1706 EXPECT_TRUE(downloads[0]->opened()); |
1591 | 1707 |
1592 // As long as we're here, confirmed everything else is good. | 1708 // As long as we're here, confirmed everything else is good. |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1729 EXPECT_EQ(1u, observer->NumDangerousDownloadsSeen()); | 1845 EXPECT_EQ(1u, observer->NumDangerousDownloadsSeen()); |
1730 | 1846 |
1731 // Download shelf should close. Download panel stays open on ChromeOS. | 1847 // Download shelf should close. Download panel stays open on ChromeOS. |
1732 CheckDownloadUI(browser(), false, true, FilePath()); | 1848 CheckDownloadUI(browser(), false, true, FilePath()); |
1733 | 1849 |
1734 // Check that the extension was installed. | 1850 // Check that the extension was installed. |
1735 ExtensionService* extension_service = | 1851 ExtensionService* extension_service = |
1736 browser()->profile()->GetExtensionService(); | 1852 browser()->profile()->GetExtensionService(); |
1737 ASSERT_TRUE(extension_service->GetExtensionById(kLargeThemeCrxId, false)); | 1853 ASSERT_TRUE(extension_service->GetExtensionById(kLargeThemeCrxId, false)); |
1738 } | 1854 } |
OLD | NEW |