| 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 util | 7 from telemetry.core import util |
| 8 from telemetry.page import page_set | 8 from telemetry.page import page_set |
| 9 from telemetry.page import page_test | 9 from telemetry.page import page_test |
| 10 | 10 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 pass | 84 pass |
| 85 new_tab.Close() | 85 new_tab.Close() |
| 86 if not completed: | 86 if not completed: |
| 87 raise page_test.Failure( | 87 raise page_test.Failure( |
| 88 'Test didn\'t complete (no context lost event?)') | 88 'Test didn\'t complete (no context lost event?)') |
| 89 if not tab.EvaluateJavaScript( | 89 if not tab.EvaluateJavaScript( |
| 90 'window.domAutomationController._succeeded'): | 90 'window.domAutomationController._succeeded'): |
| 91 raise page_test.Failure( | 91 raise page_test.Failure( |
| 92 'Test failed (context not restored properly?)') | 92 'Test failed (context not restored properly?)') |
| 93 | 93 |
| 94 elif page.force_garbage_collection: | |
| 95 # Force GC to clean up any contexts not attached to the page. | |
| 96 tab.CollectGarbage() | |
| 97 completed = False | |
| 98 try: | |
| 99 print "Waiting for page to finish." | |
| 100 util.WaitFor(lambda: tab.EvaluateJavaScript( | |
| 101 'window.domAutomationController._finished'), wait_timeout) | |
| 102 completed = True | |
| 103 except util.TimeoutException: | |
| 104 pass | |
| 105 | |
| 106 if not completed: | |
| 107 raise page_test.Failure( | |
| 108 'Test didn\'t complete (no context restored event?)') | |
| 109 if not tab.EvaluateJavaScript( | |
| 110 'window.domAutomationController._succeeded'): | |
| 111 raise page_test.Failure( | |
| 112 'Test failed (context not restored properly?)') | |
| 113 | |
| 114 class ContextLost(test_module.Test): | 94 class ContextLost(test_module.Test): |
| 115 enabled = True | 95 enabled = True |
| 116 test = _ContextLostValidator | 96 test = _ContextLostValidator |
| 117 # For the record, this would have been another way to get the pages | 97 # For the record, this would have been another way to get the pages |
| 118 # to repeat. pageset_repeat would be another option. | 98 # to repeat. pageset_repeat would be another option. |
| 119 # options = {'page_repeat': 5} | 99 # options = {'page_repeat': 5} |
| 120 def CreatePageSet(self, options): | 100 def CreatePageSet(self, options): |
| 121 page_set_dict = { | 101 page_set_dict = { |
| 122 'description': 'Test cases for real and synthetic context lost events', | 102 'description': 'Test cases for real and synthetic context lost events', |
| 123 'user_agent_type': 'desktop', | 103 'user_agent_type': 'desktop', |
| 124 'serving_dirs': [''], | 104 'serving_dirs': [''], |
| 125 'pages': [ | 105 'pages': [ |
| 126 { | 106 { |
| 127 'name': 'ContextLost.WebGLContextLostFromGPUProcessExit', | 107 'name': 'ContextLost.WebGLContextLostFromGPUProcessExit', |
| 128 'url': 'file://webgl.html?query=kill_after_notification', | 108 'url': 'file://webgl.html?query=kill_after_notification', |
| 129 'script_to_evaluate_on_commit': harness_script, | 109 'script_to_evaluate_on_commit': harness_script, |
| 130 'navigate_steps': [ | 110 'navigate_steps': [ |
| 131 { 'action': 'navigate' }, | 111 { 'action': 'navigate' }, |
| 132 { 'action': 'wait', | 112 { 'action': 'wait', |
| 133 'javascript': 'window.domAutomationController._loaded' } | 113 'javascript': 'window.domAutomationController._loaded' } |
| 134 ], | 114 ], |
| 135 'kill_gpu_process': True, | 115 'kill_gpu_process': True, |
| 136 'number_of_gpu_process_kills': 1, | 116 'number_of_gpu_process_kills': 1, |
| 137 'force_garbage_collection': False | |
| 138 }, | 117 }, |
| 139 { | 118 { |
| 140 'name': 'ContextLost.WebGLContextLostFromLoseContextExtension', | 119 'name': 'ContextLost.WebGLContextLostFromLoseContextExtension', |
| 141 'url': 'file://webgl.html?query=WEBGL_lose_context', | 120 'url': 'file://webgl.html?query=WEBGL_lose_context', |
| 142 'script_to_evaluate_on_commit': harness_script, | 121 'script_to_evaluate_on_commit': harness_script, |
| 143 'navigate_steps': [ | 122 'navigate_steps': [ |
| 144 { 'action': 'navigate' }, | 123 { 'action': 'navigate' }, |
| 145 { 'action': 'wait', | 124 { 'action': 'wait', |
| 146 'javascript': 'window.domAutomationController._finished' } | 125 'javascript': 'window.domAutomationController._finished' } |
| 147 ], | 126 ], |
| 148 'kill_gpu_process': False, | 127 'kill_gpu_process': False |
| 149 'force_garbage_collection': False | |
| 150 }, | |
| 151 { | |
| 152 'name': 'ContextLost.WebGLContextLostFromQuantity', | |
| 153 'url': 'file://webgl.html?query=forced_quantity_loss', | |
| 154 'script_to_evaluate_on_commit': harness_script, | |
| 155 'navigate_steps': [ | |
| 156 { 'action': 'navigate' }, | |
| 157 { 'action': 'wait', | |
| 158 'javascript': 'window.domAutomationController._loaded' } | |
| 159 ], | |
| 160 'kill_gpu_process': False, | |
| 161 'force_garbage_collection': True | |
| 162 }, | 128 }, |
| 163 ] | 129 ] |
| 164 } | 130 } |
| 165 return page_set.PageSet.FromDict(page_set_dict, data_path) | 131 return page_set.PageSet.FromDict(page_set_dict, data_path) |
| OLD | NEW |