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 |
new file mode 100644 |
index 0000000000000000000000000000000000000000..9b5e4fb08297523d1e4c356395171fd24a441168 |
--- /dev/null |
+++ b/content/test/gpu/gpu_tests/context_lost.py |
@@ -0,0 +1,110 @@ |
+# Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+# Use of this source code is governed by a BSD-style license that can be |
+# found in the LICENSE file. |
+import os |
+ |
+from telemetry import test as test_module |
+from telemetry.core import util |
+from telemetry.page import page_set |
+from telemetry.page import page_test |
+ |
+data_path = os.path.join( |
+ util.GetChromiumSrcDir(), 'content', 'test', 'data', 'gpu') |
+ |
+wait_timeout = 20 # seconds |
+ |
+harness_script = r""" |
+ var domAutomationController = {}; |
+ |
+ domAutomationController._loaded = false; |
+ domAutomationController._succeeded = false; |
+ domAutomationController._finished = false; |
+ |
+ domAutomationController.setAutomationId = function(id) {} |
+ |
+ domAutomationController.send = function(msg) { |
+ msg = msg.toLowerCase() |
+ if (msg == "loaded") { |
+ domAutomationController._loaded = true; |
+ } else if (msg == "success") { |
+ domAutomationController._succeeded = true; |
+ domAutomationController._finished = true; |
+ } else { |
+ domAutomationController._succeeded = false; |
+ domAutomationController._finished = true; |
+ } |
+ } |
+ |
+ window.domAutomationController = domAutomationController; |
+ console.log("Harness injected."); |
+""" |
+ |
+class ContextLostValidator(page_test.PageTest): |
dtu
2013/10/17 21:07:19
nit: _ContextLostValidator
Ken Russell (switch to Gerrit)
2013/10/17 21:24:53
Done.
|
+ def __init__(self): |
+ # Strictly speaking this test doesn't yet need a browser restart |
+ # after each run, but if more tests are added which crash the GPU |
+ # process, then it will. |
+ super(ContextLostValidator, self).__init__( |
+ 'ValidatePage', needs_browser_restart_after_each_run=True) |
+ |
+ def CustomizeBrowserOptions(self, options): |
+ options.AppendExtraBrowserArgs( |
+ '--disable-domain-blocking-for-3d-apis') |
+ # Required for about:gpucrash handling from Telemetry. |
+ options.AppendExtraBrowserArgs('--enable-gpu-benchmarking') |
+ |
+ def ValidatePage(self, page, tab, results): |
+ if page.kill_gpu_process: |
+ if not tab.browser.supports_tab_control: |
+ raise page_test.Failure('Browser must support tab control') |
+ # Crash the GPU process. |
+ new_tab = tab.browser.tabs.New() |
+ # To access these debug URLs from Telemetry, they have to be |
+ # written using the chrome:// scheme. |
+ new_tab.Navigate('chrome://gpucrash') |
+ # Activate the original tab and wait for completion. |
+ tab.Activate() |
+ res = util.WaitFor(lambda: tab.EvaluateJavaScript( |
+ 'window.domAutomationController._finished'), wait_timeout) |
+ new_tab.Close() |
+ if not res: |
+ raise page_test.Failure('Test didn\'t complete') |
dtu
2013/10/17 21:07:19
WaitFor throws a TimeoutException on timeout, you
Ken Russell (switch to Gerrit)
2013/10/17 21:24:53
Done.
|
+ if not tab.EvaluateJavaScript('window.domAutomationController._succeeded'): |
+ raise page_test.Failure('Test failed') |
dtu
2013/10/17 21:07:19
More descriptive failure message?
Ken Russell (switch to Gerrit)
2013/10/17 21:24:53
Attempted.
|
+ |
+ |
+class ContextLost(test_module.Test): |
+ enabled = True |
dtu
2013/10/17 21:07:19
Are the GPU bot scripts using this? If not, I'm go
Ken Russell (switch to Gerrit)
2013/10/17 21:24:53
I believe the Android GPU bot is using it to avoid
Sami
2013/10/18 13:05:38
To be clear, that flag was only added there to avo
|
+ test = ContextLostValidator |
+ |
+ def CreatePageSet(self, options): |
+ page_set_dict = { |
+ 'description': 'Test cases for real and synthetic context lost events', |
+ 'user_agent_type': 'desktop', |
+ 'serving_dirs': [''], |
+ 'pages': [ |
+ { |
+ 'name': 'ContextLost.WebGLContextLostFromGPUProcessExit', |
+ 'url': 'file://webgl.html?query=kill_after_notification', |
+ 'script_to_evaluate_on_commit': harness_script, |
+ 'navigate_steps': [ |
+ { 'action': 'navigate' }, |
+ { 'action': 'wait', |
+ 'javascript': 'window.domAutomationController._loaded' } |
+ ], |
+ 'kill_gpu_process': True |
+ }, |
+ { |
+ 'name': 'ContextLost.WebGLContextLostFromLoseContextExtension', |
+ 'url': 'file://webgl.html?query=WEBGL_lose_context', |
+ 'script_to_evaluate_on_commit': harness_script, |
+ 'navigate_steps': [ |
+ { 'action': 'navigate' }, |
+ { 'action': 'wait', |
+ 'javascript': 'window.domAutomationController._finished' } |
+ ], |
+ 'kill_gpu_process': False |
+ }, |
+ ] |
+ } |
+ return page_set.PageSet.FromDict(page_set_dict, data_path) |