Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(579)

Side by Side Diff: functional/browser.py

Issue 5322012: Adding tests to browser.py... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/test/
Patch Set: '' Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 re 7 import re
8 import types 8 import types
9 9
10 import pyauto_functional # Must be imported before pyauto 10 import pyauto_functional # Must be imported before pyauto
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 """Verify that reloading of renderer is possible, 167 """Verify that reloading of renderer is possible,
168 after renderer is killed""" 168 after renderer is killed"""
169 test_url = self.GetFileURLForDataPath('english_page.html') 169 test_url = self.GetFileURLForDataPath('english_page.html')
170 self.NavigateToURL(test_url) 170 self.NavigateToURL(test_url)
171 pid1 = self.GetBrowserInfo()['windows'][0]['tabs'][0]['renderer_pid'] 171 pid1 = self.GetBrowserInfo()['windows'][0]['tabs'][0]['renderer_pid']
172 self.KillRendererProcess(pid1) 172 self.KillRendererProcess(pid1)
173 self.ReloadActiveTab() 173 self.ReloadActiveTab()
174 pid2 = self.GetBrowserInfo()['windows'][0]['tabs'][0]['renderer_pid'] 174 pid2 = self.GetBrowserInfo()['windows'][0]['tabs'][0]['renderer_pid']
175 self.assertNotEqual(pid1, pid2) 175 self.assertNotEqual(pid1, pid2)
176 176
177 def testPopupSharesProcess(self):
178 """Verify that parent tab and popup share a process."""
179 file_url = self.GetFileURLForPath(os.path.join(
180 self.DataDir(), 'popup_blocker', 'popup-blocked-to-post-blank.html'))
181 self.NavigateToURL(file_url)
182 blocked_popups = self.GetBlockedPopupsInfo()
183 self.assertEqual(1, len(blocked_popups), msg='Popup not blocked')
184 self.UnblockAndLaunchBlockedPopup(0)
185 self.assertEquals(2, self.GetBrowserWindowCount())
186 parent_pid = self.GetBrowserInfo()['windows'][0]['tabs'][0]['renderer_pid']
187 popup_pid = self.GetBrowserInfo()['windows'][1]['tabs'][0]['renderer_pid']
188 self.assertEquals(popup_pid, parent_pid,
189 msg='Parent and popup are not sharing a process.')
190
191 def testKillAndReloadSharedProcess(self):
192 """Verify that killing a shared process kills all associated renderers.
193 In this case we are killing a process shared by a parent and
194 its popup process. Reloading both should share a process again.
195 """
196 file_url = self.GetFileURLForPath(os.path.join(
197 self.DataDir(), 'popup_blocker', 'popup-blocked-to-post-blank.html'))
198 self.NavigateToURL(file_url)
199 blocked_popups = self.GetBlockedPopupsInfo()
200 self.assertEqual(1, len(blocked_popups), msg='Popup not blocked')
201 self.UnblockAndLaunchBlockedPopup(0)
202 self.assertEquals(2, self.GetBrowserWindowCount())
203 # Check that the renderers are alive.
204 self.assertEquals(1, self.FindInPage('pop-up')['match_count'])
205 self.assertEquals(1,
206 self.FindInPage('popup', tab_index=0, windex=1)['match_count'])
207 # Check if they are sharing a process id.
208 self.assertEquals(
209 self.GetBrowserInfo()['windows'][0]['tabs'][0]['renderer_pid'],
210 self.GetBrowserInfo()['windows'][1]['tabs'][0]['renderer_pid'])
211 shared_pid = self.GetBrowserInfo()['windows'][0]['tabs'][0]['renderer_pid']
212 # This method would fail if the renderers are not killed.
213 self.KillRendererProcess(shared_pid)
214
215 # Reload the parent and popup windows.
216 self.GetBrowserWindow(0).GetTab(0).Reload()
217 self.GetBrowserWindow(1).GetTab(0).Reload()
218 # Check if they are sharing a process id.
219 self.assertEquals(
220 self.GetBrowserInfo()['windows'][0]['tabs'][0]['renderer_pid'],
221 self.GetBrowserInfo()['windows'][1]['tabs'][0]['renderer_pid'])
222 # The shared process id should be different from the previous one.
223 self.assertNotEqual(shared_pid,
224 self.GetBrowserInfo()['windows'][0]['tabs'][0]['renderer_pid'])
225
177 226
178 if __name__ == '__main__': 227 if __name__ == '__main__':
179 pyauto_functional.Main() 228 pyauto_functional.Main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698