summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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()