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

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

Issue 183863007: Telemetry support for iframes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more fix for unittest Created 6 years, 9 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: tools/telemetry/telemetry/core/web_contents.py
diff --git a/tools/telemetry/telemetry/core/web_contents.py b/tools/telemetry/telemetry/core/web_contents.py
index 1837a301ca728e74ca6f8e4d79be33d48c53d4e2..15c87e89f9ee173577f2b02cf1339b3de0c5979f 100644
--- a/tools/telemetry/telemetry/core/web_contents.py
+++ b/tools/telemetry/telemetry/core/web_contents.py
@@ -73,7 +73,8 @@ class WebContents(object):
If the expression failed to evaluate, EvaluateException will be raised.
"""
- self._inspector_backend.ExecuteJavaScript(expr, timeout)
+ return self.ExecuteJavaScriptInContext(
+ expr, context_id=None, timeout=timeout)
def EvaluateJavaScript(self, expr, timeout=DEFAULT_WEB_CONTENTS_TIMEOUT):
"""Evalutes expr in JavaScript and returns the JSONized result.
@@ -87,7 +88,24 @@ class WebContents(object):
If the result of the evaluation cannot be JSONized, then an
EvaluationException will be raised.
"""
- return self._inspector_backend.EvaluateJavaScript(expr, timeout)
+ return self.EvaluateJavaScriptInContext(
+ expr, context_id=None, timeout=timeout)
+
+ def ExecuteJavaScriptInContext(self, expr, context_id,
+ timeout=DEFAULT_WEB_CONTENTS_TIMEOUT):
+ """Similar to ExecuteJavaScript, except context_id can refer to an iframe.
+ The main page has context_id=1, the first iframe context_id=2, etc.
+ """
+ return self._inspector_backend.ExecuteJavaScript(
+ expr, context_id=context_id, timeout=timeout)
+
+ def EvaluateJavaScriptInContext(self, expr, context_id,
+ timeout=DEFAULT_WEB_CONTENTS_TIMEOUT):
+ """Similar to ExecuteJavaScript, except context_id can refer to an iframe.
+ The main page has context_id=1, the first iframe context_id=2, etc.
+ """
+ return self._inspector_backend.EvaluateJavaScript(
+ expr, context_id=context_id, timeout=timeout)
@property
def message_output_stream(self):
« no previous file with comments | « tools/telemetry/telemetry/core/backends/chrome/inspector_runtime_unittest.py ('k') | tools/telemetry/unittest_data/host.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698