OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 from telemetry.core import util | 5 from telemetry.core import util |
6 | 6 |
7 DEFAULT_WEB_CONTENTS_TIMEOUT = 90 | 7 DEFAULT_WEB_CONTENTS_TIMEOUT = 90 |
8 | 8 |
9 # TODO(achuith, dtu, nduca): Add unit tests specifically for WebContents, | 9 # TODO(achuith, dtu, nduca): Add unit tests specifically for WebContents, |
10 # independent of Tab. | 10 # independent of Tab. |
11 class WebContents(object): | 11 class WebContents(object): |
12 """Represents web contents in the browser""" | 12 """Represents web contents in the browser""" |
13 def __init__(self, inspector_backend): | 13 def __init__(self, inspector_backend): |
14 self._inspector_backend = inspector_backend | 14 self._inspector_backend = inspector_backend |
15 | 15 |
16 def __del__(self): | |
17 self.Disconnect() | |
18 | |
19 def Disconnect(self): | |
20 self._inspector_backend.Disconnect() | |
21 | |
22 def Close(self): | 16 def Close(self): |
23 """Closes this page. | 17 """Closes this page. |
24 | 18 |
25 Not all browsers or browser versions support this method. | 19 Not all browsers or browser versions support this method. |
26 Be sure to check browser.supports_tab_control.""" | 20 Be sure to check browser.supports_tab_control.""" |
27 self._inspector_backend.Close() | 21 self._inspector_backend.Close() |
28 | 22 |
29 def WaitForDocumentReadyStateToBeComplete(self, | 23 def WaitForDocumentReadyStateToBeComplete(self, |
30 timeout=DEFAULT_WEB_CONTENTS_TIMEOUT): | 24 timeout=DEFAULT_WEB_CONTENTS_TIMEOUT): |
31 self.WaitForJavaScriptExpression( | 25 self.WaitForJavaScriptExpression( |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 return self._inspector_backend.timeline_model | 80 return self._inspector_backend.timeline_model |
87 | 81 |
88 def StartTimelineRecording(self): | 82 def StartTimelineRecording(self): |
89 self._inspector_backend.StartTimelineRecording() | 83 self._inspector_backend.StartTimelineRecording() |
90 | 84 |
91 def StopTimelineRecording(self): | 85 def StopTimelineRecording(self): |
92 self._inspector_backend.StopTimelineRecording() | 86 self._inspector_backend.StopTimelineRecording() |
93 | 87 |
94 def TakeJSHeapSnapshot(self, timeout=120): | 88 def TakeJSHeapSnapshot(self, timeout=120): |
95 return self._inspector_backend.TakeJSHeapSnapshot(timeout) | 89 return self._inspector_backend.TakeJSHeapSnapshot(timeout) |
OLD | NEW |