OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """PyAuto: Python Interface to Chromium's Automation Proxy. | 6 """PyAuto: Python Interface to Chromium's Automation Proxy. |
7 | 7 |
8 PyAuto uses swig to expose Automation Proxy interfaces to Python. | 8 PyAuto uses swig to expose Automation Proxy interfaces to Python. |
9 For complete documentation on the functionality available, | 9 For complete documentation on the functionality available, |
10 run pydoc on this file. | 10 run pydoc on this file. |
(...skipping 3362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3373 A list of dictionaries representing each password. For an example | 3373 A list of dictionaries representing each password. For an example |
3374 dictionary see AddSavedPassword documentation. The overall structure will | 3374 dictionary see AddSavedPassword documentation. The overall structure will |
3375 be: | 3375 be: |
3376 [ {password1 dictionary}, {password2 dictionary} ] | 3376 [ {password1 dictionary}, {password2 dictionary} ] |
3377 """ | 3377 """ |
3378 cmd_dict = { # Prepare command for the json interface | 3378 cmd_dict = { # Prepare command for the json interface |
3379 'command': 'GetSavedPasswords' | 3379 'command': 'GetSavedPasswords' |
3380 } | 3380 } |
3381 return self._GetResultFromJSONRequest(cmd_dict)['passwords'] | 3381 return self._GetResultFromJSONRequest(cmd_dict)['passwords'] |
3382 | 3382 |
3383 def GetBlockedPopupsInfo(self, tab_index=0, windex=0): | |
3384 """Get info about blocked popups in a tab. | |
3385 | |
3386 Args: | |
3387 tab_index: 0-based tab index. Default: 0 | |
3388 windex: 0-based window index. Default: 0 | |
3389 | |
3390 Returns: | |
3391 [a list of property dictionaries for each blocked popup] | |
3392 Property dictionary contains: title, url | |
3393 """ | |
3394 cmd_dict = { | |
3395 'command': 'GetBlockedPopupsInfo', | |
3396 'tab_index': tab_index, | |
3397 } | |
3398 return self._GetResultFromJSONRequest(cmd_dict, | |
3399 windex=windex)['blocked_popups'] | |
3400 | |
3401 def UnblockAndLaunchBlockedPopup(self, popup_index, tab_index=0, windex=0): | |
3402 """Unblock/launch a poup at the given index. | |
3403 | |
3404 This is equivalent to clicking on a blocked popup in the UI available | |
3405 from the omnibox. | |
3406 """ | |
3407 cmd_dict = { | |
3408 'command': 'UnblockAndLaunchBlockedPopup', | |
3409 'popup_index': popup_index, | |
3410 'tab_index': tab_index, | |
3411 } | |
3412 self._GetResultFromJSONRequest(cmd_dict, windex=windex) | |
3413 | |
3414 def ResetToDefaultTheme(self, windex=0): | 3383 def ResetToDefaultTheme(self, windex=0): |
3415 """Reset to default theme. | 3384 """Reset to default theme. |
3416 | 3385 |
3417 Args: | 3386 Args: |
3418 windex: Index of the window to reset; defaults to 0. | 3387 windex: Index of the window to reset; defaults to 0. |
3419 | 3388 |
3420 Raises: | 3389 Raises: |
3421 pyauto_errors.JSONInterfaceError if the automation call returns an error. | 3390 pyauto_errors.JSONInterfaceError if the automation call returns an error. |
3422 """ | 3391 """ |
3423 cmd_dict = { | 3392 cmd_dict = { |
(...skipping 3272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6696 successful = result.wasSuccessful() | 6665 successful = result.wasSuccessful() |
6697 if not successful: | 6666 if not successful: |
6698 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) | 6667 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) |
6699 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \ | 6668 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \ |
6700 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL) | 6669 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL) |
6701 sys.exit(not successful) | 6670 sys.exit(not successful) |
6702 | 6671 |
6703 | 6672 |
6704 if __name__ == '__main__': | 6673 if __name__ == '__main__': |
6705 Main() | 6674 Main() |
OLD | NEW |