summaryrefslogtreecommitdiffstats
path: root/chrome/test/functional
diff options
context:
space:
mode:
authoralyssad@chromium.org <alyssad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-30 21:53:35 +0000
committeralyssad@chromium.org <alyssad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-30 21:53:35 +0000
commit8b081042290a48ce3c6b0a41071643175d17ae40 (patch)
tree85bbc17f92afcd2dafcda7ef5022d019275d4d09 /chrome/test/functional
parentc8647278668f33fc76900483ecf01ea9f34abde9 (diff)
downloadchromium_src-8b081042290a48ce3c6b0a41071643175d17ae40.zip
chromium_src-8b081042290a48ce3c6b0a41071643175d17ae40.tar.gz
chromium_src-8b081042290a48ce3c6b0a41071643175d17ae40.tar.bz2
Refine the tool so that, it binary searches for the extensions that crashes the browser (if there is one).
Review URL: http://codereview.chromium.org/3060021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54391 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/functional')
-rw-r--r--chrome/test/functional/extensions.py81
1 files changed, 59 insertions, 22 deletions
diff --git a/chrome/test/functional/extensions.py b/chrome/test/functional/extensions.py
index b5584d3..785f9af 100644
--- a/chrome/test/functional/extensions.py
+++ b/chrome/test/functional/extensions.py
@@ -9,9 +9,9 @@ browser crashes while visiting a list of urls.
Usage: python extensions.py -v
-Note: This assumes that there is a directory of extensions in called
-'extensions' and that there is a file of newline-separated urls to visit called
-'urls.txt' in the same directory as the script.
+Note: This assumes that there is a directory of extensions called 'extensions'
+and that there is a file of newline-separated urls to visit called 'urls.txt'
+in the same directory as the script.
"""
import glob
@@ -29,38 +29,75 @@ class ExtensionsTest(pyauto.PyUITest):
extensions_dir_ = 'extensions' # The directory of extensions
urls_file_ = 'urls.txt' # The file which holds a list of urls to visit
- def testExtensionCrashes(self):
- """Add top extensions; confirm browser stays up when visiting top urls"""
- self.assertTrue(os.path.exists(self.extensions_dir_),
- 'The dir "%s" must exist' % os.path.abspath(self.extensions_dir_))
- self.assertTrue(os.path.exists(self.urls_file_),
- 'The file "%s" must exist' % os.path.abspath(self.urls_file_))
-
- extensions_group_size = 20
- num_urls_to_visit = 100
+ def _ReturnCrashingExtensions(self, extensions, group_size, top_urls):
+ """Install the given extensions in groups of group_size and return the
+ group of extensions that crashes (if any).
- extensions = glob.glob(os.path.join(self.extensions_dir_, '*.crx'))
- top_urls = [l.rstrip() for l in open(self.urls_file_).readlines()]
+ Args:
+ extensions: A list of extensions to install.
+ group_size: The number of extensions to install at one time.
+ top_urls: The list of top urls to visit.
+ Returns:
+ The extensions in the crashing group or None if there is no crash.
+ """
curr_extension = 0
num_extensions = len(extensions)
+ self.RestartBrowser()
while curr_extension < num_extensions:
- logging.debug('New group of %d extensions.' % extensions_group_size)
- group_end = curr_extension + extensions_group_size
+ logging.debug('New group of %d extensions.' % group_size)
+ group_end = curr_extension + group_size
for extension in extensions[curr_extension:group_end]:
logging.debug('Installing extension: %s' % extension)
self.InstallExtension(pyauto.FilePath(extension), False)
- # Navigate to the top urls and verify there is still one window
- for url in top_urls[:num_urls_to_visit]:
+ for url in top_urls:
self.NavigateToURL(url)
- # Assert that there is at least 1 browser window.
- self.assertTrue(self.GetBrowserWindowCount(),
- 'Extensions in failing group: %s' %
- extensions[curr_extension:group_end])
+
+ def _LogAndReturnCrashing():
+ crashing_extensions = extensions[curr_extension:group_end]
+ logging.debug('Crashing extensions: %s' % crashing_extensions)
+ return crashing_extensions
+
+ # If the browser has crashed, return the extensions in the failing group.
+ try:
+ num_browser_windows = self.GetBrowserWindowCount()
+ except:
+ return _LogAndReturnCrashing()
+ else:
+ if not num_browser_windows:
+ return _LogAndReturnCrashing()
+
curr_extension = group_end
+ # None of the extensions crashed.
+ return None
+
+ def testExtensionCrashes(self):
+ """Add top extensions; confirm browser stays up when visiting top urls"""
+ self.assertTrue(os.path.exists(self.extensions_dir_),
+ 'The dir "%s" must exist' % os.path.abspath(self.extensions_dir_))
+ self.assertTrue(os.path.exists(self.urls_file_),
+ 'The file "%s" must exist' % os.path.abspath(self.urls_file_))
+
+ num_urls_to_visit = 100
+ extensions_group_size = 20
+
+ top_urls = [l.rstrip() for l in
+ open(self.urls_file_).readlines()[:num_urls_to_visit]]
+
+ failed_extensions = glob.glob(os.path.join(self.extensions_dir_, '*.crx'))
+ group_size = extensions_group_size
+
+ while(group_size and failed_extensions):
+ failed_extensions = self._ReturnCrashingExtensions(
+ failed_extensions, group_size, top_urls)
+ group_size = group_size // 2
+
+ self.assertFalse(failed_extensions,
+ 'Extension(s) in failing group: %s' % failed_extensions)
+
if __name__ == '__main__':
pyauto_functional.Main()