summaryrefslogtreecommitdiffstats
path: root/content/test/gpu/gpu_tests/context_lost.py
diff options
context:
space:
mode:
Diffstat (limited to 'content/test/gpu/gpu_tests/context_lost.py')
-rw-r--r--content/test/gpu/gpu_tests/context_lost.py90
1 files changed, 84 insertions, 6 deletions
diff --git a/content/test/gpu/gpu_tests/context_lost.py b/content/test/gpu/gpu_tests/context_lost.py
index 731fffb..b691e8f 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,26 @@ 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()');
+
+ # If we're running the GPU process crash test, we need the
+ # test to have fully reset before crashing the GPU process.
+ if page.check_crash_count:
+ util.WaitFor(lambda: tab.EvaluateJavaScript(
+ 'window.domAutomationController._finished'), wait_timeout)
+
# 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 +102,48 @@ 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')
+
+ if not tab.EvaluateJavaScript(
+ 'window.domAutomationController._succeeded'):
+ raise page_test.Failure(
+ 'Test failed (didn\'t render content properly?)')
+
+ number_of_crashes = -1
+ # To allow time for a gpucrash to complete, wait up to 20s,
+ # polling repeatedly.
+ start_time = time.time()
+ current_time = time.time()
+ while current_time - start_time < 20:
+ system_info = tab.browser.GetSystemInfo()
+ number_of_crashes = \
+ system_info.gpu.aux_attributes[u'process_crash_count']
+ if number_of_crashes >= expected_kills:
+ break
+ time.sleep(1)
+ current_time = time.time()
+
+ # Wait 5 more seconds and re-read process_crash_count, in
+ # attempt to catch latent process crashes.
+ time.sleep(5)
+ system_info = tab.browser.GetSystemInfo()
+ number_of_crashes = \
+ system_info.gpu.aux_attributes[u'process_crash_count']
+
+ 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 +190,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 +219,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 +238,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 +255,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 +272,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 +291,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))