Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 import os | 4 import os |
| 5 import time | 5 import time |
| 6 | 6 |
| 7 import context_lost_expectations | 7 import context_lost_expectations |
| 8 | 8 |
| 9 from telemetry import benchmark as benchmark_module | 9 from telemetry import benchmark as benchmark_module |
| 10 from telemetry.core import exceptions | 10 from telemetry.core import exceptions |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 | 59 |
| 60 def CustomizeBrowserOptions(self, options): | 60 def CustomizeBrowserOptions(self, options): |
| 61 options.AppendExtraBrowserArgs( | 61 options.AppendExtraBrowserArgs( |
| 62 '--disable-domain-blocking-for-3d-apis') | 62 '--disable-domain-blocking-for-3d-apis') |
| 63 options.AppendExtraBrowserArgs( | 63 options.AppendExtraBrowserArgs( |
| 64 '--disable-gpu-process-crash-limit') | 64 '--disable-gpu-process-crash-limit') |
| 65 # Required for about:gpucrash handling from Telemetry. | 65 # Required for about:gpucrash handling from Telemetry. |
| 66 options.AppendExtraBrowserArgs('--enable-gpu-benchmarking') | 66 options.AppendExtraBrowserArgs('--enable-gpu-benchmarking') |
| 67 | 67 |
| 68 def ValidateAndMeasurePage(self, page, tab, results): | 68 def ValidateAndMeasurePage(self, page, tab, results): |
| 69 def WaitForPageToFinish(): | |
| 70 print "Waiting for page to finish." | |
| 71 try: | |
| 72 util.WaitFor(lambda: tab.EvaluateJavaScript( | |
| 73 'window.domAutomationController._finished'), wait_timeout) | |
| 74 return True | |
| 75 except util.TimeoutException: | |
| 76 return False | |
| 77 | |
| 69 if page.kill_gpu_process: | 78 if page.kill_gpu_process: |
| 70 # Doing the GPU process kill operation cooperatively -- in the | 79 # Doing the GPU process kill operation cooperatively -- in the |
| 71 # same page's context -- is much more stressful than restarting | 80 # same page's context -- is much more stressful than restarting |
| 72 # the browser every time. | 81 # the browser every time. |
| 73 for x in range(page.number_of_gpu_process_kills): | 82 for x in range(page.number_of_gpu_process_kills): |
| 74 if not tab.browser.supports_tab_control: | 83 if not tab.browser.supports_tab_control: |
| 75 raise page_test.Failure('Browser must support tab control') | 84 raise page_test.Failure('Browser must support tab control') |
| 76 | 85 |
| 77 expected_kills = x + 1 | 86 expected_kills = x + 1 |
| 78 | 87 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 90 gpucrash_tab = tab.browser.tabs.New() | 99 gpucrash_tab = tab.browser.tabs.New() |
| 91 # To access these debug URLs from Telemetry, they have to be | 100 # To access these debug URLs from Telemetry, they have to be |
| 92 # written using the chrome:// scheme. | 101 # written using the chrome:// scheme. |
| 93 # The try/except is a workaround for crbug.com/368107. | 102 # The try/except is a workaround for crbug.com/368107. |
| 94 try: | 103 try: |
| 95 gpucrash_tab.Navigate('chrome://gpucrash') | 104 gpucrash_tab.Navigate('chrome://gpucrash') |
| 96 except (exceptions.TabCrashException, Exception): | 105 except (exceptions.TabCrashException, Exception): |
| 97 print 'Tab crashed while navigating to chrome://gpucrash' | 106 print 'Tab crashed while navigating to chrome://gpucrash' |
| 98 # Activate the original tab and wait for completion. | 107 # Activate the original tab and wait for completion. |
| 99 tab.Activate() | 108 tab.Activate() |
| 100 completed = False | 109 completed = WaitForPageToFinish() |
| 101 try: | |
| 102 util.WaitFor(lambda: tab.EvaluateJavaScript( | |
| 103 'window.domAutomationController._finished'), wait_timeout) | |
| 104 completed = True | |
| 105 except util.TimeoutException: | |
| 106 pass | |
| 107 | 110 |
| 108 if page.check_crash_count: | 111 if page.check_crash_count: |
| 109 if not tab.browser.supports_system_info: | 112 if not tab.browser.supports_system_info: |
| 110 raise page_test.Failure('Browser must support system info') | 113 raise page_test.Failure('Browser must support system info') |
| 111 | 114 |
| 112 if not tab.EvaluateJavaScript( | 115 if not tab.EvaluateJavaScript( |
| 113 'window.domAutomationController._succeeded'): | 116 'window.domAutomationController._succeeded'): |
| 114 raise page_test.Failure( | 117 raise page_test.Failure( |
| 115 'Test failed (didn\'t render content properly?)') | 118 'Test failed (didn\'t render content properly?)') |
| 116 | 119 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 153 'Test didn\'t complete (no context lost event?)') | 156 'Test didn\'t complete (no context lost event?)') |
| 154 if not tab.EvaluateJavaScript( | 157 if not tab.EvaluateJavaScript( |
| 155 'window.domAutomationController._succeeded'): | 158 'window.domAutomationController._succeeded'): |
| 156 raise page_test.Failure( | 159 raise page_test.Failure( |
| 157 'Test failed (context not restored properly?)') | 160 'Test failed (context not restored properly?)') |
| 158 elif page.force_garbage_collection: | 161 elif page.force_garbage_collection: |
| 159 # Try to corce GC to clean up any contexts not attached to the page. | 162 # Try to corce GC to clean up any contexts not attached to the page. |
| 160 # This method seem unreliable, so the page will also attempt to force | 163 # This method seem unreliable, so the page will also attempt to force |
| 161 # GC through excessive allocations. | 164 # GC through excessive allocations. |
| 162 tab.CollectGarbage() | 165 tab.CollectGarbage() |
| 163 completed = False | 166 completed = WaitForPageToFinish() |
| 164 try: | |
| 165 print "Waiting for page to finish." | |
| 166 util.WaitFor(lambda: tab.EvaluateJavaScript( | |
| 167 'window.domAutomationController._finished'), wait_timeout) | |
| 168 completed = True | |
| 169 except util.TimeoutException: | |
| 170 pass | |
| 171 | 167 |
| 172 if not completed: | 168 if not completed: |
| 173 raise page_test.Failure( | 169 raise page_test.Failure( |
| 174 'Test didn\'t complete (no context restored event?)') | 170 'Test didn\'t complete (no context restored event?)') |
| 175 if not tab.EvaluateJavaScript( | 171 if not tab.EvaluateJavaScript( |
| 176 'window.domAutomationController._succeeded'): | 172 'window.domAutomationController._succeeded'): |
| 177 raise page_test.Failure( | 173 raise page_test.Failure( |
| 178 'Test failed (context not restored properly?)') | 174 'Test failed (context not restored properly?)') |
| 179 else: | 175 elif page.hide_tab_and_lose_context: |
| 180 completed = False | 176 if not tab.browser.supports_tab_control: |
| 181 try: | 177 raise page_test.Failure('Browser must support tab control') |
| 182 print "Waiting for page to finish." | 178 |
| 183 util.WaitFor(lambda: tab.EvaluateJavaScript( | 179 # Test losing a context in a hidden tab. This test passes if the tab |
| 184 'window.domAutomationController._finished'), wait_timeout) | 180 # doesn't crash. |
| 185 completed = True | 181 dummy_tab = tab.browser.tabs.New() |
| 186 except util.TimeoutException: | 182 tab.EvaluateJavaScript('loseContextUsingExtension()') |
| 187 pass | 183 tab.Activate() |
| 184 | |
| 185 completed = WaitForPageToFinish() | |
| 188 | 186 |
| 189 if not completed: | 187 if not completed: |
| 190 raise page_test.Failure('Test didn\'t complete') | 188 raise page_test.Failure('Test didn\'t complete') |
| 189 if not tab.EvaluateJavaScript( | |
| 190 'window.domAutomationController._succeeded'): | |
| 191 raise page_test.Failure('Test failed') | |
| 192 else: | |
| 193 completed = WaitForPageToFinish() | |
| 194 | |
| 195 if not completed: | |
| 196 raise page_test.Failure('Test didn\'t complete') | |
| 191 if not tab.EvaluateJavaScript( | 197 if not tab.EvaluateJavaScript( |
| 192 'window.domAutomationController._succeeded'): | 198 'window.domAutomationController._succeeded'): |
| 193 raise page_test.Failure('Test failed') | 199 raise page_test.Failure('Test failed') |
| 194 | 200 |
| 195 # Test that navigating to chrome://gpucrash causes the GPU process to crash | 201 # Test that navigating to chrome://gpucrash causes the GPU process to crash |
| 196 # exactly one time per navigation. | 202 # exactly one time per navigation. |
| 197 class GPUProcessCrashesExactlyOnce(page.Page): | 203 class GPUProcessCrashesExactlyOnce(page.Page): |
| 198 def __init__(self, page_set, base_dir): | 204 def __init__(self, page_set, base_dir): |
| 199 super(GPUProcessCrashesExactlyOnce, self).__init__( | 205 super(GPUProcessCrashesExactlyOnce, self).__init__( |
| 200 url='file://gpu_process_crash.html', | 206 url='file://gpu_process_crash.html', |
| 201 page_set=page_set, | 207 page_set=page_set, |
| 202 base_dir=base_dir, | 208 base_dir=base_dir, |
| 203 name='GpuCrash.GPUProcessCrashesExactlyOnce') | 209 name='GpuCrash.GPUProcessCrashesExactlyOnce') |
| 204 self.script_to_evaluate_on_commit = harness_script | 210 self.script_to_evaluate_on_commit = harness_script |
| 205 self.kill_gpu_process = True | 211 self.kill_gpu_process = True |
| 206 self.number_of_gpu_process_kills = 2 | 212 self.number_of_gpu_process_kills = 2 |
| 207 self.check_crash_count = True | 213 self.check_crash_count = True |
| 208 self.force_garbage_collection = False | 214 self.force_garbage_collection = False |
| 215 self.hide_tab_and_lose_context = False | |
|
picksi1
2014/09/12 09:05:25
It looks like this has already landed, but as an o
Sami
2014/09/12 09:56:28
Right, what I'd really want to do here is have a c
| |
| 209 | 216 |
| 210 def RunNavigateSteps(self, action_runner): | 217 def RunNavigateSteps(self, action_runner): |
| 211 action_runner.NavigateToPage(self) | 218 action_runner.NavigateToPage(self) |
| 212 action_runner.WaitForJavaScriptCondition( | 219 action_runner.WaitForJavaScriptCondition( |
| 213 'window.domAutomationController._loaded') | 220 'window.domAutomationController._loaded') |
| 214 | 221 |
| 215 class WebGLContextLostFromGPUProcessExitPage(page.Page): | 222 class WebGLContextLostFromGPUProcessExitPage(page.Page): |
| 216 def __init__(self, page_set, base_dir): | 223 def __init__(self, page_set, base_dir): |
| 217 super(WebGLContextLostFromGPUProcessExitPage, self).__init__( | 224 super(WebGLContextLostFromGPUProcessExitPage, self).__init__( |
| 218 url='file://webgl.html?query=kill_after_notification', | 225 url='file://webgl.html?query=kill_after_notification', |
| 219 page_set=page_set, | 226 page_set=page_set, |
| 220 base_dir=base_dir, | 227 base_dir=base_dir, |
| 221 name='ContextLost.WebGLContextLostFromGPUProcessExit') | 228 name='ContextLost.WebGLContextLostFromGPUProcessExit') |
| 222 self.script_to_evaluate_on_commit = harness_script | 229 self.script_to_evaluate_on_commit = harness_script |
| 223 self.kill_gpu_process = True | 230 self.kill_gpu_process = True |
| 224 self.check_crash_count = False | 231 self.check_crash_count = False |
| 225 self.number_of_gpu_process_kills = 1 | 232 self.number_of_gpu_process_kills = 1 |
| 226 self.force_garbage_collection = False | 233 self.force_garbage_collection = False |
| 234 self.hide_tab_and_lose_context = False | |
| 227 | 235 |
| 228 def RunNavigateSteps(self, action_runner): | 236 def RunNavigateSteps(self, action_runner): |
| 229 action_runner.NavigateToPage(self) | 237 action_runner.NavigateToPage(self) |
| 230 action_runner.WaitForJavaScriptCondition( | 238 action_runner.WaitForJavaScriptCondition( |
| 231 'window.domAutomationController._loaded') | 239 'window.domAutomationController._loaded') |
| 232 | 240 |
| 233 | 241 |
| 234 class WebGLContextLostFromLoseContextExtensionPage(page.Page): | 242 class WebGLContextLostFromLoseContextExtensionPage(page.Page): |
| 235 def __init__(self, page_set, base_dir): | 243 def __init__(self, page_set, base_dir): |
| 236 super(WebGLContextLostFromLoseContextExtensionPage, self).__init__( | 244 super(WebGLContextLostFromLoseContextExtensionPage, self).__init__( |
| 237 url='file://webgl.html?query=WEBGL_lose_context', | 245 url='file://webgl.html?query=WEBGL_lose_context', |
| 238 page_set=page_set, | 246 page_set=page_set, |
| 239 base_dir=base_dir, | 247 base_dir=base_dir, |
| 240 name='ContextLost.WebGLContextLostFromLoseContextExtension') | 248 name='ContextLost.WebGLContextLostFromLoseContextExtension') |
| 241 self.script_to_evaluate_on_commit = harness_script | 249 self.script_to_evaluate_on_commit = harness_script |
| 242 self.kill_gpu_process = False | 250 self.kill_gpu_process = False |
| 243 self.check_crash_count = False | 251 self.check_crash_count = False |
| 244 self.force_garbage_collection = False | 252 self.force_garbage_collection = False |
| 253 self.hide_tab_and_lose_context = False | |
| 245 | 254 |
| 246 def RunNavigateSteps(self, action_runner): | 255 def RunNavigateSteps(self, action_runner): |
| 247 action_runner.NavigateToPage(self) | 256 action_runner.NavigateToPage(self) |
| 248 action_runner.WaitForJavaScriptCondition( | 257 action_runner.WaitForJavaScriptCondition( |
| 249 'window.domAutomationController._finished') | 258 'window.domAutomationController._finished') |
| 250 | 259 |
| 260 | |
| 261 class WebGLContextLostInHiddenTabPage(page.Page): | |
| 262 def __init__(self, page_set, base_dir): | |
| 263 super(WebGLContextLostInHiddenTabPage, self).__init__( | |
| 264 url='file://webgl.html?query=kill_after_notification', | |
| 265 page_set=page_set, | |
| 266 base_dir=base_dir, | |
| 267 name='ContextLost.WebGLContextLostInHiddenTab') | |
| 268 self.script_to_evaluate_on_commit = harness_script | |
| 269 self.kill_gpu_process = False | |
| 270 self.check_crash_count = False | |
| 271 self.force_garbage_collection = False | |
| 272 self.hide_tab_and_lose_context = True | |
| 273 | |
| 274 def RunNavigateSteps(self, action_runner): | |
| 275 action_runner.NavigateToPage(self) | |
| 276 action_runner.WaitForJavaScriptCondition( | |
| 277 'window.domAutomationController._loaded') | |
| 278 | |
| 279 | |
| 251 class WebGLContextLostFromQuantityPage(page.Page): | 280 class WebGLContextLostFromQuantityPage(page.Page): |
| 252 def __init__(self, page_set, base_dir): | 281 def __init__(self, page_set, base_dir): |
| 253 super(WebGLContextLostFromQuantityPage, self).__init__( | 282 super(WebGLContextLostFromQuantityPage, self).__init__( |
| 254 url='file://webgl.html?query=forced_quantity_loss', | 283 url='file://webgl.html?query=forced_quantity_loss', |
| 255 page_set=page_set, | 284 page_set=page_set, |
| 256 base_dir=base_dir, | 285 base_dir=base_dir, |
| 257 name='ContextLost.WebGLContextLostFromQuantity') | 286 name='ContextLost.WebGLContextLostFromQuantity') |
| 258 self.script_to_evaluate_on_commit = harness_script | 287 self.script_to_evaluate_on_commit = harness_script |
| 259 self.kill_gpu_process = False | 288 self.kill_gpu_process = False |
| 260 self.check_crash_count = False | 289 self.check_crash_count = False |
| 261 self.force_garbage_collection = True | 290 self.force_garbage_collection = True |
| 291 self.hide_tab_and_lose_context = False | |
| 262 | 292 |
| 263 def RunNavigateSteps(self, action_runner): | 293 def RunNavigateSteps(self, action_runner): |
| 264 action_runner.NavigateToPage(self) | 294 action_runner.NavigateToPage(self) |
| 265 action_runner.WaitForJavaScriptCondition( | 295 action_runner.WaitForJavaScriptCondition( |
| 266 'window.domAutomationController._loaded') | 296 'window.domAutomationController._loaded') |
| 267 | 297 |
| 268 class WebGLContextLostFromSelectElementPage(page.Page): | 298 class WebGLContextLostFromSelectElementPage(page.Page): |
| 269 def __init__(self, page_set, base_dir): | 299 def __init__(self, page_set, base_dir): |
| 270 super(WebGLContextLostFromSelectElementPage, self).__init__( | 300 super(WebGLContextLostFromSelectElementPage, self).__init__( |
| 271 url='file://webgl_with_select_element.html', | 301 url='file://webgl_with_select_element.html', |
| 272 page_set=page_set, | 302 page_set=page_set, |
| 273 base_dir=base_dir, | 303 base_dir=base_dir, |
| 274 name='ContextLost.WebGLContextLostFromSelectElement') | 304 name='ContextLost.WebGLContextLostFromSelectElement') |
| 275 self.script_to_evaluate_on_commit = harness_script | 305 self.script_to_evaluate_on_commit = harness_script |
| 276 self.kill_gpu_process = False | 306 self.kill_gpu_process = False |
| 277 self.check_crash_count = False | 307 self.check_crash_count = False |
| 278 self.force_garbage_collection = False | 308 self.force_garbage_collection = False |
| 309 self.hide_tab_and_lose_context = False | |
| 279 | 310 |
| 280 def RunNavigateSteps(self, action_runner): | 311 def RunNavigateSteps(self, action_runner): |
| 281 action_runner.NavigateToPage(self) | 312 action_runner.NavigateToPage(self) |
| 282 action_runner.WaitForJavaScriptCondition( | 313 action_runner.WaitForJavaScriptCondition( |
| 283 'window.domAutomationController._loaded') | 314 'window.domAutomationController._loaded') |
| 284 | 315 |
| 285 class ContextLost(benchmark_module.Benchmark): | 316 class ContextLost(benchmark_module.Benchmark): |
| 286 enabled = True | 317 enabled = True |
| 287 test = _ContextLostValidator | 318 test = _ContextLostValidator |
| 288 | 319 |
| 289 def CreateExpectations(self, page_set): | 320 def CreateExpectations(self, page_set): |
| 290 return context_lost_expectations.ContextLostExpectations() | 321 return context_lost_expectations.ContextLostExpectations() |
| 291 | 322 |
| 292 # For the record, this would have been another way to get the pages | 323 # For the record, this would have been another way to get the pages |
| 293 # to repeat. pageset_repeat would be another option. | 324 # to repeat. pageset_repeat would be another option. |
| 294 # options = {'page_repeat': 5} | 325 # options = {'page_repeat': 5} |
| 295 def CreatePageSet(self, options): | 326 def CreatePageSet(self, options): |
| 296 ps = page_set.PageSet( | 327 ps = page_set.PageSet( |
| 297 file_path=data_path, | 328 file_path=data_path, |
| 298 user_agent_type='desktop', | 329 user_agent_type='desktop', |
| 299 serving_dirs=set([''])) | 330 serving_dirs=set([''])) |
| 300 ps.AddPage(GPUProcessCrashesExactlyOnce(ps, ps.base_dir)) | 331 ps.AddPage(GPUProcessCrashesExactlyOnce(ps, ps.base_dir)) |
| 301 ps.AddPage(WebGLContextLostFromGPUProcessExitPage(ps, ps.base_dir)) | 332 ps.AddPage(WebGLContextLostFromGPUProcessExitPage(ps, ps.base_dir)) |
| 302 ps.AddPage(WebGLContextLostFromLoseContextExtensionPage(ps, ps.base_dir)) | 333 ps.AddPage(WebGLContextLostFromLoseContextExtensionPage(ps, ps.base_dir)) |
| 303 ps.AddPage(WebGLContextLostFromQuantityPage(ps, ps.base_dir)) | 334 ps.AddPage(WebGLContextLostFromQuantityPage(ps, ps.base_dir)) |
| 304 ps.AddPage(WebGLContextLostFromSelectElementPage(ps, ps.base_dir)) | 335 ps.AddPage(WebGLContextLostFromSelectElementPage(ps, ps.base_dir)) |
| 336 ps.AddPage(WebGLContextLostInHiddenTabPage(ps, ps.base_dir)) | |
| 305 return ps | 337 return ps |
| OLD | NEW |