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

Unified Diff: telemetry/telemetry/internal/browser/tab.py

Issue 2693923005: Reland of [Telemetry] Switch clients to new JavaScript API (batch 5) (Closed)
Patch Set: Created 3 years, 10 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
Index: telemetry/telemetry/internal/browser/tab.py
diff --git a/telemetry/telemetry/internal/browser/tab.py b/telemetry/telemetry/internal/browser/tab.py
index cfedeba21291edd8b0da5af7678ba7ff9d53e538..3c346e9e4a1558ef537c1b1901417ebc77dd453c 100644
--- a/telemetry/telemetry/internal/browser/tab.py
+++ b/telemetry/telemetry/internal/browser/tab.py
@@ -133,28 +133,29 @@
exceptions.TimeoutException
exceptions.DevtoolsTargetCrashException
"""
- # TODO(catapult:#3028): Fix interpolation of JavaScript values.
- self.ExecuteJavaScript("""
- (function() {
- var screen = document.createElement('div');
- screen.style.background = 'rgba(%d, %d, %d, %d)';
- screen.style.position = 'fixed';
- screen.style.top = '0';
- screen.style.left = '0';
- screen.style.width = '100%%';
- screen.style.height = '100%%';
- screen.style.zIndex = '2147483638';
- document.body.appendChild(screen);
- requestAnimationFrame(function() {
+ screen_save = 'window.__telemetry_screen_%d' % int(color)
+ self.ExecuteJavaScript2("""
+ (function() {
+ var screen = document.createElement('div');
+ screen.style.background = {{ color }};
+ screen.style.position = 'fixed';
+ screen.style.top = '0';
+ screen.style.left = '0';
+ screen.style.width = '100%';
+ screen.style.height = '100%';
+ screen.style.zIndex = '2147483638';
+ document.body.appendChild(screen);
requestAnimationFrame(function() {
- window.__telemetry_screen_%d = screen;
+ requestAnimationFrame(function() {
+ {{ @screen_save }} = screen;
+ });
});
- });
- })();
- """ % (color.r, color.g, color.b, color.a, int(color)))
- # TODO(catapult:#3028): Fix interpolation of JavaScript values.
- self.WaitForJavaScriptExpression(
- '!!window.__telemetry_screen_%d' % int(color), 5)
+ })();
+ """,
+ color='rgba(%d, %d, %d, %d)' % (color.r, color.g, color.b, color.a),
+ screen_save=screen_save)
+ self.WaitForJavaScriptCondition2(
+ '!!{{ @screen_save }}', screen_save=screen_save, timeout=5)
def ClearHighlight(self, color):
"""Clears a highlight of the given bitmap.RgbaColor.
@@ -165,22 +166,21 @@
exceptions.TimeoutException
exceptions.DevtoolsTargetCrashException
"""
- # TODO(catapult:#3028): Fix interpolation of JavaScript values.
- self.ExecuteJavaScript("""
- (function() {
- document.body.removeChild(window.__telemetry_screen_%d);
- requestAnimationFrame(function() {
+ screen_save = 'window.__telemetry_screen_%d' % int(color)
+ self.ExecuteJavaScript2("""
+ (function() {
+ document.body.removeChild({{ @screen_save }});
requestAnimationFrame(function() {
- window.__telemetry_screen_%d = null;
- console.time('__ClearHighlight.video_capture_start');
- console.timeEnd('__ClearHighlight.video_capture_start');
+ requestAnimationFrame(function() {
+ {{ @screen_save }} = null;
+ console.time('__ClearHighlight.video_capture_start');
+ console.timeEnd('__ClearHighlight.video_capture_start');
+ });
});
- });
- })();
- """ % (int(color), int(color)))
- # TODO(catapult:#3028): Fix interpolation of JavaScript values.
- self.WaitForJavaScriptExpression(
- '!window.__telemetry_screen_%d' % int(color), 5)
+ })();
+ """, screen_save=screen_save)
+ self.WaitForJavaScriptCondition2(
+ '!{{ @screen_save }}', screen_save=screen_save, timeout=5)
def StartVideoCapture(self, min_bitrate_mbps,
highlight_bitmap=video.HIGHLIGHT_ORANGE_FRAME):
@@ -257,7 +257,7 @@
errors.DeviceUnresponsiveError
"""
self.browser.platform.FlushDnsCache()
- self.ExecuteJavaScript("""
+ self.ExecuteJavaScript2("""
if (window.chrome && chrome.benchmarking &&
chrome.benchmarking.clearCache) {
chrome.benchmarking.clearCache();
« no previous file with comments | « telemetry/telemetry/internal/browser/extension_unittest.py ('k') | telemetry/telemetry/internal/browser/tab_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698