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 DEFAULT_WEB_CONTENTS_TIMEOUT = 60 | 5 DEFAULT_WEB_CONTENTS_TIMEOUT = 60 |
6 | 6 |
7 # TODO(achuith, dtu, nduca): Add unit tests specifically for WebContents, | 7 # TODO(achuith, dtu, nduca): Add unit tests specifically for WebContents, |
8 # independent of Tab. | 8 # independent of Tab. |
9 class WebContents(object): | 9 class WebContents(object): |
10 """Represents web contents in the browser""" | 10 """Represents web contents in the browser""" |
11 def __init__(self, inspector_backend): | 11 def __init__(self, inspector_backend): |
12 self._inspector_backend = inspector_backend | 12 self._inspector_backend = inspector_backend |
13 | 13 |
14 def __del__(self): | 14 def __del__(self): |
15 self.Disconnect() | 15 self.Disconnect() |
16 | 16 |
17 def Disconnect(self): | 17 def Disconnect(self): |
18 self._inspector_backend.Disconnect() | 18 self._inspector_backend.Disconnect() |
19 | 19 |
20 def Close(self): | 20 def Close(self): |
21 """Closes this page. | 21 """Closes this page. |
22 | 22 |
23 Not all browsers or browser versions support this method. | 23 Not all browsers or browser versions support this method. |
24 Be sure to check browser.supports_tab_control.""" | 24 Be sure to check browser.supports_tab_control.""" |
25 self._inspector_backend.Close() | 25 self._inspector_backend.Close() |
26 | 26 |
| 27 @property |
| 28 def browser(self): |
| 29 """The browser in which this WebContents resides.""" |
| 30 return self._inspector_backend.browser |
| 31 |
| 32 @property |
| 33 def url(self): |
| 34 return self._inspector_backend.url |
| 35 |
27 def WaitForDocumentReadyStateToBeComplete(self, | 36 def WaitForDocumentReadyStateToBeComplete(self, |
28 timeout=DEFAULT_WEB_CONTENTS_TIMEOUT): | 37 timeout=DEFAULT_WEB_CONTENTS_TIMEOUT): |
29 self._inspector_backend.WaitForDocumentReadyStateToBeComplete(timeout) | 38 self._inspector_backend.WaitForDocumentReadyStateToBeComplete(timeout) |
30 | 39 |
31 def WaitForDocumentReadyStateToBeInteractiveOrBetter(self, | 40 def WaitForDocumentReadyStateToBeInteractiveOrBetter(self, |
32 timeout=DEFAULT_WEB_CONTENTS_TIMEOUT): | 41 timeout=DEFAULT_WEB_CONTENTS_TIMEOUT): |
33 self._inspector_backend.WaitForDocumentReadyStateToBeInteractiveOrBetter( | 42 self._inspector_backend.WaitForDocumentReadyStateToBeInteractiveOrBetter( |
34 timeout) | 43 timeout) |
35 | 44 |
36 def ExecuteJavaScript(self, expr, timeout=DEFAULT_WEB_CONTENTS_TIMEOUT): | 45 def ExecuteJavaScript(self, expr, timeout=DEFAULT_WEB_CONTENTS_TIMEOUT): |
(...skipping 27 matching lines...) Expand all Loading... |
64 | 73 |
65 @property | 74 @property |
66 def timeline_model(self): | 75 def timeline_model(self): |
67 return self._inspector_backend.timeline_model | 76 return self._inspector_backend.timeline_model |
68 | 77 |
69 def StartTimelineRecording(self): | 78 def StartTimelineRecording(self): |
70 self._inspector_backend.StartTimelineRecording() | 79 self._inspector_backend.StartTimelineRecording() |
71 | 80 |
72 def StopTimelineRecording(self): | 81 def StopTimelineRecording(self): |
73 self._inspector_backend.StopTimelineRecording() | 82 self._inspector_backend.StopTimelineRecording() |
OLD | NEW |