| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 def __init__(self): | 43 def __init__(self): |
| 44 # Strictly speaking this test doesn't yet need a browser restart | 44 # Strictly speaking this test doesn't yet need a browser restart |
| 45 # after each run, but if more tests are added which crash the GPU | 45 # after each run, but if more tests are added which crash the GPU |
| 46 # process, then it will. | 46 # process, then it will. |
| 47 super(_ContextLostValidator, self).__init__( | 47 super(_ContextLostValidator, self).__init__( |
| 48 'ValidatePage', needs_browser_restart_after_each_page=True) | 48 'ValidatePage', needs_browser_restart_after_each_page=True) |
| 49 | 49 |
| 50 def CustomizeBrowserOptions(self, options): | 50 def CustomizeBrowserOptions(self, options): |
| 51 options.AppendExtraBrowserArgs( | 51 options.AppendExtraBrowserArgs( |
| 52 '--disable-domain-blocking-for-3d-apis') | 52 '--disable-domain-blocking-for-3d-apis') |
| 53 options.AppendExtraBrowserArgs( |
| 54 '--disable-gpu-process-crash-limit') |
| 53 # Required for about:gpucrash handling from Telemetry. | 55 # Required for about:gpucrash handling from Telemetry. |
| 54 options.AppendExtraBrowserArgs('--enable-gpu-benchmarking') | 56 options.AppendExtraBrowserArgs('--enable-gpu-benchmarking') |
| 55 | 57 |
| 56 def ValidatePage(self, page, tab, results): | 58 def ValidatePage(self, page, tab, results): |
| 57 if page.kill_gpu_process: | 59 if page.kill_gpu_process: |
| 58 if not tab.browser.supports_tab_control: | 60 # Doing the GPU process kill operation cooperatively -- in the |
| 59 raise page_test.Failure('Browser must support tab control') | 61 # same page's context -- is much more stressful than restarting |
| 60 # Crash the GPU process. | 62 # the browser every time. |
| 61 new_tab = tab.browser.tabs.New() | 63 for x in range(page.number_of_gpu_process_kills): |
| 62 # To access these debug URLs from Telemetry, they have to be | 64 if not tab.browser.supports_tab_control: |
| 63 # written using the chrome:// scheme. | 65 raise page_test.Failure('Browser must support tab control') |
| 64 new_tab.Navigate('chrome://gpucrash') | 66 # Reset the test's state. |
| 65 # Activate the original tab and wait for completion. | 67 tab.EvaluateJavaScript( |
| 66 tab.Activate() | 68 'window.domAutomationController._succeeded = false'); |
| 67 completed = False | 69 tab.EvaluateJavaScript( |
| 68 try: | 70 'window.domAutomationController._finished = false'); |
| 69 util.WaitFor(lambda: tab.EvaluateJavaScript( | 71 # Crash the GPU process. |
| 70 'window.domAutomationController._finished'), wait_timeout) | 72 new_tab = tab.browser.tabs.New() |
| 71 completed = True | 73 # To access these debug URLs from Telemetry, they have to be |
| 72 except util.TimeoutException: | 74 # written using the chrome:// scheme. |
| 73 pass | 75 new_tab.Navigate('chrome://gpucrash') |
| 74 new_tab.Close() | 76 # Activate the original tab and wait for completion. |
| 75 if not completed: | 77 tab.Activate() |
| 76 raise page_test.Failure( | 78 completed = False |
| 77 'Test didn\'t complete (no context lost event?)') | 79 try: |
| 78 if not tab.EvaluateJavaScript('window.domAutomationController._succeeded'): | 80 util.WaitFor(lambda: tab.EvaluateJavaScript( |
| 79 raise page_test.Failure('Test failed (context not restored properly?)') | 81 'window.domAutomationController._finished'), wait_timeout) |
| 82 completed = True |
| 83 except util.TimeoutException: |
| 84 pass |
| 85 new_tab.Close() |
| 86 if not completed: |
| 87 raise page_test.Failure( |
| 88 'Test didn\'t complete (no context lost event?)') |
| 89 if not tab.EvaluateJavaScript( |
| 90 'window.domAutomationController._succeeded'): |
| 91 raise page_test.Failure( |
| 92 'Test failed (context not restored properly?)') |
| 80 | 93 |
| 81 class ContextLost(test_module.Test): | 94 class ContextLost(test_module.Test): |
| 82 enabled = True | 95 enabled = True |
| 83 test = _ContextLostValidator | 96 test = _ContextLostValidator |
| 84 | 97 # For the record, this would have been another way to get the pages |
| 98 # to repeat. pageset_repeat would be another option. |
| 99 # options = {'page_repeat': 5} |
| 85 def CreatePageSet(self, options): | 100 def CreatePageSet(self, options): |
| 86 page_set_dict = { | 101 page_set_dict = { |
| 87 'description': 'Test cases for real and synthetic context lost events', | 102 'description': 'Test cases for real and synthetic context lost events', |
| 88 'user_agent_type': 'desktop', | 103 'user_agent_type': 'desktop', |
| 89 'serving_dirs': [''], | 104 'serving_dirs': [''], |
| 90 'pages': [ | 105 'pages': [ |
| 91 { | 106 { |
| 92 'name': 'ContextLost.WebGLContextLostFromGPUProcessExit', | 107 'name': 'ContextLost.WebGLContextLostFromGPUProcessExit', |
| 93 'url': 'file://webgl.html?query=kill_after_notification', | 108 'url': 'file://webgl.html?query=kill_after_notification', |
| 94 'script_to_evaluate_on_commit': harness_script, | 109 'script_to_evaluate_on_commit': harness_script, |
| 95 'navigate_steps': [ | 110 'navigate_steps': [ |
| 96 { 'action': 'navigate' }, | 111 { 'action': 'navigate' }, |
| 97 { 'action': 'wait', | 112 { 'action': 'wait', |
| 98 'javascript': 'window.domAutomationController._loaded' } | 113 'javascript': 'window.domAutomationController._loaded' } |
| 99 ], | 114 ], |
| 100 'kill_gpu_process': True | 115 'kill_gpu_process': True, |
| 116 'number_of_gpu_process_kills': 30, |
| 101 }, | 117 }, |
| 102 { | 118 { |
| 103 'name': 'ContextLost.WebGLContextLostFromLoseContextExtension', | 119 'name': 'ContextLost.WebGLContextLostFromLoseContextExtension', |
| 104 'url': 'file://webgl.html?query=WEBGL_lose_context', | 120 'url': 'file://webgl.html?query=WEBGL_lose_context', |
| 105 'script_to_evaluate_on_commit': harness_script, | 121 'script_to_evaluate_on_commit': harness_script, |
| 106 'navigate_steps': [ | 122 'navigate_steps': [ |
| 107 { 'action': 'navigate' }, | 123 { 'action': 'navigate' }, |
| 108 { 'action': 'wait', | 124 { 'action': 'wait', |
| 109 'javascript': 'window.domAutomationController._finished' } | 125 'javascript': 'window.domAutomationController._finished' } |
| 110 ], | 126 ], |
| 111 'kill_gpu_process': False | 127 'kill_gpu_process': False |
| 112 }, | 128 }, |
| 113 ] | 129 ] |
| 114 } | 130 } |
| 115 return page_set.PageSet.FromDict(page_set_dict, data_path) | 131 return page_set.PageSet.FromDict(page_set_dict, data_path) |
| OLD | NEW |