| 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 4e29c7d5a7f7fc1164c00705555279b75f65eac4..1837a301ca728e74ca6f8e4d79be33d48c53d4e2 100644
|
| --- a/tools/telemetry/telemetry/core/web_contents.py
|
| +++ b/tools/telemetry/telemetry/core/web_contents.py
|
| @@ -2,6 +2,8 @@
|
| # Use of this source code is governed by a BSD-style license that can be
|
| # found in the LICENSE file.
|
|
|
| +import os
|
| +
|
| from telemetry.core import util
|
|
|
| DEFAULT_WEB_CONTENTS_TIMEOUT = 90
|
| @@ -13,6 +15,10 @@ class WebContents(object):
|
| def __init__(self, inspector_backend):
|
| self._inspector_backend = inspector_backend
|
|
|
| + with open(os.path.join(os.path.dirname(__file__),
|
| + 'network_quiescence.js')) as f:
|
| + self._quiescence_js = f.read()
|
| +
|
| def Close(self):
|
| """Closes this page.
|
|
|
| @@ -46,6 +52,22 @@ class WebContents(object):
|
| return False
|
| util.WaitFor(IsTrue, timeout)
|
|
|
| + def HasReachedQuiescence(self):
|
| + """Determine whether the page has reached quiescence after loading.
|
| +
|
| + Returns:
|
| + True if 2 seconds have passed since last resource received, false
|
| + otherwise."""
|
| +
|
| + # Inclusion of the script that provides
|
| + # window.__telemetry_testHasReachedNetworkQuiescence()
|
| + # is idempotent, it's run on every call because WebContents doesn't track
|
| + # page loads and we need to execute anew for every newly loaded page.
|
| + has_reached_quiescence = (
|
| + self.EvaluateJavaScript(self._quiescence_js +
|
| + "window.__telemetry_testHasReachedNetworkQuiescence()"))
|
| + return has_reached_quiescence
|
| +
|
| def ExecuteJavaScript(self, expr, timeout=DEFAULT_WEB_CONTENTS_TIMEOUT):
|
| """Executes expr in JavaScript. Does not return the result.
|
|
|
|
|