| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 import time | 4 import time |
| 5 | 5 |
| 6 from profile_creators import profile_extender | 6 from profile_creators import profile_extender |
| 7 from telemetry.core import exceptions | 7 from telemetry.core import exceptions |
| 8 from telemetry.core import util | 8 from telemetry.core import util |
| 9 | 9 |
| 10 | 10 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 def _RemoveNavigationTab(self, tab): | 113 def _RemoveNavigationTab(self, tab): |
| 114 """Removes a tab which is no longer in a useable state from | 114 """Removes a tab which is no longer in a useable state from |
| 115 self._navigation_tabs. The tab is not removed from self.browser.tabs, | 115 self._navigation_tabs. The tab is not removed from self.browser.tabs, |
| 116 since there is no guarantee that the tab can be safely removed.""" | 116 since there is no guarantee that the tab can be safely removed.""" |
| 117 self._navigation_tabs.remove(tab) | 117 self._navigation_tabs.remove(tab) |
| 118 | 118 |
| 119 def _RetrieveTabUrl(self, tab, timeout): | 119 def _RetrieveTabUrl(self, tab, timeout): |
| 120 """Retrives the URL of the tab.""" | 120 """Retrives the URL of the tab.""" |
| 121 # TODO(erikchen): Use tab.url instead, which talks to the browser process | 121 # TODO(erikchen): Use tab.url instead, which talks to the browser process |
| 122 # instead of the renderer process. http://crbug.com/486119 | 122 # instead of the renderer process. http://crbug.com/486119 |
| 123 return tab.EvaluateJavaScript2('document.URL', timeout=timeout) | 123 return tab.EvaluateJavaScript('document.URL', timeout=timeout) |
| 124 | 124 |
| 125 def _WaitForUrlToChange(self, tab, initial_url, end_time): | 125 def _WaitForUrlToChange(self, tab, initial_url, end_time): |
| 126 """Waits for the tab to navigate away from its initial url. | 126 """Waits for the tab to navigate away from its initial url. |
| 127 | 127 |
| 128 If time.time() is larger than end_time, the function does nothing. | 128 If time.time() is larger than end_time, the function does nothing. |
| 129 Otherwise, the function tries to return no later than end_time. | 129 Otherwise, the function tries to return no later than end_time. |
| 130 """ | 130 """ |
| 131 while True: | 131 while True: |
| 132 seconds_to_wait = end_time - time.time() | 132 seconds_to_wait = end_time - time.time() |
| 133 if seconds_to_wait <= 0: | 133 if seconds_to_wait <= 0: |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 tab = self._navigation_tabs[i] | 236 tab = self._navigation_tabs[i] |
| 237 batch.append((tab, url)) | 237 batch.append((tab, url)) |
| 238 | 238 |
| 239 queued_tabs = self._BatchNavigateTabs(batch) | 239 queued_tabs = self._BatchNavigateTabs(batch) |
| 240 self._WaitForQueuedTabsToLoad(queued_tabs) | 240 self._WaitForQueuedTabsToLoad(queued_tabs) |
| 241 | 241 |
| 242 self.CleanUpAfterBatchNavigation() | 242 self.CleanUpAfterBatchNavigation() |
| 243 | 243 |
| 244 if self.ShouldExitAfterBatchNavigation(): | 244 if self.ShouldExitAfterBatchNavigation(): |
| 245 break | 245 break |
| OLD | NEW |