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 |
94 class ContextLost(test_module.Test): | 114 class ContextLost(test_module.Test): |
95 enabled = True | 115 enabled = True |
96 test = _ContextLostValidator | 116 test = _ContextLostValidator |
97 # For the record, this would have been another way to get the pages | 117 # For the record, this would have been another way to get the pages |
98 # to repeat. pageset_repeat would be another option. | 118 # to repeat. pageset_repeat would be another option. |
99 # options = {'page_repeat': 5} | 119 # options = {'page_repeat': 5} |
100 def CreatePageSet(self, options): | 120 def CreatePageSet(self, options): |
101 page_set_dict = { | 121 page_set_dict = { |
102 'description': 'Test cases for real and synthetic context lost events', | 122 'description': 'Test cases for real and synthetic context lost events', |
103 'user_agent_type': 'desktop', | 123 'user_agent_type': 'desktop', |
104 'serving_dirs': [''], | 124 'serving_dirs': [''], |
105 'pages': [ | 125 'pages': [ |
106 { | 126 { |
107 'name': 'ContextLost.WebGLContextLostFromGPUProcessExit', | 127 'name': 'ContextLost.WebGLContextLostFromGPUProcessExit', |
108 'url': 'file://webgl.html?query=kill_after_notification', | 128 'url': 'file://webgl.html?query=kill_after_notification', |
109 'script_to_evaluate_on_commit': harness_script, | 129 'script_to_evaluate_on_commit': harness_script, |
110 'navigate_steps': [ | 130 'navigate_steps': [ |
111 { 'action': 'navigate' }, | 131 { 'action': 'navigate' }, |
112 { 'action': 'wait', | 132 { 'action': 'wait', |
113 'javascript': 'window.domAutomationController._loaded' } | 133 'javascript': 'window.domAutomationController._loaded' } |
114 ], | 134 ], |
115 'kill_gpu_process': True, | 135 'kill_gpu_process': True, |
116 'number_of_gpu_process_kills': 1, | 136 'number_of_gpu_process_kills': 1, |
| 137 'force_garbage_collection': False |
117 }, | 138 }, |
118 { | 139 { |
119 'name': 'ContextLost.WebGLContextLostFromLoseContextExtension', | 140 'name': 'ContextLost.WebGLContextLostFromLoseContextExtension', |
120 'url': 'file://webgl.html?query=WEBGL_lose_context', | 141 'url': 'file://webgl.html?query=WEBGL_lose_context', |
121 'script_to_evaluate_on_commit': harness_script, | 142 'script_to_evaluate_on_commit': harness_script, |
122 'navigate_steps': [ | 143 'navigate_steps': [ |
123 { 'action': 'navigate' }, | 144 { 'action': 'navigate' }, |
124 { 'action': 'wait', | 145 { 'action': 'wait', |
125 'javascript': 'window.domAutomationController._finished' } | 146 'javascript': 'window.domAutomationController._finished' } |
126 ], | 147 ], |
127 'kill_gpu_process': False | 148 '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 |
128 }, | 162 }, |
129 ] | 163 ] |
130 } | 164 } |
131 return page_set.PageSet.FromDict(page_set_dict, data_path) | 165 return page_set.PageSet.FromDict(page_set_dict, data_path) |
OLD | NEW |