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..00e2dd94c3576e12c583ae49b14fdb739c948e68 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,10 +38,33 @@ harness_script = r""" |
} |
} |
+ domAutomationController.reset = function() { |
+ domAutomationController._succeeded = false; |
+ domAutomationController._finished = false; |
+ } |
+ |
window.domAutomationController = domAutomationController; |
console.log("Harness injected."); |
""" |
+gpu_process_crash_count_script = r""" |
+ function GetProcessCrashCount() { |
+ var table = document.querySelector('#basic-info #info-view-table'); |
+ if ( table == null ) |
+ return false; |
+ for (var i = 0, row; row = table.rows[i]; i++) { |
+ var span_list = row.getElementsByTagName('span'); |
+ var name_str = span_list[0].textContent; |
+ var value_str = span_list[1].textContent; |
+ if (name_str == 'GPU process crash count') { |
+ window._process_crash_count = value_str; |
+ return true; |
+ } |
+ } |
+ return false; |
+ } |
+"""; |
+ |
class _ContextLostValidator(page_test.PageTest): |
def __init__(self): |
# Strictly speaking this test doesn't yet need a browser restart |
@@ -65,18 +89,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 +113,45 @@ class _ContextLostValidator(page_test.PageTest): |
completed = True |
except util.TimeoutException: |
pass |
+ |
+ if page.check_crash_count: |
+ 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) |
+ |
+ # Scrub chrome://gpu page for GPU process crash count. |
+ gpuinfo_tab = tab.browser.tabs.New() |
+ gpuinfo_tab.Navigate('chrome://gpu', gpu_process_crash_count_script) |
+ |
+ # Wait until chrome://gpu page is populated. |
+ util.WaitFor(lambda: gpuinfo_tab.EvaluateJavaScript( |
+ 'GetProcessCrashCount()'), wait_timeout) |
+ |
+ number_of_crashes =int( |
Ken Russell (switch to Gerrit)
2014/07/25 01:08:27
space after '='
vmiura
2014/07/25 19:56:03
Done.
|
+ gpuinfo_tab.EvaluateJavaScript("window._process_crash_count")) |
+ |
+ # The try/except is a workaround for crbug.com/368107. |
+ try: |
+ gpuinfo_tab.Close() |
+ except (exceptions.TabCrashException, Exception): |
+ print 'Tab crashed while closing chrome://gpucrash' |
+ |
+ 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 +198,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. |
+class GPUProcessExitPageCrashesOnce(page.Page): |
Ken Russell (switch to Gerrit)
2014/07/25 01:08:26
Suggest something like "GPUProcessCrashesExactlyOn
vmiura
2014/07/25 19:56:03
Done.
|
+ def __init__(self, page_set, base_dir): |
+ super(GPUProcessExitPageCrashesOnce, self).__init__( |
+ url='file://gpu_process_crash.html', |
+ page_set=page_set, |
+ base_dir=base_dir, |
+ name='GpuCrash.GPUProcessExitPageCrashesOnce') |
+ self.script_to_evaluate_on_commit = harness_script |
+ self.kill_gpu_process = True |
+ self.number_of_gpu_process_kills = 2 |
Ken Russell (switch to Gerrit)
2014/07/25 01:08:26
Running the test twice looks good. Just checking t
vmiura
2014/07/25 19:56:03
Yes I thought it would be good to check behavior o
|
+ 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 +227,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 +246,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 +263,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 +280,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 +299,7 @@ class ContextLost(benchmark_module.Benchmark): |
file_path=data_path, |
user_agent_type='desktop', |
serving_dirs=set([''])) |
+ ps.AddPage(GPUProcessExitPageCrashesOnce(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)) |