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

Unified Diff: tools/telemetry/telemetry/inspector_page.py

Issue 11360172: Added Tab.SnapshotContent and MapsGL example to telemetry (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Merged with master Created 8 years, 1 month 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
Index: tools/telemetry/telemetry/inspector_page.py
diff --git a/tools/telemetry/telemetry/inspector_page.py b/tools/telemetry/telemetry/inspector_page.py
index b37d33049e1a876e0834201b8260df3c1cbaa2be..58afb4e8f4bb22337b0575740fde772de0617905 100644
--- a/tools/telemetry/telemetry/inspector_page.py
+++ b/tools/telemetry/telemetry/inspector_page.py
@@ -5,9 +5,13 @@ import json
import logging
from telemetry import util
+from telemetry import png_bitmap
+
+DEFAULT_SCREENSHOT_TIMEOUT = 60
class InspectorPage(object):
- def __init__(self, inspector_backend):
+ def __init__(self, inspector_backend, tab):
+ self._tab = tab
self._inspector_backend = inspector_backend
self._inspector_backend.RegisterDomain(
'Page',
@@ -81,3 +85,56 @@ class InspectorPage(object):
self._inspector_backend.SendAndIgnoreResponse(request)
self.PerformActionAndWaitForNavigate(DoNavigate, timeout)
+
+ @property
+ def screenshot_supported(self):
+ """True if the browser instance is capable of capturing screenshots"""
+ if self._tab.runtime.Evaluate(
+ 'window.chrome.gpuBenchmarking === undefined'):
+ return False
+
+ if self._tab.runtime.Evaluate(
+ 'window.chrome.gpuBenchmarking.windowSnapshot === undefined'):
+ return False
+
+ return True
+
+ def Screenshot(self, timeout=DEFAULT_SCREENSHOT_TIMEOUT):
+ """Capture a screenshot of the window for rendering validation"""
+
+ if self._tab.runtime.Evaluate(
+ 'window.chrome.gpuBenchmarking === undefined'):
+ raise Exception("Browser was not started with --enable-gpu-benchmarking")
+
+ if self._tab.runtime.Evaluate(
+ 'window.chrome.gpuBenchmarking.windowSnapshot === undefined'):
+ raise Exception("Browser does not support window snapshot API.")
+
+ self._tab.runtime.Evaluate("""
+ if(!window.__telemetry) {
+ window.__telemetry = {}
+ }
+ window.__telemetry.snapshotComplete = false;
+ window.__telemetry.snapshotData = null;
+ window.chrome.gpuBenchmarking.windowSnapshot(function(snapshot) {
+ window.__telemetry.snapshotData = snapshot;
+ window.__telemetry.snapshotComplete = true;
+ });
+ """)
+
+ def IsSnapshotComplete():
+ return self._tab.runtime.Evaluate('window.__telemetry.snapshotComplete')
+
+ util.WaitFor(IsSnapshotComplete, timeout)
+
+ snap = self._tab.runtime.Evaluate("""
+ (function() {
+ var data = window.__telemetry.snapshotData;
+ delete window.__telemetry.snapshotComplete;
+ delete window.__telemetry.snapshotData;
+ return data;
+ })()
+ """)
+ if snap:
+ return png_bitmap.PngBitmap(snap['data'])
+ return None
« no previous file with comments | « tools/telemetry/telemetry/inspector_console.py ('k') | tools/telemetry/telemetry/inspector_page_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698