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

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: Addressing feedback, moved maps test to different CL 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..64bf1e799a73721756b6a8f65124b3ab926d34b0 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,34 @@ class InspectorPage(object):
self._inspector_backend.SendAndIgnoreResponse(request)
self.PerformActionAndWaitForNavigate(DoNavigate, timeout)
+
+ 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("""
+ window.chrome.gpuBenchmarking.snapshotComplete = false;
+ window.chrome.gpuBenchmarking.windowSnapshot(function(snapshot) {
+ window.chrome.gpuBenchmarking.snapshotData = snapshot;
nduca 2012/11/12 19:53:26 would probably bebetter if you stash this outside
+ window.chrome.gpuBenchmarking.snapshotComplete = true;
+ });
+ """)
+
+ def IsSnapshotComplete():
+ return self._tab.runtime.Evaluate(
+ 'window.chrome.gpuBenchmarking.snapshotComplete')
+
+ util.WaitFor(IsSnapshotComplete, timeout)
+
+ snap = self._tab.runtime.Evaluate(
+ 'window.chrome.gpuBenchmarking.snapshotData')
+ if snap:
nduca 2012/11/12 19:53:26 should you delette the snapshotComplete and snapsh
+ return png_bitmap.PngBitmap(snap['data'])
+ return None

Powered by Google App Engine
This is Rietveld 408576698