Stop python icon bouncing in the dock while running browser benchmarks.
authordewei_zhu@apple.com <dewei_zhu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Aug 2016 05:12:51 +0000 (05:12 +0000)
committerdewei_zhu@apple.com <dewei_zhu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Aug 2016 05:12:51 +0000 (05:12 +0000)
https://bugs.webkit.org/show_bug.cgi?id=161066

Reviewed by Ryosuke Niwa.

Bouncing python icon may impact browser benchmark results.
* Scripts/webkitpy/benchmark_runner/browser_driver/osx_browser_driver.py:
(OSXBrowserDriver.prepare_env):
(OSXBrowserDriver.restore_env):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@204756 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_browser_driver.py
Tools/Scripts/webkitpy/benchmark_runner/utils.py

index 28e22ed..da82755 100644 (file)
@@ -1,3 +1,15 @@
+2016-08-22  Dewei Zhu  <dewei_zhu@apple.com>
+
+        Stop python icon bouncing in the dock while running browser benchmarks.
+        https://bugs.webkit.org/show_bug.cgi?id=161066
+
+        Reviewed by Ryosuke Niwa.
+
+        Bouncing python icon may impact browser benchmark results.
+        * Scripts/webkitpy/benchmark_runner/browser_driver/osx_browser_driver.py:
+        (OSXBrowserDriver.prepare_env):
+        (OSXBrowserDriver.restore_env):
+
 2016-08-22  Simon Fraser  <simon.fraser@apple.com>
 
         <select> menu on iPad causes shifting of hit-testing areas
index 48e1505..f1b3518 100644 (file)
@@ -4,6 +4,7 @@ import os
 import subprocess
 
 from browser_driver import BrowserDriver
+from webkitpy.benchmark_runner.utils import write_defaults
 
 
 _log = logging.getLogger(__name__)
@@ -17,9 +18,14 @@ class OSXBrowserDriver(BrowserDriver):
         self.close_browsers()
         from Quartz import CGWarpMouseCursorPosition
         CGWarpMouseCursorPosition((10, 0))
+        self.updated_dock_animation_defaults = write_defaults('com.apple.dock', 'launchanim', False)
+        if self.updated_dock_animation_defaults:
+            self._terminate_processes('Dock')
 
     def restore_env(self):
-        pass
+        if self.updated_dock_animation_defaults:
+            write_defaults('com.apple.dock', 'launchanim', True)
+            self._terminate_processes('Dock')
 
     def close_browsers(self):
         self._terminate_processes(self.process_name)
index a773ce2..d628f2b 100644 (file)
@@ -45,6 +45,23 @@ def force_remove(path):
         pass
 
 
+def write_defaults(domain, key, value):
+    # Returns whether the key in the domain is updated
+    from Foundation import NSUserDefaults
+    defaults = NSUserDefaults.standardUserDefaults()
+    defaults_for_domain = defaults.persistentDomainForName_(domain)
+    if not defaults_for_domain:
+        return False
+    old_value = defaults_for_domain.get(key)
+    if old_value == value:
+        return False
+    mutable_defaults_for_domain = defaults_for_domain.mutableCopy()
+    mutable_defaults_for_domain[key] = value
+    defaults.setPersistentDomain_forName_(mutable_defaults_for_domain, domain)
+    defaults.synchronize()
+    return True
+
+
 # Borrow this code from
 # 'http://stackoverflow.com/questions/2281850/timeout-function-if-it-takes-too-long-to-finish'
 class TimeoutError(Exception):