Make arguments of run-benchmark more user friendly
[WebKit-https.git] / Tools / Scripts / webkitpy / benchmark_runner / browser_driver / osx_safari_driver.py
index fdb906b4ce7a00b0f6a1082ff1ee3a69096053b8..62a365ac7f6d63ab131e203171635add1ff7782f 100644 (file)
@@ -23,11 +23,20 @@ class OSXSafariDriver(BrowserDriver):
         forceRemove(os.path.join(os.path.expanduser('~'), 'Library/Safari/LastSession.plist'))
         self.safariPreferences = ["-HomePage", "about:blank", "-WarnAboutFraudulentWebsites", "0", "-ExtensionsEnabled", "0", "-ShowStatusBar", "0", "-NewWindowBehavior", "1", "-NewTabBehavior", "1"]
 
-    def launchUrl(self, url, browserBuildPath=None):
-        args = [os.path.join(browserBuildPath, 'Safari.app/Contents/MacOS/Safari')]
+    def launchUrl(self, url, browserBuildPath):
+        args = ['/Applications/Safari.app/Contents/MacOS/SafariForWebKitDevelopment']
+        env = {}
+        if browserBuildPath:
+            safariAppInBuildPath = os.path.join(browserBuildPath, 'Safari.app/Contents/MacOS/Safari')
+            if os.path.exists(safariAppInBuildPath):
+                args = [safariAppInBuildPath]
+                env = {'DYLD_FRAMEWORK_PATH': browserBuildPath, 'DYLD_LIBRARY_PATH': browserBuildPath}
+            else:
+                _log.info('Could not find Safari.app at %s, using the system SafariForWebKitDevelopment in /Applications instead' % safariAppInBuildPath)
+
         args.extend(self.safariPreferences)
         _log.info('Launching safari: %s with url: %s' % (args[0], url))
-        self.safariProcess = subprocess.Popen(args, env={'DYLD_FRAMEWORK_PATH': browserBuildPath, 'DYLD_LIBRARY_PATH': browserBuildPath}, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+        self.safariProcess = subprocess.Popen(args, env=env, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
         # Stop for initialization of the safari process, otherwise, open
         # command may use the system safari.
         time.sleep(3)