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

Unified Diff: telemetry/telemetry/internal/backends/chrome/oobe.py

Issue 1893683002: Fix _ExecuteOobeApi for non-string arguments. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/catapult-project/catapult.git@master
Patch Set: Add comment with example values Created 4 years, 8 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: telemetry/telemetry/internal/backends/chrome/oobe.py
diff --git a/telemetry/telemetry/internal/backends/chrome/oobe.py b/telemetry/telemetry/internal/backends/chrome/oobe.py
index 7d92add0df4ca6f2aedb4a07819d715ad14739b2..7e9e1b1e670fbe2befe6cf4c7ce496b2070cea40 100644
--- a/telemetry/telemetry/internal/backends/chrome/oobe.py
+++ b/telemetry/telemetry/internal/backends/chrome/oobe.py
@@ -4,6 +4,7 @@
from functools import partial
import logging
+import json
from telemetry.core import exceptions
from telemetry.core import util
@@ -41,8 +42,13 @@ class Oobe(web_contents.WebContents):
if self.EvaluateJavaScript("typeof %s == 'undefined'" % api):
raise exceptions.LoginException('%s js api missing' % api)
- js = api + '(' + ("'%s'," * len(args)).rstrip(',') + ');'
- self.ExecuteJavaScript(js % args)
+ # Example values:
+ # |api|: 'doLogin'
+ # |args|: ['username', 'pass', True]
+ # js: '{}({},{},{})'
+ # js.format(...): 'doLogin("username","pass",true)'
achuithb 2016/04/15 22:05:37 Thanks!
+ js = '{}(' + ('{},' * len(args)).rstrip(',') + ')'
+ self.ExecuteJavaScript(js.format(api, *map(json.dumps, args)))
def NavigateGuestLogin(self):
"""Logs in as guest."""
« 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