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