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 | |
36 def WaitForDocumentReadyStateToBeComplete(self, | 27 def WaitForDocumentReadyStateToBeComplete(self, |
37 timeout=DEFAULT_WEB_CONTENTS_TIMEOUT): | 28 timeout=DEFAULT_WEB_CONTENTS_TIMEOUT): |
38 self._inspector_backend.WaitForDocumentReadyStateToBeComplete(timeout) | 29 self._inspector_backend.WaitForDocumentReadyStateToBeComplete(timeout) |
39 | 30 |
40 def WaitForDocumentReadyStateToBeInteractiveOrBetter(self, | 31 def WaitForDocumentReadyStateToBeInteractiveOrBetter(self, |
41 timeout=DEFAULT_WEB_CONTENTS_TIMEOUT): | 32 timeout=DEFAULT_WEB_CONTENTS_TIMEOUT): |
42 self._inspector_backend.WaitForDocumentReadyStateToBeInteractiveOrBetter( | 33 self._inspector_backend.WaitForDocumentReadyStateToBeInteractiveOrBetter( |
43 timeout) | 34 timeout) |
44 | 35 |
45 def ExecuteJavaScript(self, expr, timeout=DEFAULT_WEB_CONTENTS_TIMEOUT): | 36 def ExecuteJavaScript(self, expr, timeout=DEFAULT_WEB_CONTENTS_TIMEOUT): |
(...skipping 27 matching lines...) Expand all Loading... |
73 | 64 |
74 @property | 65 @property |
75 def timeline_model(self): | 66 def timeline_model(self): |
76 return self._inspector_backend.timeline_model | 67 return self._inspector_backend.timeline_model |
77 | 68 |
78 def StartTimelineRecording(self): | 69 def StartTimelineRecording(self): |
79 self._inspector_backend.StartTimelineRecording() | 70 self._inspector_backend.StartTimelineRecording() |
80 | 71 |
81 def StopTimelineRecording(self): | 72 def StopTimelineRecording(self): |
82 self._inspector_backend.StopTimelineRecording() | 73 self._inspector_backend.StopTimelineRecording() |
OLD | NEW |