| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/browser.h" | 5 #include "chrome/browser/browser.h" |
| 6 #include "chrome/browser/tab_contents/tab_contents.h" | 6 #include "chrome/browser/tab_contents/tab_contents.h" |
| 7 #include "chrome/browser/download/download_manager.h" | 7 #include "chrome/browser/download/download_manager.h" |
| 8 #include "chrome/browser/profile.h" | 8 #include "chrome/browser/profile.h" |
| 9 #include "chrome/common/chrome_paths.h" | 9 #include "chrome/common/chrome_paths.h" |
| 10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 } | 75 } |
| 76 } | 76 } |
| 77 | 77 |
| 78 private: | 78 private: |
| 79 NotificationRegistrar registrar_; | 79 NotificationRegistrar registrar_; |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 // Test for crbug.com/12745. This tests that if a download is initiated from | 82 // Test for crbug.com/12745. This tests that if a download is initiated from |
| 83 // a chrome:// page that has registered and onunload handler, the browser | 83 // a chrome:// page that has registered and onunload handler, the browser |
| 84 // will be able to close. | 84 // will be able to close. |
| 85 // TODO(rafaelw): The fix for 12745 has now also been reverted. Another fix |
| 86 // must be found before this can be re-enabled. |
| 85 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, | 87 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, |
| 86 DISABLED_BrowserCloseAfterDownload) { | 88 DISABLED_BrowserCloseAfterDownload) { |
| 87 GURL downloads_url("chrome://downloads"); | 89 GURL downloads_url("chrome://downloads"); |
| 88 FilePath zip_download; | 90 FilePath zip_download; |
| 89 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &zip_download)); | 91 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &zip_download)); |
| 90 zip_download = zip_download.AppendASCII("zip").AppendASCII("test.zip"); | 92 zip_download = zip_download.AppendASCII("zip").AppendASCII("test.zip"); |
| 91 ASSERT_TRUE(file_util::PathExists(zip_download)); | 93 ASSERT_TRUE(file_util::PathExists(zip_download)); |
| 92 GURL zip_url = net::FilePathToFileURL(zip_download); | 94 GURL zip_url = net::FilePathToFileURL(zip_download); |
| 93 | 95 |
| 94 ui_test_utils::NavigateToURL(browser(), downloads_url); | 96 ui_test_utils::NavigateToURL(browser(), downloads_url); |
| 95 TabContents *contents = browser()->GetSelectedTabContents(); | 97 TabContents *contents = browser()->GetSelectedTabContents(); |
| 96 ASSERT_TRUE(contents); | 98 ASSERT_TRUE(contents); |
| 97 bool result = false; | 99 bool result = false; |
| 98 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 100 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| 99 contents->render_view_host(), | 101 contents->render_view_host(), |
| 100 L"", | 102 L"", |
| 101 L"window.onunload = function() { var do_nothing = 0; }; " | 103 L"window.onunload = function() { var do_nothing = 0; }; " |
| 102 L"window.domAutomationController.send(true);", | 104 L"window.domAutomationController.send(true);", |
| 103 &result)); | 105 &result)); |
| 104 EXPECT_TRUE(result); | 106 EXPECT_TRUE(result); |
| 105 ui_test_utils::NavigateToURL(browser(), zip_url); | 107 ui_test_utils::NavigateToURL(browser(), zip_url); |
| 106 | 108 |
| 107 ui_test_utils::WaitForDownloadCount( | 109 ui_test_utils::WaitForDownloadCount( |
| 108 browser()->profile()->GetDownloadManager(), 1); | 110 browser()->profile()->GetDownloadManager(), 1); |
| 109 | 111 |
| 110 browser()->CloseWindow(); | 112 browser()->CloseWindow(); |
| 111 BrowserClosedObserver wait_for_close(browser()); | 113 BrowserClosedObserver wait_for_close(browser()); |
| 112 } | 114 } |
| OLD | NEW |