| 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 | 5 |
| 6 from telemetry import benchmark as benchmark_module | 6 from telemetry import benchmark as benchmark_module |
| 7 from telemetry.core import exceptions | 7 from telemetry.core import exceptions |
| 8 from telemetry.core import util | 8 from telemetry.core import util |
| 9 from telemetry.page import page | 9 from telemetry.page import page |
| 10 from telemetry.page import page_set | 10 from telemetry.page import page_set |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 except util.TimeoutException: | 114 except util.TimeoutException: |
| 115 pass | 115 pass |
| 116 | 116 |
| 117 if not completed: | 117 if not completed: |
| 118 raise page_test.Failure( | 118 raise page_test.Failure( |
| 119 'Test didn\'t complete (no context restored event?)') | 119 'Test didn\'t complete (no context restored event?)') |
| 120 if not tab.EvaluateJavaScript( | 120 if not tab.EvaluateJavaScript( |
| 121 'window.domAutomationController._succeeded'): | 121 'window.domAutomationController._succeeded'): |
| 122 raise page_test.Failure( | 122 raise page_test.Failure( |
| 123 'Test failed (context not restored properly?)') | 123 'Test failed (context not restored properly?)') |
| 124 else: |
| 125 completed = False |
| 126 try: |
| 127 print "Waiting for page to finish." |
| 128 util.WaitFor(lambda: tab.EvaluateJavaScript( |
| 129 'window.domAutomationController._finished'), wait_timeout) |
| 130 completed = True |
| 131 except util.TimeoutException: |
| 132 pass |
| 133 |
| 134 if not completed: |
| 135 raise page_test.Failure('Test didn\'t complete') |
| 136 if not tab.EvaluateJavaScript( |
| 137 'window.domAutomationController._succeeded'): |
| 138 raise page_test.Failure('Test failed') |
| 124 | 139 |
| 125 class WebGLContextLostFromGPUProcessExitPage(page.Page): | 140 class WebGLContextLostFromGPUProcessExitPage(page.Page): |
| 126 def __init__(self, page_set, base_dir): | 141 def __init__(self, page_set, base_dir): |
| 127 super(WebGLContextLostFromGPUProcessExitPage, self).__init__( | 142 super(WebGLContextLostFromGPUProcessExitPage, self).__init__( |
| 128 url='file://webgl.html?query=kill_after_notification', | 143 url='file://webgl.html?query=kill_after_notification', |
| 129 page_set=page_set, | 144 page_set=page_set, |
| 130 base_dir=base_dir, | 145 base_dir=base_dir, |
| 131 name='ContextLost.WebGLContextLostFromGPUProcessExit') | 146 name='ContextLost.WebGLContextLostFromGPUProcessExit') |
| 132 self.script_to_evaluate_on_commit = harness_script | 147 self.script_to_evaluate_on_commit = harness_script |
| 133 self.kill_gpu_process = True | 148 self.kill_gpu_process = True |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 name='ContextLost.WebGLContextLostFromQuantity') | 180 name='ContextLost.WebGLContextLostFromQuantity') |
| 166 self.script_to_evaluate_on_commit = harness_script | 181 self.script_to_evaluate_on_commit = harness_script |
| 167 self.kill_gpu_process = False | 182 self.kill_gpu_process = False |
| 168 self.force_garbage_collection = True | 183 self.force_garbage_collection = True |
| 169 | 184 |
| 170 def RunNavigateSteps(self, action_runner): | 185 def RunNavigateSteps(self, action_runner): |
| 171 action_runner.NavigateToPage(self) | 186 action_runner.NavigateToPage(self) |
| 172 action_runner.WaitForJavaScriptCondition( | 187 action_runner.WaitForJavaScriptCondition( |
| 173 'window.domAutomationController._loaded') | 188 'window.domAutomationController._loaded') |
| 174 | 189 |
| 190 class WebGLContextLostFromSelectElementPage(page.Page): |
| 191 def __init__(self, page_set, base_dir): |
| 192 super(WebGLContextLostFromSelectElementPage, self).__init__( |
| 193 url='file://webgl_with_select_element.html', |
| 194 page_set=page_set, |
| 195 base_dir=base_dir, |
| 196 name='ContextLost.WebGLContextLostFromSelectElement') |
| 197 self.script_to_evaluate_on_commit = harness_script |
| 198 self.kill_gpu_process = False |
| 199 self.force_garbage_collection = False |
| 200 |
| 201 def RunNavigateSteps(self, action_runner): |
| 202 action_runner.NavigateToPage(self) |
| 203 action_runner.WaitForJavaScriptCondition( |
| 204 'window.domAutomationController._loaded') |
| 205 |
| 175 class ContextLost(benchmark_module.Benchmark): | 206 class ContextLost(benchmark_module.Benchmark): |
| 176 enabled = True | 207 enabled = True |
| 177 test = _ContextLostValidator | 208 test = _ContextLostValidator |
| 178 # For the record, this would have been another way to get the pages | 209 # For the record, this would have been another way to get the pages |
| 179 # to repeat. pageset_repeat would be another option. | 210 # to repeat. pageset_repeat would be another option. |
| 180 # options = {'page_repeat': 5} | 211 # options = {'page_repeat': 5} |
| 181 def CreatePageSet(self, options): | 212 def CreatePageSet(self, options): |
| 182 ps = page_set.PageSet( | 213 ps = page_set.PageSet( |
| 183 file_path=data_path, | 214 file_path=data_path, |
| 184 user_agent_type='desktop', | 215 user_agent_type='desktop', |
| 185 serving_dirs=set([''])) | 216 serving_dirs=set([''])) |
| 186 ps.AddPage(WebGLContextLostFromGPUProcessExitPage(ps, ps.base_dir)) | 217 ps.AddPage(WebGLContextLostFromGPUProcessExitPage(ps, ps.base_dir)) |
| 187 ps.AddPage(WebGLContextLostFromLoseContextExtensionPage(ps, ps.base_dir)) | 218 ps.AddPage(WebGLContextLostFromLoseContextExtensionPage(ps, ps.base_dir)) |
| 188 ps.AddPage(WebGLContextLostFromQuantityPage(ps, ps.base_dir)) | 219 ps.AddPage(WebGLContextLostFromQuantityPage(ps, ps.base_dir)) |
| 220 ps.AddPage(WebGLContextLostFromSelectElementPage(ps, ps.base_dir)) |
| 189 return ps | 221 return ps |
| OLD | NEW |