run-benchmark should support Chrome Canary and Firefox Nightly
[WebKit-https.git] / Tools / Scripts / webkitpy / benchmark_runner / browser_driver / osx_chrome_driver.py
index 878b14071f58b8168b31940b1f04bc1f909e26e9..b85ec77f1410ae0295e71f6dbf976ca3fcde234f 100644 (file)
@@ -5,29 +5,21 @@ import os
 import subprocess
 import time
 
-# We assume that this handle can only be used when the platform is OSX
-from AppKit import NSRunningApplication
-from browser_driver import BrowserDriver
+from osx_browser_driver import OSXBrowserDriver
 
 
 _log = logging.getLogger(__name__)
 
 
-class OSXChromeDriver(BrowserDriver):
+class OSXChromeDriver(OSXBrowserDriver):
+    bundleIdentifier = 'com.google.Chrome'
 
-    def prepareEnv(self):
-        self.closeBrowsers()
-        self.chromePreferences = []
+    def launchUrl(self, url, browserBuildPath):
+        self.launchProcess(buildDir=browserBuildPath, appName='Google Chrome.app', url=url, args=['--args', '--homepage', url])
+
+
+class OSXChromeCanaryDriver(OSXBrowserDriver):
+    bundleIdentifier = 'com.google.Chrome.canary'
 
     def launchUrl(self, url, browserBuildPath):
-        if not browserBuildPath:
-            browserBuildPath = '/Applications/'
-        _log.info('Launching chrome: %s with url: %s' % (os.path.join(browserBuildPath, 'Google Chrome.app'), url))
-        # FIXME: May need to be modified for develop build, such as setting up libraries
-        subprocess.Popen(['open', '-a', os.path.join(browserBuildPath, 'Google Chrome.app'), '--args', '--homepage', url] + self.chromePreferences).communicate()
-
-    def closeBrowsers(self):
-        _log.info('Closing all existing chrome processes')
-        chromes = NSRunningApplication.runningApplicationsWithBundleIdentifier_('com.google.Chrome')
-        for chrome in chromes:
-            chrome.terminate()
+        self.launchProcess(buildDir=browserBuildPath, appName='Google Chrome Canary.app', url=url, args=['--args', '--homepage', url])