diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-28 15:09:27 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-28 15:09:27 +0000 |
commit | abf159184a29aaa95784ac0726b4f919be155433 (patch) | |
tree | f89990ba1eb21b4b43410a450768833338453fe9 | |
parent | 0c656520f1955f2b6a9920979977500021ee62c8 (diff) | |
download | chromium_src-abf159184a29aaa95784ac0726b4f919be155433.zip chromium_src-abf159184a29aaa95784ac0726b4f919be155433.tar.gz chromium_src-abf159184a29aaa95784ac0726b4f919be155433.tar.bz2 |
Add a browser-test for downloading an anchor with a suggested name for download.
BUG=89346
TEST=DownloadTest.AnchorDownloadTag
Review URL: http://codereview.chromium.org/7484063
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@94460 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/download/download_browsertest.cc | 18 | ||||
-rw-r--r-- | chrome/test/data/download-anchor-attrib.html | 13 |
2 files changed, 31 insertions, 0 deletions
diff --git a/chrome/browser/download/download_browsertest.cc b/chrome/browser/download/download_browsertest.cc index 9141cb8..bdcc1f3 100644 --- a/chrome/browser/download/download_browsertest.cc +++ b/chrome/browser/download/download_browsertest.cc @@ -1548,6 +1548,24 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, DISABLED_BrowserCloseAfterDownload) { signal.Wait(); } +// Test to make sure the 'download' attribute in anchor tag is respected. +IN_PROC_BROWSER_TEST_F(DownloadTest, AnchorDownloadTag) { + ASSERT_TRUE(InitialSetup(false)); + FilePath file(FILE_PATH_LITERAL("download-anchor-attrib.html")); + GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); + + // Create a download, wait until it's complete, and confirm + // we're in the expected state. + scoped_ptr<DownloadsObserver> observer(CreateWaiter(browser(), 1)); + ui_test_utils::NavigateToURL(browser(), url); + observer->WaitForFinished(); + + // Confirm the downloaded data exists. + FilePath downloaded_file = GetDownloadDirectory(browser()); + downloaded_file = downloaded_file.Append(FILE_PATH_LITERAL("a_red_dot.png")); + EXPECT_TRUE(file_util::PathExists(downloaded_file)); +} + // Test to make sure auto-open works. IN_PROC_BROWSER_TEST_F(DownloadTest, AutoOpen) { ASSERT_TRUE(InitialSetup(false)); diff --git a/chrome/test/data/download-anchor-attrib.html b/chrome/test/data/download-anchor-attrib.html new file mode 100644 index 0000000..142679e --- /dev/null +++ b/chrome/test/data/download-anchor-attrib.html @@ -0,0 +1,13 @@ +<html> +<head><title>Download Test for <a download></title></head> +<body> +<a id='red-dot' href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" download='a_red_dot.png'>Download Red Dot!</a> +<script> +window.setTimeout(function() { + var evt = document.createEvent("MouseEvent"); + evt.initMouseEvent('click', true, true); + document.getElementById('red-dot').dispatchEvent(evt); +}, 0); +</script> +</body> +</html> |