| Index: tools/telemetry/telemetry/core/backends/chrome/inspector_runtime.py
|
| diff --git a/tools/telemetry/telemetry/core/backends/chrome/inspector_runtime.py b/tools/telemetry/telemetry/core/backends/chrome/inspector_runtime.py
|
| index 3b8d19db7fbe812121f78628319c126157342d97..2d1c764cdcf09f6f88bdce7a5c531a514412a2ae 100644
|
| --- a/tools/telemetry/telemetry/core/backends/chrome/inspector_runtime.py
|
| +++ b/tools/telemetry/telemetry/core/backends/chrome/inspector_runtime.py
|
| @@ -11,9 +11,13 @@ class InspectorRuntime(object):
|
| self._OnNotification,
|
| self._OnClose)
|
| self._contexts_enabled = False
|
| + self._max_context_id = None
|
|
|
| def _OnNotification(self, msg):
|
| - pass
|
| + if (self._contexts_enabled and
|
| + msg['method'] == 'Runtime.executionContextCreated'):
|
| + self._max_context_id = max(self._max_context_id,
|
| + msg['params']['context']['id'])
|
|
|
| def _OnClose(self):
|
| pass
|
| @@ -22,7 +26,6 @@ class InspectorRuntime(object):
|
| self.Evaluate(expr + '; 0;', context_id, timeout)
|
|
|
| def Evaluate(self, expr, context_id, timeout):
|
| - self._EnableAllContexts(context_id)
|
| request = {
|
| 'method': 'Runtime.evaluate',
|
| 'params': {
|
| @@ -31,6 +34,7 @@ class InspectorRuntime(object):
|
| }
|
| }
|
| if context_id is not None:
|
| + self.EnableAllContexts()
|
| request['params']['contextId'] = context_id
|
| res = self._inspector_backend.SyncRequest(request, timeout)
|
| if 'error' in res:
|
| @@ -44,9 +48,10 @@ class InspectorRuntime(object):
|
| return None
|
| return res['result']['result']['value']
|
|
|
| - def _EnableAllContexts(self, context_id):
|
| - """Allow access to iframes as necessary."""
|
| - if context_id is not None and not self._contexts_enabled:
|
| + def EnableAllContexts(self):
|
| + """Allow access to iframes."""
|
| + if not self._contexts_enabled:
|
| + self._contexts_enabled = True
|
| self._inspector_backend.SyncRequest({'method': 'Runtime.enable'},
|
| timeout=30)
|
| - self._contexts_enabled = True
|
| + return self._max_context_id
|
|
|