| 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 import logging | 5 import logging |
| 6 import os | 6 import os |
| 7 import sys | 7 import sys |
| 8 import tempfile | 8 import tempfile |
| 9 import time | 9 import time |
| 10 | 10 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 def Run(self, options, page, tab, results): | 40 def Run(self, options, page, tab, results): |
| 41 # When recording, sleep to catch any resources that load post-onload. | 41 # When recording, sleep to catch any resources that load post-onload. |
| 42 tab.WaitForDocumentReadyStateToBeComplete() | 42 tab.WaitForDocumentReadyStateToBeComplete() |
| 43 time.sleep(3) | 43 time.sleep(3) |
| 44 | 44 |
| 45 # Run the actions for all measurements. Reload the page between | 45 # Run the actions for all measurements. Reload the page between |
| 46 # actions. | 46 # actions. |
| 47 should_reload = False | 47 should_reload = False |
| 48 for compound_action in self._CompoundActionsForPage(page): | 48 for compound_action in self._CompoundActionsForPage(page): |
| 49 if should_reload: | 49 if should_reload: |
| 50 tab.Navigate(page.url) | 50 self.RunNavigateSteps(page, tab) |
| 51 tab.WaitForDocumentReadyStateToBeComplete() | |
| 52 self._RunCompoundAction(page, tab, compound_action) | 51 self._RunCompoundAction(page, tab, compound_action) |
| 53 should_reload = True | 52 should_reload = True |
| 54 | 53 |
| 55 def _CompoundActionsForPage(self, page): | 54 def _CompoundActionsForPage(self, page): |
| 56 actions = [] | 55 actions = [] |
| 57 for action_name in self._action_names: | 56 for action_name in self._action_names: |
| 58 if not hasattr(page, action_name): | 57 if not hasattr(page, action_name): |
| 59 continue | 58 continue |
| 60 actions.append(page_test.GetCompoundActionFromPage(page, action_name)) | 59 actions.append(page_test.GetCompoundActionFromPage(page, action_name)) |
| 61 return actions | 60 return actions |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 'updated for these pages.') | 112 'updated for these pages.') |
| 114 logging.warning('Skipped pages:\n%s', '\n'.join(zip(*results.skipped)[0])) | 113 logging.warning('Skipped pages:\n%s', '\n'.join(zip(*results.skipped)[0])) |
| 115 | 114 |
| 116 if results.successes: | 115 if results.successes: |
| 117 # Update the metadata for the pages which were recorded. | 116 # Update the metadata for the pages which were recorded. |
| 118 ps.wpr_archive_info.AddRecordedPages(results.successes) | 117 ps.wpr_archive_info.AddRecordedPages(results.successes) |
| 119 else: | 118 else: |
| 120 os.remove(temp_target_wpr_file_path) | 119 os.remove(temp_target_wpr_file_path) |
| 121 | 120 |
| 122 return min(255, len(results.failures)) | 121 return min(255, len(results.failures)) |
| OLD | NEW |