| 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 <sstream> | 5 #include <sstream> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1165 // We should still have 2 windows. | 1165 // We should still have 2 windows. |
| 1166 ExpectWindowCountAfterDownload(2); | 1166 ExpectWindowCountAfterDownload(2); |
| 1167 | 1167 |
| 1168 // Verify that the download shelf is showing for the Incognito window. | 1168 // Verify that the download shelf is showing for the Incognito window. |
| 1169 EXPECT_TRUE(incognito->window()->IsDownloadShelfVisible()); | 1169 EXPECT_TRUE(incognito->window()->IsDownloadShelfVisible()); |
| 1170 | 1170 |
| 1171 #if !defined(OS_MACOSX) | 1171 #if !defined(OS_MACOSX) |
| 1172 // On Mac OS X, the UI window close is delayed until the outermost | 1172 // On Mac OS X, the UI window close is delayed until the outermost |
| 1173 // message loop runs. So it isn't possible to get a BROWSER_CLOSED | 1173 // message loop runs. So it isn't possible to get a BROWSER_CLOSED |
| 1174 // notification inside of a test. | 1174 // notification inside of a test. |
| 1175 ui_test_utils::WindowedNotificationObserver signal( | 1175 content::WindowedNotificationObserver signal( |
| 1176 chrome::NOTIFICATION_BROWSER_CLOSED, | 1176 chrome::NOTIFICATION_BROWSER_CLOSED, |
| 1177 content::Source<Browser>(incognito)); | 1177 content::Source<Browser>(incognito)); |
| 1178 #endif | 1178 #endif |
| 1179 | 1179 |
| 1180 // Close the Incognito window and don't crash. | 1180 // Close the Incognito window and don't crash. |
| 1181 chrome::CloseWindow(incognito); | 1181 chrome::CloseWindow(incognito); |
| 1182 | 1182 |
| 1183 #if !defined(OS_MACOSX) | 1183 #if !defined(OS_MACOSX) |
| 1184 signal.Wait(); | 1184 signal.Wait(); |
| 1185 ExpectWindowCountAfterDownload(1); | 1185 ExpectWindowCountAfterDownload(1); |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1408 ui_test_utils::GetBrowserNotInSet(original_browsers); | 1408 ui_test_utils::GetBrowserNotInSet(original_browsers); |
| 1409 ASSERT_TRUE(download_browser != NULL); | 1409 ASSERT_TRUE(download_browser != NULL); |
| 1410 EXPECT_NE(download_browser, browser()); | 1410 EXPECT_NE(download_browser, browser()); |
| 1411 EXPECT_EQ(1, download_browser->tab_count()); | 1411 EXPECT_EQ(1, download_browser->tab_count()); |
| 1412 EXPECT_TRUE(download_browser->window()->IsDownloadShelfVisible()); | 1412 EXPECT_TRUE(download_browser->window()->IsDownloadShelfVisible()); |
| 1413 | 1413 |
| 1414 #if !defined(OS_MACOSX) | 1414 #if !defined(OS_MACOSX) |
| 1415 // On Mac OS X, the UI window close is delayed until the outermost | 1415 // On Mac OS X, the UI window close is delayed until the outermost |
| 1416 // message loop runs. So it isn't possible to get a BROWSER_CLOSED | 1416 // message loop runs. So it isn't possible to get a BROWSER_CLOSED |
| 1417 // notification inside of a test. | 1417 // notification inside of a test. |
| 1418 ui_test_utils::WindowedNotificationObserver signal( | 1418 content::WindowedNotificationObserver signal( |
| 1419 chrome::NOTIFICATION_BROWSER_CLOSED, | 1419 chrome::NOTIFICATION_BROWSER_CLOSED, |
| 1420 content::Source<Browser>(download_browser)); | 1420 content::Source<Browser>(download_browser)); |
| 1421 #endif | 1421 #endif |
| 1422 | 1422 |
| 1423 // Close the new window. | 1423 // Close the new window. |
| 1424 chrome::CloseWindow(download_browser); | 1424 chrome::CloseWindow(download_browser); |
| 1425 | 1425 |
| 1426 #if !defined(OS_MACOSX) | 1426 #if !defined(OS_MACOSX) |
| 1427 signal.Wait(); | 1427 signal.Wait(); |
| 1428 EXPECT_EQ(first_browser, browser()); | 1428 EXPECT_EQ(first_browser, browser()); |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1630 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 1630 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| 1631 contents->GetRenderViewHost(), | 1631 contents->GetRenderViewHost(), |
| 1632 L"", | 1632 L"", |
| 1633 L"window.onunload = function() { var do_nothing = 0; }; " | 1633 L"window.onunload = function() { var do_nothing = 0; }; " |
| 1634 L"window.domAutomationController.send(true);", | 1634 L"window.domAutomationController.send(true);", |
| 1635 &result)); | 1635 &result)); |
| 1636 EXPECT_TRUE(result); | 1636 EXPECT_TRUE(result); |
| 1637 | 1637 |
| 1638 DownloadAndWait(browser(), download_url, EXPECT_NO_SELECT_DIALOG); | 1638 DownloadAndWait(browser(), download_url, EXPECT_NO_SELECT_DIALOG); |
| 1639 | 1639 |
| 1640 ui_test_utils::WindowedNotificationObserver signal( | 1640 content::WindowedNotificationObserver signal( |
| 1641 chrome::NOTIFICATION_BROWSER_CLOSED, | 1641 chrome::NOTIFICATION_BROWSER_CLOSED, |
| 1642 content::Source<Browser>(browser())); | 1642 content::Source<Browser>(browser())); |
| 1643 chrome::CloseWindow(browser()); | 1643 chrome::CloseWindow(browser()); |
| 1644 signal.Wait(); | 1644 signal.Wait(); |
| 1645 } | 1645 } |
| 1646 | 1646 |
| 1647 // Test to make sure the 'download' attribute in anchor tag is respected. | 1647 // Test to make sure the 'download' attribute in anchor tag is respected. |
| 1648 IN_PROC_BROWSER_TEST_F(DownloadTest, AnchorDownloadTag) { | 1648 IN_PROC_BROWSER_TEST_F(DownloadTest, AnchorDownloadTag) { |
| 1649 FilePath file(FILE_PATH_LITERAL("download-anchor-attrib.html")); | 1649 FilePath file(FILE_PATH_LITERAL("download-anchor-attrib.html")); |
| 1650 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | 1650 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2111 ASSERT_TRUE(form_url.is_valid()); | 2111 ASSERT_TRUE(form_url.is_valid()); |
| 2112 ui_test_utils::NavigateToURL(browser(), form_url); | 2112 ui_test_utils::NavigateToURL(browser(), form_url); |
| 2113 | 2113 |
| 2114 // Submit the form. This will send a POST reqeuest, and the response is a | 2114 // Submit the form. This will send a POST reqeuest, and the response is a |
| 2115 // JPEG image. The resource also has Cache-Control: no-cache set, | 2115 // JPEG image. The resource also has Cache-Control: no-cache set, |
| 2116 // which normally requires revalidation each time. | 2116 // which normally requires revalidation each time. |
| 2117 GURL jpeg_url = test_server()->GetURL("files/post/downloads/image.jpg"); | 2117 GURL jpeg_url = test_server()->GetURL("files/post/downloads/image.jpg"); |
| 2118 ASSERT_TRUE(jpeg_url.is_valid()); | 2118 ASSERT_TRUE(jpeg_url.is_valid()); |
| 2119 WebContents* web_contents = chrome::GetActiveWebContents(browser()); | 2119 WebContents* web_contents = chrome::GetActiveWebContents(browser()); |
| 2120 ASSERT_TRUE(web_contents != NULL); | 2120 ASSERT_TRUE(web_contents != NULL); |
| 2121 ui_test_utils::WindowedNotificationObserver observer( | 2121 content::WindowedNotificationObserver observer( |
| 2122 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 2122 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 2123 content::Source<content::NavigationController>( | 2123 content::Source<content::NavigationController>( |
| 2124 &web_contents->GetController())); | 2124 &web_contents->GetController())); |
| 2125 content::RenderViewHost* render_view_host = web_contents->GetRenderViewHost(); | 2125 content::RenderViewHost* render_view_host = web_contents->GetRenderViewHost(); |
| 2126 ASSERT_TRUE(render_view_host != NULL); | 2126 ASSERT_TRUE(render_view_host != NULL); |
| 2127 render_view_host->ExecuteJavascriptInWebFrame( | 2127 render_view_host->ExecuteJavascriptInWebFrame( |
| 2128 string16(), ASCIIToUTF16("SubmitForm()")); | 2128 string16(), ASCIIToUTF16("SubmitForm()")); |
| 2129 observer.Wait(); | 2129 observer.Wait(); |
| 2130 EXPECT_EQ(jpeg_url, web_contents->GetURL()); | 2130 EXPECT_EQ(jpeg_url, web_contents->GetURL()); |
| 2131 | 2131 |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2496 GetDownloads(browser(), &download_items); | 2496 GetDownloads(browser(), &download_items); |
| 2497 ASSERT_EQ(1u, download_items.size()); | 2497 ASSERT_EQ(1u, download_items.size()); |
| 2498 ASSERT_EQ(test_server()->GetURL("echoheader?Referer"), | 2498 ASSERT_EQ(test_server()->GetURL("echoheader?Referer"), |
| 2499 download_items[0]->GetOriginalUrl()); | 2499 download_items[0]->GetOriginalUrl()); |
| 2500 | 2500 |
| 2501 // Check that the file contains the expected referrer. | 2501 // Check that the file contains the expected referrer. |
| 2502 FilePath file(download_items[0]->GetFullPath()); | 2502 FilePath file(download_items[0]->GetFullPath()); |
| 2503 std::string expected_contents = test_server()->GetURL("").spec(); | 2503 std::string expected_contents = test_server()->GetURL("").spec(); |
| 2504 ASSERT_TRUE(VerifyFile(file, expected_contents, expected_contents.length())); | 2504 ASSERT_TRUE(VerifyFile(file, expected_contents, expected_contents.length())); |
| 2505 } | 2505 } |
| OLD | NEW |