OLD | NEW |
1 # Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2016 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 """Library handling DevTools websocket interaction. | 5 """Library handling DevTools websocket interaction. |
6 """ | 6 """ |
7 | 7 |
8 import httplib | 8 import httplib |
9 import json | 9 import json |
10 import logging | 10 import logging |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 Args: | 161 Args: |
162 method: (str) Method. | 162 method: (str) Method. |
163 params: (dict) Optional parameters to the request. | 163 params: (dict) Optional parameters to the request. |
164 """ | 164 """ |
165 result = self.SyncRequest(method, params) | 165 result = self.SyncRequest(method, params) |
166 if 'error' in result or ('result' in result and | 166 if 'error' in result or ('result' in result and |
167 result['result']): | 167 result['result']): |
168 raise DevToolsConnectionException( | 168 raise DevToolsConnectionException( |
169 'Unexpected response for %s: %s' % (method, result)) | 169 'Unexpected response for %s: %s' % (method, result)) |
170 | 170 |
| 171 def ClearCache(self): |
| 172 """Clears buffer cache. |
| 173 |
| 174 Will assert that the browser supports cache clearing. |
| 175 """ |
| 176 res = self.SyncRequest('Network.canClearBrowserCache') |
| 177 assert res['result'], 'Cache clearing is not supported by this browser.' |
| 178 self.SyncRequest('Network.clearBrowserCache') |
| 179 |
171 def SetUpMonitoring(self): | 180 def SetUpMonitoring(self): |
172 for domain in self._domains_to_enable: | 181 for domain in self._domains_to_enable: |
173 self._ws.RegisterDomain(domain, self._OnDataReceived) | 182 self._ws.RegisterDomain(domain, self._OnDataReceived) |
174 if domain != self.TRACING_DOMAIN: | 183 if domain != self.TRACING_DOMAIN: |
175 self.SyncRequestNoResponse('%s.enable' % domain) | 184 self.SyncRequestNoResponse('%s.enable' % domain) |
176 # Tracing setup must be done by the tracing track to control filtering | 185 # Tracing setup must be done by the tracing track to control filtering |
177 # and output. | 186 # and output. |
178 self._tearing_down_tracing = False | 187 self._tearing_down_tracing = False |
179 self._set_up = True | 188 self._set_up = True |
180 | 189 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 """Returns a Track instance constructed from data dumped by | 323 """Returns a Track instance constructed from data dumped by |
315 Track.ToJsonDict(). | 324 Track.ToJsonDict(). |
316 | 325 |
317 Args: | 326 Args: |
318 json_data: (dict) Parsed from a JSON file using the json module. | 327 json_data: (dict) Parsed from a JSON file using the json module. |
319 | 328 |
320 Returns: | 329 Returns: |
321 a Track instance. | 330 a Track instance. |
322 """ | 331 """ |
323 pass | 332 pass |
OLD | NEW |