diff options
author | nirnimesh@chromium.org <nirnimesh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-14 01:54:51 +0000 |
---|---|---|
committer | nirnimesh@chromium.org <nirnimesh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-14 01:54:51 +0000 |
commit | e92f3dff4931412216fc2342c1a5205a5c7ff58f (patch) | |
tree | 6df24c30884b46256792388b4092889d5cb54e86 /chrome/test/functional | |
parent | 4d816991deb2b66c94cc451b1c5d4bcbe7d5ff92 (diff) | |
download | chromium_src-e92f3dff4931412216fc2342c1a5205a5c7ff58f.zip chromium_src-e92f3dff4931412216fc2342c1a5205a5c7ff58f.tar.gz chromium_src-e92f3dff4931412216fc2342c1a5205a5c7ff58f.tar.bz2 |
Fix pyauto downloads tests to trigger dangerous downloads to match expectation
It used to be possible to navigate to a dnagerous file type to trigger its
download. Not anymore. Now all downloads where the user initiated it (by
navigating to a URL or clicking on a link) are not marked unsafe even for
unsafe filetypes.
Update the tests to trigger dangerous downloads by navigating to a file which
in turn triggers the dangerous files to download.
BUG=66081, 57875
Review URL: http://codereview.chromium.org/5781006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69093 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/functional')
-rw-r--r-- | chrome/test/functional/PYAUTO_TESTS | 14 | ||||
-rw-r--r-- | chrome/test/functional/downloads.py | 41 |
2 files changed, 32 insertions, 23 deletions
diff --git a/chrome/test/functional/PYAUTO_TESTS b/chrome/test/functional/PYAUTO_TESTS index c4e08b1..b5950d1 100644 --- a/chrome/test/functional/PYAUTO_TESTS +++ b/chrome/test/functional/PYAUTO_TESTS @@ -80,9 +80,6 @@ # crbug.com/50481, crbug.com/54942 '-downloads.DownloadsTest.testZip', '-downloads.DownloadsTest.testRemoveDownload', - # Unsafe downloads tests broken. crbug.com/66081 - '-downloads.DownloadsTest.testDeclineDangerousDownload', - '-downloads.DownloadsTest.testNoUnsafeDownloadsOnRestart', '-prefs.PrefsTest.testDownloadDirPref', # crbug.com/64269 '-passwords.PasswordTest.testDisplayAndSavePasswordInfobar', @@ -95,10 +92,6 @@ # codesign tests should run *after* signing. crbug.com/50481 '-codesign', '-content.ContentTest.testThreeWindows', # crbug.com/47457 - '-downloads.DownloadsTest.testSaveDangerousFile', # crbug.com/57875 - # Unsafe downloads tests broken. crbug.com/66081 - '-downloads.DownloadsTest.testDeclineDangerousDownload', - '-downloads.DownloadsTest.testNoUnsafeDownloadsOnRestart', ], 'linux': [ # linux != chromeos @@ -107,10 +100,6 @@ '-content.ContentTest.testThreeWindows', # crbug.com/47457 # crbug.com/64664 '-databases.DatabasesTest.testReloadActiveTab', - # Unsafe downloads tests broken. crbug.com/66081 - '-downloads.DownloadsTest.testDeclineDangerousDownload', - '-downloads.DownloadsTest.testNoUnsafeDownloadsOnRestart', - '-downloads.DownloadsTest.testSaveDangerousFile', # crbug.com/64269 '-passwords.PasswordTest.testDisplayAndSavePasswordInfobar', ], @@ -148,8 +137,5 @@ '-crash_reporter.CrashReporterTest.testRendererCrash', # crbug.com/64269 '-passwords.PasswordTest.testDisplayAndSavePasswordInfobar', - # Unsafe downloads tests broken. crbug.com/66081 - '-downloads.DownloadsTest.testDeclineDangerousDownload', - '-downloads.DownloadsTest.testSaveDangerousFile', ], } diff --git a/chrome/test/functional/downloads.py b/chrome/test/functional/downloads.py index 355f676..715ee57 100644 --- a/chrome/test/functional/downloads.py +++ b/chrome/test/functional/downloads.py @@ -61,7 +61,7 @@ class DownloadsTest(pyauto.PyUITest): os.path.exists(crdownload) and os.remove(crdownload) def _GetDangerousDownload(self): - """Returns the file url for a dangerous download for this OS.""" + """Returns the file path for a dangerous download for this OS.""" sub_path = os.path.join(self.DataDir(), 'downloads', 'dangerous') if self.IsMac(): return os.path.join(sub_path, 'invalid-dummy.dmg') @@ -158,12 +158,10 @@ class DownloadsTest(pyauto.PyUITest): def testSaveDangerousFile(self): """Verify that we can download and save a dangerous file.""" file_path = self._GetDangerousDownload() - file_url = self.GetFileURLForPath(file_path) downloaded_pkg = os.path.join(self.GetDownloadDirectory().value(), os.path.basename(file_path)) self._ClearLocalDownloadState(downloaded_pkg) - - self.DownloadAndWaitForStart(file_url) + self._TriggerUnsafeDownload(os.path.basename(file_path)) self.PerformActionOnDownload(self._GetDownloadId(), 'save_dangerous_download') self.WaitForDownloadToComplete(downloaded_pkg) @@ -176,12 +174,10 @@ class DownloadsTest(pyauto.PyUITest): def testDeclineDangerousDownload(self): """Verify that we can decline dangerous downloads""" file_path = self._GetDangerousDownload() - file_url = self.GetFileURLForPath(file_path) downloaded_pkg = os.path.join(self.GetDownloadDirectory().value(), os.path.basename(file_path)) self._ClearLocalDownloadState(downloaded_pkg) - - self.DownloadAndWaitForStart(file_url) + self._TriggerUnsafeDownload(os.path.basename(file_path)) self.PerformActionOnDownload(self._GetDownloadId(), 'decline_dangerous_download') self.assertFalse(os.path.exists(downloaded_pkg)) @@ -307,14 +303,41 @@ class DownloadsTest(pyauto.PyUITest): os.path.join(temp_dir, filename))) os.path.exists(downloaded_file) and os.remove(downloaded_file) + def _TriggerUnsafeDownload(self, filename, tab_index=0, windex=0): + """Trigger download of an unsafe/dangerous filetype. + + Files explictly requested by the user (like navigating to a package, or + clicking on a link) aren't marked unsafe. + Only the ones where the user didn't directly initiate a download are + marked unsafe. + + Navigates to download-dangerous.html which triggers the download. + Waits until the download starts. + + Args: + filename: the name of the file to trigger the download. + This should exist in the 'dangerous' directory. + tab_index: tab index. Default 0. + windex: window index. Default 0. + """ + dangerous_dir = os.path.join( + self.DataDir(), 'downloads', 'dangerous') + assert os.path.isfile(os.path.join(dangerous_dir, filename)) + file_url = self.GetFileURLForDataPath(os.path.join( + dangerous_dir, 'download-dangerous.html')) + '?' + filename + num_downloads = len(self.GetDownloadsInfo().Downloads()) + self.NavigateToURL(file_url, windex, tab_index) + # It might take a while for the download to kick in, hold on until then. + self.assertTrue(self.WaitUntil( + lambda: len(self.GetDownloadsInfo().Downloads()) == num_downloads + 1)) + def testNoUnsafeDownloadsOnRestart(self): """Verify that unsafe file should not show up on session restart.""" file_path = self._GetDangerousDownload() - file_url = self.GetFileURLForPath(file_path) downloaded_pkg = os.path.join(self.GetDownloadDirectory().value(), os.path.basename(file_path)) self._ClearLocalDownloadState(downloaded_pkg) - self.DownloadAndWaitForStart(file_url) + self._TriggerUnsafeDownload(os.path.basename(file_path)) self.assertTrue(self.IsDownloadShelfVisible()) # Restart the browser and assert that the download was removed. self.RestartBrowser(clear_profile=False) |