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

Unified Diff: tools/telemetry/telemetry/core/browser_info.py

Issue 288313005: Add page.CanRunOnBrowser. Add WebGL check for tough_webgl_cases pages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix rebase mistakes Created 6 years, 7 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 | « tools/perf/page_sets/tough_webgl_cases.py ('k') | tools/telemetry/telemetry/page/page.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/core/browser_info.py
diff --git a/tools/telemetry/telemetry/core/browser_info.py b/tools/telemetry/telemetry/core/browser_info.py
new file mode 100644
index 0000000000000000000000000000000000000000..2e4cf49df4007624dc5c243ed0fcac774e54310f
--- /dev/null
+++ b/tools/telemetry/telemetry/core/browser_info.py
@@ -0,0 +1,38 @@
+# Copyright (c) 2014 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.
+
+_check_webgl_supported_script = """
+(function () {
+ var c = document.createElement('canvas');
+ var gl = c.getContext('webgl');
+ if (gl == null) {
+ gl = c.getContext("experimental-webgl");
+ if (gl == null) {
+ return false;
+ }
+ }
+ return true;
+})();
+"""
+
+class BrowserInfo(object):
+ """A wrapper around browser object that allows looking up infos of the
+ browser.
+ """
+ def __init__(self, browser):
+ self._browser = browser
+
+ def HasWebGLSupport(self):
+ result = False
+ # If no tab is opened, open one and close it after evaluate
+ # _check_webgl_supported_script
+ if len(self._browser.tabs) == 0 and self._browser.supports_tab_control:
+ self._browser.tabs.New()
+ tab = self._browser.tabs[0]
+ result = tab.EvaluateJavaScript(_check_webgl_supported_script)
+ tab.Close()
+ elif len(self._browser.tabs) > 0:
+ tab = self._browser.tabs[0]
+ result = tab.EvaluateJavaScript(_check_webgl_supported_script)
+ return result
« no previous file with comments | « tools/perf/page_sets/tough_webgl_cases.py ('k') | tools/telemetry/telemetry/page/page.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698