| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import os | 6 import os |
| 7 import logging | 7 import logging |
| 8 | 8 |
| 9 import pyauto_functional # Must be imported before pyauto | 9 import pyauto_functional # Must be imported before pyauto |
| 10 import pyauto | 10 import pyauto |
| 11 | 11 import test_utils |
| 12 | 12 |
| 13 class PopupsTest(pyauto.PyUITest): | 13 class PopupsTest(pyauto.PyUITest): |
| 14 """TestCase for Popup blocking.""" | 14 """TestCase for Popup blocking.""" |
| 15 | 15 |
| 16 def Debug(self): | 16 def Debug(self): |
| 17 """Test method for experimentation. | 17 """Test method for experimentation. |
| 18 | 18 |
| 19 This method will not run automatically. | 19 This method will not run automatically. |
| 20 """ | 20 """ |
| 21 import pprint | 21 import pprint |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 """Verify popups are launched when closing a tab.""" | 134 """Verify popups are launched when closing a tab.""" |
| 135 self._SetPopupsException() | 135 self._SetPopupsException() |
| 136 self.AppendTab(pyauto.GURL('http://www.popuptest.com/popuptest12.html')) | 136 self.AppendTab(pyauto.GURL('http://www.popuptest.com/popuptest12.html')) |
| 137 self.assertEqual(4, self.GetBrowserWindowCount(), | 137 self.assertEqual(4, self.GetBrowserWindowCount(), |
| 138 msg='Popups did not launch from the external site.') | 138 msg='Popups did not launch from the external site.') |
| 139 self.GetBrowserWindow(0).GetTab(1).Close(True) | 139 self.GetBrowserWindow(0).GetTab(1).Close(True) |
| 140 # Check if last popup is launched when the tab is closed. | 140 # Check if last popup is launched when the tab is closed. |
| 141 self.assertEqual(5, self.GetBrowserWindowCount(), | 141 self.assertEqual(5, self.GetBrowserWindowCount(), |
| 142 msg='Last popup did not launch when the tab is closed.') | 142 msg='Last popup did not launch when the tab is closed.') |
| 143 | 143 |
| 144 def testUnblockedPopupShowsInHistory(self): |
| 145 """Verify that when you unblock popup, the popup shows in history.""" |
| 146 file_url = self.GetFileURLForDataPath('popup_blocker', |
| 147 'popup-window-open.html') |
| 148 self.NavigateToURL(file_url) |
| 149 self.assertEqual(1, len(self.GetBlockedPopupsInfo())) |
| 150 self.UnblockAndLaunchBlockedPopup(0) |
| 151 history = self.GetHistoryInfo().History() |
| 152 self.assertEqual(2, len(history)) |
| 153 self.assertEqual('Popup Success!', history[0]['title']) |
| 154 |
| 155 def testBlockedPopupNotShowInHistory(self): |
| 156 """Verify that a blocked popup does not show up in history.""" |
| 157 file_url = self.GetFileURLForDataPath('popup_blocker', |
| 158 'popup-window-open.html') |
| 159 self.NavigateToURL(file_url) |
| 160 self.assertEqual(1, len(self.GetBlockedPopupsInfo())) |
| 161 self.assertEqual(1, len(self.GetHistoryInfo().History())) |
| 162 |
| 163 def testUnblockedPopupAddedToOmnibox(self): |
| 164 """Verify that an unblocked popup shows up in omnibox suggestions.""" |
| 165 file_url = self.GetFileURLForDataPath('popup_blocker', |
| 166 'popup-window-open.html') |
| 167 self.NavigateToURL(file_url) |
| 168 self.assertEqual(1, len(self.GetBlockedPopupsInfo())) |
| 169 self.UnblockAndLaunchBlockedPopup(0) |
| 170 search_string = 'data:text/html,<title>Popup Success!</title> \ |
| 171 you should not see this message if popup blocker is enabled' |
| 172 matches = test_utils.GetOmniboxMatchesFor(self, search_string) |
| 173 self.assertEqual(search_string, matches[0]['destination_url']) |
| 174 self.assertEqual(search_string, matches[0]['contents']) |
| 175 |
| 144 | 176 |
| 145 if __name__ == '__main__': | 177 if __name__ == '__main__': |
| 146 pyauto_functional.Main() | 178 pyauto_functional.Main() |
| OLD | NEW |