| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 | 4 |
| 5 import os | 5 import os |
| 6 import time | 6 import time |
| 7 | 7 |
| 8 from gpu_tests import gpu_integration_test | 8 from gpu_tests import gpu_integration_test |
| 9 from gpu_tests import context_lost_expectations | 9 from gpu_tests import context_lost_expectations |
| 10 from gpu_tests import path_util | 10 from gpu_tests import path_util |
| 11 | 11 |
| 12 import py_utils |
| 12 from telemetry.core import exceptions | 13 from telemetry.core import exceptions |
| 13 from telemetry.core import util | |
| 14 | 14 |
| 15 data_path = os.path.join( | 15 data_path = os.path.join( |
| 16 path_util.GetChromiumSrcDir(), 'content', 'test', 'data', 'gpu') | 16 path_util.GetChromiumSrcDir(), 'content', 'test', 'data', 'gpu') |
| 17 | 17 |
| 18 wait_timeout = 60 # seconds | 18 wait_timeout = 60 # seconds |
| 19 | 19 |
| 20 harness_script = r""" | 20 harness_script = r""" |
| 21 var domAutomationController = {}; | 21 var domAutomationController = {}; |
| 22 | 22 |
| 23 domAutomationController._loaded = false; | 23 domAutomationController._loaded = false; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 @classmethod | 99 @classmethod |
| 100 def setUpClass(cls): | 100 def setUpClass(cls): |
| 101 super(cls, ContextLostIntegrationTest).setUpClass() | 101 super(cls, ContextLostIntegrationTest).setUpClass() |
| 102 cls.CustomizeOptions() | 102 cls.CustomizeOptions() |
| 103 cls.SetBrowserOptions(cls._finder_options) | 103 cls.SetBrowserOptions(cls._finder_options) |
| 104 cls.StartBrowser() | 104 cls.StartBrowser() |
| 105 cls.SetStaticServerDirs([data_path]) | 105 cls.SetStaticServerDirs([data_path]) |
| 106 | 106 |
| 107 def _WaitForPageToFinish(self, tab): | 107 def _WaitForPageToFinish(self, tab): |
| 108 try: | 108 try: |
| 109 util.WaitFor(lambda: tab.EvaluateJavaScript( | 109 py_utils.WaitFor(lambda: tab.EvaluateJavaScript( |
| 110 'window.domAutomationController._finished'), wait_timeout) | 110 'window.domAutomationController._finished'), wait_timeout) |
| 111 return True | 111 return True |
| 112 except exceptions.TimeoutException: | 112 except exceptions.TimeoutException: |
| 113 return False | 113 return False |
| 114 | 114 |
| 115 def _KillGPUProcess(self, number_of_gpu_process_kills, | 115 def _KillGPUProcess(self, number_of_gpu_process_kills, |
| 116 check_crash_count): | 116 check_crash_count): |
| 117 tab = self.tab | 117 tab = self.tab |
| 118 # Doing the GPU process kill operation cooperatively -- in the | 118 # Doing the GPU process kill operation cooperatively -- in the |
| 119 # same page's context -- is much more stressful than restarting | 119 # same page's context -- is much more stressful than restarting |
| 120 # the browser every time. | 120 # the browser every time. |
| 121 for x in range(number_of_gpu_process_kills): | 121 for x in range(number_of_gpu_process_kills): |
| 122 expected_kills = x + 1 | 122 expected_kills = x + 1 |
| 123 | 123 |
| 124 # Reset the test's state. | 124 # Reset the test's state. |
| 125 tab.EvaluateJavaScript( | 125 tab.EvaluateJavaScript( |
| 126 'window.domAutomationController.reset()') | 126 'window.domAutomationController.reset()') |
| 127 | 127 |
| 128 # If we're running the GPU process crash test, we need the test | 128 # If we're running the GPU process crash test, we need the test |
| 129 # to have fully reset before crashing the GPU process. | 129 # to have fully reset before crashing the GPU process. |
| 130 if check_crash_count: | 130 if check_crash_count: |
| 131 util.WaitFor(lambda: tab.EvaluateJavaScript( | 131 py_utils.WaitFor(lambda: tab.EvaluateJavaScript( |
| 132 'window.domAutomationController._finished'), wait_timeout) | 132 'window.domAutomationController._finished'), wait_timeout) |
| 133 | 133 |
| 134 # Crash the GPU process. | 134 # Crash the GPU process. |
| 135 gpucrash_tab = tab.browser.tabs.New() | 135 gpucrash_tab = tab.browser.tabs.New() |
| 136 # To access these debug URLs from Telemetry, they have to be | 136 # To access these debug URLs from Telemetry, they have to be |
| 137 # written using the chrome:// scheme. | 137 # written using the chrome:// scheme. |
| 138 # The try/except is a workaround for crbug.com/368107. | 138 # The try/except is a workaround for crbug.com/368107. |
| 139 try: | 139 try: |
| 140 gpucrash_tab.Navigate('chrome://gpucrash') | 140 gpucrash_tab.Navigate('chrome://gpucrash') |
| 141 except Exception: | 141 except Exception: |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 | 244 |
| 245 def _ContextLost_WebGLContextLostInHiddenTab(self, test_path): | 245 def _ContextLost_WebGLContextLostInHiddenTab(self, test_path): |
| 246 self._NavigateAndWaitForLoad(test_path) | 246 self._NavigateAndWaitForLoad(test_path) |
| 247 # Test losing a context in a hidden tab. This test passes if the tab | 247 # Test losing a context in a hidden tab. This test passes if the tab |
| 248 # doesn't crash. | 248 # doesn't crash. |
| 249 tab = self.tab | 249 tab = self.tab |
| 250 dummy_tab = tab.browser.tabs.New() | 250 dummy_tab = tab.browser.tabs.New() |
| 251 tab.EvaluateJavaScript('loseContextUsingExtension()') | 251 tab.EvaluateJavaScript('loseContextUsingExtension()') |
| 252 tab.Activate() | 252 tab.Activate() |
| 253 self._WaitForTabAndCheckCompletion() | 253 self._WaitForTabAndCheckCompletion() |
| OLD | NEW |