summaryrefslogtreecommitdiffstats
path: root/chrome/test/functional
diff options
context:
space:
mode:
authordyu@chromium.org <dyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-11 21:14:54 +0000
committerdyu@chromium.org <dyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-11 21:14:54 +0000
commit37d2886aa92d99c525cf1a55ae3bc949bd017deb (patch)
treed1dec93af1625d279305106f0dcd48169153da40 /chrome/test/functional
parent9539c03e4038f10d1c6f5ae4914e2f0b19013ab9 (diff)
downloadchromium_src-37d2886aa92d99c525cf1a55ae3bc949bd017deb.zip
chromium_src-37d2886aa92d99c525cf1a55ae3bc949bd017deb.tar.gz
chromium_src-37d2886aa92d99c525cf1a55ae3bc949bd017deb.tar.bz2
Added five Popup Blocker tests.
- testMultiplePopups - verify that multiple popups are blocked. - testPopupBlockedEverySec - Verify that popups launched are blocked every second. - testPopupsLaunchWhenBrowserBackButton - Verify that popups are launched when the browser back button is pressed. - testBlockPopupsFromExternalSite - Verify popups are blocked from an external site. - testPopupsLaunchWhenTabIsClosed - Verify that popups are launched when leaving a page. TEST=none BUG=none Review URL: http://codereview.chromium.org/6820006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81153 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/functional')
-rw-r--r--chrome/test/functional/popups.py56
1 files changed, 55 insertions, 1 deletions
diff --git a/chrome/test/functional/popups.py b/chrome/test/functional/popups.py
index 0a95800..229b9e2 100644
--- a/chrome/test/functional/popups.py
+++ b/chrome/test/functional/popups.py
@@ -1,5 +1,4 @@
#!/usr/bin/python
-
# Copyright (c) 2010 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -92,6 +91,61 @@ class PopupsTest(pyauto.PyUITest):
msg='Popup could not be launched');
self.assertEqual('Popup Success!', self.GetActiveTabTitle(2))
+ def testMultiplePopups(self):
+ """Verify multiple popups are blocked."""
+ url = self.GetHttpURLForDataPath(
+ os.path.join('pyauto_private', 'popup_blocker',
+ 'PopupTest1.html'))
+ self.NavigateToURL(url)
+ self.assertEqual(6, len(self.GetBlockedPopupsInfo()),
+ msg='Did not block 6 popups.')
+
+ def testPopupBlockedEverySec(self):
+ """Verify that a popup is blocked every second."""
+ url = self.GetHttpURLForDataPath(
+ os.path.join('pyauto_private', 'popup_blocker',
+ 'PopupTest4.html'))
+ self.NavigateToURL(url)
+ self.assertTrue(self.WaitUntil(lambda: len(self.GetBlockedPopupsInfo()),
+ expect_retval=2))
+
+ def _SetPopupsException(self):
+ """Set an exception to allow popups from www.popuptest.com."""
+ value = {'[*.]www.popuptest.com': {'popups': 1}}
+ return self.SetPrefs(pyauto.kContentSettingsPatterns, value)
+
+ def testAllowPopupsFromExternalSite(self):
+ """Verify that popups are allowed from an external website."""
+ self._SetPopupsException()
+ self.NavigateToURL('http://www.popuptest.com/popuptest1.html')
+ self.assertEqual(7, self.GetBrowserWindowCount(),
+ msg='Popups did not launch from the external site.')
+
+ def testPopupsLaunchUponBrowserBackButton(self):
+ """Verify that popups are launched on browser back button."""
+ self._SetPopupsException()
+ url = self.GetHttpURLForDataPath(
+ os.path.join('popup_blocker', 'popup-blocked-to-post-blank.html'))
+ self.NavigateToURL(url)
+ self.NavigateToURL('http://www.popuptest.com/popuptest1.html')
+ self.assertEqual(7, self.GetBrowserWindowCount(),
+ msg='Popups did not launch from the external site.')
+ self.GetBrowserWindow(0).GetTab(0).GoBack()
+ # Check if two additional popups launch when navigating away from the page.
+ self.assertEqual(9, self.GetBrowserWindowCount(),
+ msg='Additional popups did not launch.')
+
+ def testPopupsLaunchWhenTabIsClosed(self):
+ """Verify popups are launched when closing a tab."""
+ self._SetPopupsException()
+ self.AppendTab(pyauto.GURL('http://www.popuptest.com/popuptest12.html'))
+ self.assertEqual(4, self.GetBrowserWindowCount(),
+ msg='Popups did not launch from the external site.')
+ self.GetBrowserWindow(0).GetTab(1).Close(True)
+ # Check if last popup is launched when the tab is closed.
+ self.assertEqual(5, self.GetBrowserWindowCount(),
+ msg='Last popup did not launch when the tab is closed.')
+
if __name__ == '__main__':
pyauto_functional.Main()