| Index: content/test/gpu/gpu_tests/context_lost.py
|
| diff --git a/content/test/gpu/gpu_tests/context_lost.py b/content/test/gpu/gpu_tests/context_lost.py
|
| index 731fffbfd4c7485f106b472f0dd4427a673db6b9..e3752a8a2b22bac58ab7c7578fb9bd5d4c1fe186 100644
|
| --- a/content/test/gpu/gpu_tests/context_lost.py
|
| +++ b/content/test/gpu/gpu_tests/context_lost.py
|
| @@ -2,6 +2,7 @@
|
| # Use of this source code is governed by a BSD-style license that can be
|
| # found in the LICENSE file.
|
| import os
|
| +import time
|
|
|
| from telemetry import benchmark as benchmark_module
|
| from telemetry.core import exceptions
|
| @@ -37,6 +38,11 @@ harness_script = r"""
|
| }
|
| }
|
|
|
| + domAutomationController.reset = function() {
|
| + domAutomationController._succeeded = false;
|
| + domAutomationController._finished = false;
|
| + }
|
| +
|
| window.domAutomationController = domAutomationController;
|
| console.log("Harness injected.");
|
| """
|
| @@ -65,18 +71,19 @@ class _ContextLostValidator(page_test.PageTest):
|
| for x in range(page.number_of_gpu_process_kills):
|
| if not tab.browser.supports_tab_control:
|
| raise page_test.Failure('Browser must support tab control')
|
| +
|
| + expected_kills = x + 1
|
| +
|
| # Reset the test's state.
|
| tab.EvaluateJavaScript(
|
| - 'window.domAutomationController._succeeded = false');
|
| - tab.EvaluateJavaScript(
|
| - 'window.domAutomationController._finished = false');
|
| + 'window.domAutomationController.reset()');
|
| # Crash the GPU process.
|
| - new_tab = tab.browser.tabs.New()
|
| + gpucrash_tab = tab.browser.tabs.New()
|
| # To access these debug URLs from Telemetry, they have to be
|
| # written using the chrome:// scheme.
|
| # The try/except is a workaround for crbug.com/368107.
|
| try:
|
| - new_tab.Navigate('chrome://gpucrash')
|
| + gpucrash_tab.Navigate('chrome://gpucrash')
|
| except (exceptions.TabCrashException, Exception):
|
| print 'Tab crashed while navigating to chrome://gpucrash'
|
| # Activate the original tab and wait for completion.
|
| @@ -88,9 +95,33 @@ class _ContextLostValidator(page_test.PageTest):
|
| completed = True
|
| except util.TimeoutException:
|
| pass
|
| +
|
| + if page.check_crash_count:
|
| + if not tab.browser.supports_system_info:
|
| + raise page_test.Failure('Browser must support system info')
|
| +
|
| + number_of_crashes = -1
|
| + # To allow time for a gpucrash to complete, wait 10s with
|
| + # maximum retry x3 times.
|
| + for retry in range(3):
|
| + time.sleep(10)
|
| + system_info = tab.browser.GetSystemInfo()
|
| + number_of_crashes = \
|
| + system_info.gpu.aux_attributes[u'process_crash_count']
|
| + if number_of_crashes >= expected_kills:
|
| + break
|
| +
|
| + if number_of_crashes < expected_kills:
|
| + raise page_test.Failure(
|
| + 'Timed out waiting for a gpu process crash')
|
| + elif number_of_crashes != expected_kills:
|
| + raise page_test.Failure(
|
| + 'Expected %d gpu process crashes; got: %d' %
|
| + (expected_kills, number_of_crashes))
|
| +
|
| # The try/except is a workaround for crbug.com/368107.
|
| try:
|
| - new_tab.Close()
|
| + gpucrash_tab.Close()
|
| except (exceptions.TabCrashException, Exception):
|
| print 'Tab crashed while closing chrome://gpucrash'
|
| if not completed:
|
| @@ -137,6 +168,26 @@ class _ContextLostValidator(page_test.PageTest):
|
| 'window.domAutomationController._succeeded'):
|
| raise page_test.Failure('Test failed')
|
|
|
| +# Test that navigating to chrome://gpucrash causes the GPU process to crash
|
| +# exactly one time per navigation.
|
| +class GPUProcessCrashesExactlyOnce(page.Page):
|
| + def __init__(self, page_set, base_dir):
|
| + super(GPUProcessCrashesExactlyOnce, self).__init__(
|
| + url='file://gpu_process_crash.html',
|
| + page_set=page_set,
|
| + base_dir=base_dir,
|
| + name='GpuCrash.GPUProcessCrashesExactlyOnce')
|
| + self.script_to_evaluate_on_commit = harness_script
|
| + self.kill_gpu_process = True
|
| + self.number_of_gpu_process_kills = 2
|
| + self.check_crash_count = True
|
| + self.force_garbage_collection = False
|
| +
|
| + def RunNavigateSteps(self, action_runner):
|
| + action_runner.NavigateToPage(self)
|
| + action_runner.WaitForJavaScriptCondition(
|
| + 'window.domAutomationController._loaded')
|
| +
|
| class WebGLContextLostFromGPUProcessExitPage(page.Page):
|
| def __init__(self, page_set, base_dir):
|
| super(WebGLContextLostFromGPUProcessExitPage, self).__init__(
|
| @@ -146,6 +197,7 @@ class WebGLContextLostFromGPUProcessExitPage(page.Page):
|
| name='ContextLost.WebGLContextLostFromGPUProcessExit')
|
| self.script_to_evaluate_on_commit = harness_script
|
| self.kill_gpu_process = True
|
| + self.check_crash_count = False
|
| self.number_of_gpu_process_kills = 1
|
| self.force_garbage_collection = False
|
|
|
| @@ -164,6 +216,7 @@ class WebGLContextLostFromLoseContextExtensionPage(page.Page):
|
| name='ContextLost.WebGLContextLostFromLoseContextExtension')
|
| self.script_to_evaluate_on_commit = harness_script
|
| self.kill_gpu_process = False
|
| + self.check_crash_count = False
|
| self.force_garbage_collection = False
|
|
|
| def RunNavigateSteps(self, action_runner):
|
| @@ -180,6 +233,7 @@ class WebGLContextLostFromQuantityPage(page.Page):
|
| name='ContextLost.WebGLContextLostFromQuantity')
|
| self.script_to_evaluate_on_commit = harness_script
|
| self.kill_gpu_process = False
|
| + self.check_crash_count = False
|
| self.force_garbage_collection = True
|
|
|
| def RunNavigateSteps(self, action_runner):
|
| @@ -196,6 +250,7 @@ class WebGLContextLostFromSelectElementPage(page.Page):
|
| name='ContextLost.WebGLContextLostFromSelectElement')
|
| self.script_to_evaluate_on_commit = harness_script
|
| self.kill_gpu_process = False
|
| + self.check_crash_count = False
|
| self.force_garbage_collection = False
|
|
|
| def RunNavigateSteps(self, action_runner):
|
| @@ -214,6 +269,7 @@ class ContextLost(benchmark_module.Benchmark):
|
| file_path=data_path,
|
| user_agent_type='desktop',
|
| serving_dirs=set(['']))
|
| + ps.AddPage(GPUProcessCrashesExactlyOnce(ps, ps.base_dir))
|
| ps.AddPage(WebGLContextLostFromGPUProcessExitPage(ps, ps.base_dir))
|
| ps.AddPage(WebGLContextLostFromLoseContextExtensionPage(ps, ps.base_dir))
|
| ps.AddPage(WebGLContextLostFromQuantityPage(ps, ps.base_dir))
|
|
|