From 45097b2058e1a0d5049c9b7789a91aa9ea4f09ae Mon Sep 17 00:00:00 2001 From: tonyg Date: Fri, 10 Oct 2014 17:09:56 -0700 Subject: [PATCH] [Telemetry] Restart browser in the case it hangs during unittests. This should unstick us if a unittest times out in a weird way. BUG=418577 Review URL: https://codereview.chromium.org/645233002 Cr-Commit-Position: refs/heads/master@{#299216} --- tools/telemetry/telemetry/unittest/tab_test_case.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/tools/telemetry/telemetry/unittest/tab_test_case.py b/tools/telemetry/telemetry/unittest/tab_test_case.py index 81a198c6b7b5..856b9c859f65 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] -- 2.11.4.GIT