Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Unified Diff: tools/telemetry/telemetry/unittest/tab_test_case.py

Issue 645233002: [Telemetry] Restart browser in the case it hangs during unittests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Catch TimeoutException Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/unittest/tab_test_case.py
diff --git a/tools/telemetry/telemetry/unittest/tab_test_case.py b/tools/telemetry/telemetry/unittest/tab_test_case.py
index 81a198c6b7b5d03347b3fe9903d27c957c30d43b..856b9c859f654aa19f04423ffeb799ca48796bbe 100644
--- a/tools/telemetry/telemetry/unittest/tab_test_case.py
+++ b/tools/telemetry/telemetry/unittest/tab_test_case.py
@@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+from telemetry.core import util
from telemetry.unittest import browser_test_case
@@ -14,14 +15,14 @@ class TabTestCase(browser_test_case.BrowserTestCase):
super(TabTestCase, self).setUp()
if self._browser.supports_tab_control:
- self._tab = self._browser.tabs.New()
- while len(self._browser.tabs) > 1:
- self._browser.tabs[0].Close()
+ try:
+ self._tab = self._browser.tabs.New()
+ while len(self._browser.tabs) > 1:
+ self._browser.tabs[0].Close()
+ except util.TimeoutException:
+ self._RestartBrowser()
else:
- if not self._browser.tabs:
- self.tearDownClass()
- self.setUpClass()
- self._tab = self._browser.tabs[0]
+ self._RestartBrowser()
self._tab.Navigate('about:blank')
self._tab.WaitForDocumentReadyStateToBeInteractiveOrBetter()
@@ -33,3 +34,9 @@ class TabTestCase(browser_test_case.BrowserTestCase):
url = self.UrlOfUnittestFile(filename)
self._tab.Navigate(url, script_to_evaluate_on_commit)
self._tab.WaitForDocumentReadyStateToBeComplete()
+
+ def _RestartBrowser(self):
+ if not self._browser.tabs:
+ self.tearDownClass()
+ self.setUpClass()
+ self._tab = self._browser.tabs[0]
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698