run-benchmark should support Chrome Canary and Firefox Nightly
[WebKit-https.git] / Tools / Scripts / webkitpy / benchmark_runner / browser_driver / osx_browser_driver.py
1
2 import logging
3 import os
4 import subprocess
5
6 from AppKit import NSRunningApplication
7 from browser_driver import BrowserDriver
8
9
10 _log = logging.getLogger(__name__)
11
12
13 class OSXBrowserDriver(BrowserDriver):
14     bundleIdentifier = None
15
16     def prepareEnv(self):
17         self.closeBrowsers()
18
19     def closeBrowsers(self):
20         self.terminateProcesses(self.bundleIdentifier)
21
22     @classmethod
23     def launchProcess(cls, buildDir, appName, url, args):
24         if not buildDir:
25             buildDir = '/Applications/'
26         appPath = os.path.join(buildDir, appName)
27
28         _log.info('Launching "%s" with url "%s"' % (appPath, url))
29
30         # FIXME: May need to be modified for a local build such as setting up DYLD libraries
31         subprocess.Popen((['open', '-a', appPath] + args)).communicate()
32
33     @classmethod
34     def terminateProcesses(cls, bundleIdentifier):
35         _log.info('Closing all terminating all processes with the bundle identifier %s' % bundleIdentifier)
36         processes = NSRunningApplication.runningApplicationsWithBundleIdentifier_(bundleIdentifier)
37         for process in processes:
38             process.terminate()