Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3203)

Unified Diff: content/test/gpu/gpu_tests/webgl_robustness.py

Issue 21150015: gpu: Add WebGL robustness telemetry test (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added requestAnimationFrame loop. Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/test/gpu/gpu_tests/webgl_robustness.py
diff --git a/content/test/gpu/gpu_tests/webgl_robustness.py b/content/test/gpu/gpu_tests/webgl_robustness.py
new file mode 100644
index 0000000000000000000000000000000000000000..f3ea32f63b059d457ef5e7bc795f34b07a9eef06
--- /dev/null
+++ b/content/test/gpu/gpu_tests/webgl_robustness.py
@@ -0,0 +1,64 @@
+# 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.
+from telemetry import test
+from telemetry.page import page_set
+from webgl_conformance import WebglConformanceValidator
+from webgl_conformance import conformance_harness_script
+from webgl_conformance import conformance_path
+
+
+robustness_harness_script = conformance_harness_script + r"""
+ var robustnessTestHarness = {};
+ robustnessTestHarness._contextLost = false;
+ robustnessTestHarness.initialize = function() {
+ var canvas = document.getElementById('example');
+ canvas.addEventListener('webglcontextlost', function() {
+ robustnessTestHarness._contextLost = true;
+ });
+ }
+ robustnessTestHarness.runTestLoop = function() {
+ // Run the test in a loop until the context is lost.
+ main();
+ if (!robustnessTestHarness._contextLost)
+ window.requestAnimationFrame(robustnessTestHarness.runTestLoop);
+ else
+ robustnessTestHarness.notifyFinished();
+ }
+ robustnessTestHarness.notifyFinished = function() {
+ // The test may fail in unpredictable ways depending on when the context is
+ // lost. We ignore such errors and only require that the browser doesn't
+ // crash.
+ webglTestHarness._allTestSucceeded = true;
+ // Notify test completion after a delay to make sure the browser is able to
+ // recover from the lost context.
+ setTimeout(webglTestHarness.notifyFinished, 3000);
+ }
+
+ window.confirm = function() {
+ robustnessTestHarness.initialize();
+ robustnessTestHarness.runTestLoop();
+ return false;
+ }
+ window.webglRobustnessTestHarness = robustnessTestHarness;
+"""
+
+
+class WebglRobustness(test.Test):
+ enabled = False
+ test = WebglConformanceValidator
+
+ def CreatePageSet(self, options):
+ page_set_dict = {
+ 'description': 'Test cases for WebGL robustness',
+ 'user_agent_type': 'desktop',
+ 'serving_dirs': [''],
+ 'pages': [
+ {
+ 'url': 'file:///extra/lots-of-polys-example.html',
+ 'script_to_evaluate_on_commit': robustness_harness_script,
+ 'wait_for_javascript_expression': 'webglTestHarness._finished'
+ }
+ ]
+ }
+ return page_set.PageSet.FromDict(page_set_dict, conformance_path)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698