OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import logging | 5 import logging |
6 import re | 6 import re |
7 | 7 |
8 from telemetry import decorators | 8 from telemetry import decorators |
9 from telemetry.timeline import trace_data as trace_data_module | 9 from telemetry.timeline import trace_data as trace_data_module |
10 from telemetry.core.backends.chrome_inspector import devtools_http | 10 from telemetry.core.backends.chrome_inspector import devtools_http |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 those three event categories. | 127 those three event categories. |
128 """ | 128 """ |
129 assert trace_options and trace_options.enable_chrome_trace | 129 assert trace_options and trace_options.enable_chrome_trace |
130 self._CreateTracingBackendIfNeeded() | 130 self._CreateTracingBackendIfNeeded() |
131 return self._tracing_backend.StartTracing( | 131 return self._tracing_backend.StartTracing( |
132 trace_options, custom_categories, timeout) | 132 trace_options, custom_categories, timeout) |
133 | 133 |
134 def StopChromeTracing(self, trace_data_builder, timeout=30): | 134 def StopChromeTracing(self, trace_data_builder, timeout=30): |
135 context_map = self.GetUpdatedInspectableContexts() | 135 context_map = self.GetUpdatedInspectableContexts() |
136 for context in context_map.contexts: | 136 for context in context_map.contexts: |
| 137 if context['type'] not in ['iframe', 'page', 'webview']: |
| 138 continue |
137 context_id = context['id'] | 139 context_id = context['id'] |
138 backend = context_map.GetInspectorBackend(context_id) | 140 backend = context_map.GetInspectorBackend(context_id) |
139 success = backend.EvaluateJavaScript( | 141 success = backend.EvaluateJavaScript( |
140 "console.time('" + backend.id + "');" + | 142 "console.time('" + backend.id + "');" + |
141 "console.timeEnd('" + backend.id + "');" + | 143 "console.timeEnd('" + backend.id + "');" + |
142 "console.time.toString().indexOf('[native code]') != -1;") | 144 "console.time.toString().indexOf('[native code]') != -1;") |
143 if not success: | 145 if not success: |
144 raise Exception('Page stomped on console.time') | 146 raise Exception('Page stomped on console.time') |
145 trace_data_builder.AddEventsTo( | 147 trace_data_builder.AddEventsTo( |
146 trace_data_module.TAB_ID_PART, [backend.id]) | 148 trace_data_module.TAB_ID_PART, [backend.id]) |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 # If an InspectorBackend is already created for the tab, | 202 # If an InspectorBackend is already created for the tab, |
201 # webSocketDebuggerUrl will be missing, and this is expected. | 203 # webSocketDebuggerUrl will be missing, and this is expected. |
202 context_id = context['id'] | 204 context_id = context['id'] |
203 if context_id not in self._inspector_backends_dict: | 205 if context_id not in self._inspector_backends_dict: |
204 if 'webSocketDebuggerUrl' not in context: | 206 if 'webSocketDebuggerUrl' not in context: |
205 logging.debug('webSocketDebuggerUrl missing, removing %s' | 207 logging.debug('webSocketDebuggerUrl missing, removing %s' |
206 % context_id) | 208 % context_id) |
207 continue | 209 continue |
208 valid_contexts.append(context) | 210 valid_contexts.append(context) |
209 self._contexts = valid_contexts | 211 self._contexts = valid_contexts |
OLD | NEW |