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

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

Issue 1023493002: Add flag to WaitForJavaScriptExpression to reduce the exception verbosity. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 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
« 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: 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 bf217e19aaa48f2cfa530086e336debc538c1662..3d1cfb6517e5934e1570b8f745cf46f3f9bd9ef9 100644
--- a/tools/telemetry/telemetry/core/web_contents.py
+++ b/tools/telemetry/telemetry/core/web_contents.py
@@ -36,10 +36,17 @@ class WebContents(object):
'document.readyState == "interactive" || '
'document.readyState == "complete"', timeout)
- def WaitForJavaScriptExpression(self, expr, timeout):
+ def WaitForJavaScriptExpression(self, expr, timeout,
+ dump_page_state_on_timeout=True):
"""Waits for the given JavaScript expression to be True.
This method is robust against any given Evaluation timing out.
+
+ Args:
+ expr: The expression to evaluate.
+ timeout: The number of seconds to wait for the expression to be True.
+ dump_page_state_on_timeout: Whether to provide additional information on
+ the page state if a TimeoutException is thrown.
"""
def IsJavaScriptExpressionTrue():
try:
@@ -52,6 +59,9 @@ class WebContents(object):
try:
util.WaitFor(IsJavaScriptExpressionTrue, timeout)
except exceptions.TimeoutException as e:
+ if not dump_page_state_on_timeout:
+ raise
+
# Try to make timeouts a little more actionable by dumping |this|.
raise exceptions.TimeoutException(e.message + self.EvaluateJavaScript("""
(function() {
« 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