| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 116 |
| 117 def testPopupsLaunchUponBrowserBackButton(self): | 117 def testPopupsLaunchUponBrowserBackButton(self): |
| 118 """Verify that popups are launched on browser back button.""" | 118 """Verify that popups are launched on browser back button.""" |
| 119 self._SetPopupsException() | 119 self._SetPopupsException() |
| 120 url = self.GetHttpURLForDataPath( | 120 url = self.GetHttpURLForDataPath( |
| 121 os.path.join('popup_blocker', 'popup-blocked-to-post-blank.html')) | 121 os.path.join('popup_blocker', 'popup-blocked-to-post-blank.html')) |
| 122 self.NavigateToURL(url) | 122 self.NavigateToURL(url) |
| 123 self.NavigateToURL('http://www.popuptest.com/popuptest1.html') | 123 self.NavigateToURL('http://www.popuptest.com/popuptest1.html') |
| 124 self.assertEqual(7, self.GetBrowserWindowCount(), | 124 self.assertEqual(7, self.GetBrowserWindowCount(), |
| 125 msg='Popups did not launch from the external site.') | 125 msg='Popups did not launch from the external site.') |
| 126 self.GetBrowserWindow(0).GetTab(0).GoBack() | 126 self.TabGoBack() |
| 127 # Check if two additional popups launch when navigating away from the page. | 127 # Check if two additional popups launch when navigating away from the page. |
| 128 self.assertEqual(9, self.GetBrowserWindowCount(), | 128 self.assertEqual(9, self.GetBrowserWindowCount(), |
| 129 msg='Additional popups did not launch.') | 129 msg='Additional popups did not launch.') |
| 130 | 130 |
| 131 def testPopupsLaunchWhenTabIsClosed(self): | 131 def testPopupsLaunchWhenTabIsClosed(self): |
| 132 """Verify popups are launched when closing a tab.""" | 132 """Verify popups are launched when closing a tab.""" |
| 133 self._SetPopupsException() | 133 self._SetPopupsException() |
| 134 self.AppendTab(pyauto.GURL('http://www.popuptest.com/popuptest12.html')) | 134 self.AppendTab(pyauto.GURL('http://www.popuptest.com/popuptest12.html')) |
| 135 self.assertEqual(4, self.GetBrowserWindowCount(), | 135 self.assertEqual(4, self.GetBrowserWindowCount(), |
| 136 msg='Popups did not launch from the external site.') | 136 msg='Popups did not launch from the external site.') |
| 137 self.GetBrowserWindow(0).GetTab(1).Close(True) | 137 self.CloseTab(tab_index=1) |
| 138 # Check if last popup is launched when the tab is closed. | 138 # Check if last popup is launched when the tab is closed. |
| 139 self.assertEqual(5, self.GetBrowserWindowCount(), | 139 self.assertEqual(5, self.GetBrowserWindowCount(), |
| 140 msg='Last popup did not launch when the tab is closed.') | 140 msg='Last popup did not launch when the tab is closed.') |
| 141 | 141 |
| 142 def testUnblockedPopupShowsInHistory(self): | 142 def testUnblockedPopupShowsInHistory(self): |
| 143 """Verify that when you unblock popup, the popup shows in history.""" | 143 """Verify that when you unblock popup, the popup shows in history.""" |
| 144 file_url = self.GetFileURLForDataPath('popup_blocker', | 144 file_url = self.GetFileURLForDataPath('popup_blocker', |
| 145 'popup-window-open.html') | 145 'popup-window-open.html') |
| 146 self.NavigateToURL(file_url) | 146 self.NavigateToURL(file_url) |
| 147 self.assertEqual(1, len(self.GetBlockedPopupsInfo())) | 147 self.assertEqual(1, len(self.GetBlockedPopupsInfo())) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 168 self.UnblockAndLaunchBlockedPopup(0) | 168 self.UnblockAndLaunchBlockedPopup(0) |
| 169 search_string = 'data:text/html,<title>Popup Success!</title> \ | 169 search_string = 'data:text/html,<title>Popup Success!</title> \ |
| 170 you should not see this message if popup blocker is enabled' | 170 you should not see this message if popup blocker is enabled' |
| 171 matches = test_utils.GetOmniboxMatchesFor(self, search_string) | 171 matches = test_utils.GetOmniboxMatchesFor(self, search_string) |
| 172 self.assertEqual(search_string, matches[0]['destination_url']) | 172 self.assertEqual(search_string, matches[0]['destination_url']) |
| 173 self.assertEqual(search_string, matches[0]['contents']) | 173 self.assertEqual(search_string, matches[0]['contents']) |
| 174 | 174 |
| 175 | 175 |
| 176 if __name__ == '__main__': | 176 if __name__ == '__main__': |
| 177 pyauto_functional.Main() | 177 pyauto_functional.Main() |
| OLD | NEW |