Diff
Modified: trunk/Tools/ChangeLog (287288 => 287289)
--- trunk/Tools/ChangeLog 2021-12-21 00:33:43 UTC (rev 287288)
+++ trunk/Tools/ChangeLog 2021-12-21 01:19:32 UTC (rev 287289)
@@ -1,3 +1,54 @@
+2021-12-20 Dewei Zhu <[email protected]>
+
+ 'run-benchmark' should launch browsers in a relative clean state.
+ https://bugs.webkit.org/show_bug.cgi?id=234107
+
+ Reviewed by Stephanie Lewis.
+
+ Add code to ensure Chrome and Firefox launches in a relative clean state.
+ Refactor browser drivers for macOS Chrome and Firefox to share more code.
+
+ * Scripts/webkitpy/benchmark_runner/browser_driver/osx_chrome_driver.py:
+ Added '--no-first-run', '--no-default-browser-check', '--disable-extensions' flags.
+ (OSXChromeDriverBase):
+ (OSXChromeDriverBase.launch_url):
+ (OSXChromeDriverBase.launch_driver):
+ (OSXChromeDriverBase._create_chrome_options):
+ (OSXChromeDriverBase._window_size_arg):
+ (OSXChromeDriverBase._set_chrome_binary_location):
+ (OSXChromeDriver):
+ (OSXChromeDriver._set_chrome_binary_location):
+ (OSXChromeCanaryDriver._set_chrome_binary_location):
+ (OSXChromeDriver.launch_url): Deleted.
+ (OSXChromeDriver.launch_driver): Deleted.
+ (OSXChromeCanaryDriver.launch_url): Deleted.
+ (OSXChromeCanaryDriver.launch_driver): Deleted.
+ (create_args): Deleted.
+ (create_chrome_options): Deleted.
+ (create_window_size_arg): Deleted.
+ * Scripts/webkitpy/benchmark_runner/browser_driver/osx_firefox_driver.py:
+ Added code to use profiles to suppress default browser check and privacy notice tab.
+ (OSXFirefoxDriverBase):
+ (OSXFirefoxDriverBase.__init__):
+ (OSXFirefoxDriverBase.prepare_env):
+ (OSXFirefoxDriverBase.restore_env):
+ (OSXFirefoxDriverBase.launch_url):
+ (OSXFirefoxDriverBase.launch_driver):
+ (OSXFirefoxDriverBase._setup_temporary_profile_directory):
+ (OSXFirefoxDriverBase._teardown_temporary_profile_directory):
+ (OSXFirefoxDriverBase._set_firefox_binary_location):
+ (OSXFirefoxDriver):
+ (OSXFirefoxDriver._set_firefox_binary_location):
+ (OSXFirefoxNightlyDriver):
+ (OSXFirefoxNightlyDriver._set_firefox_binary_location):
+ (OSXFirefoxDriver.launch_url): Deleted.
+ (OSXFirefoxDriver.launch_driver): Deleted.
+ (OSXFirefoxNightlyDriver.launch_url): Deleted.
+ (OSXFirefoxNightlyDriver.launch_driver): Deleted.
+ (create_args): Deleted.
+ * Scripts/webkitpy/benchmark_runner/data/firefox_profile/user.js: Added user preferences
+ so that Firefox can be launched without checking default browser and privacy notice.
+
2021-12-20 J Pascoe <[email protected]>
[WebAuthn] Add option to change requestWebAuthenticationNoGesture delegate for api tests.
Modified: trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_chrome_driver.py (287288 => 287289)
--- trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_chrome_driver.py 2021-12-21 00:33:43 UTC (rev 287288)
+++ trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_chrome_driver.py 2021-12-21 01:19:32 UTC (rev 287289)
@@ -9,30 +9,55 @@
_log = logging.getLogger(__name__)
-class OSXChromeDriver(OSXBrowserDriver):
- process_name = 'Google Chrome'
- browser_name = 'chrome'
- app_name = 'Google Chrome.app'
- bundle_id = 'com.google.Chrome'
+class OSXChromeDriverBase(OSXBrowserDriver):
+ app_name = None
def launch_url(self, url, options, browser_build_path, browser_path):
# FIXME: handle self._browser_path.
- args_with_url = self._insert_url(create_args(), 2, url)
+ args_with_url = ['--args', '--homepage', url, self._window_size_arg(), '--no-first-run',
+ '--no-default-browser-check', '--disable-extensions']
self._launch_process(build_dir=browser_build_path, app_name=self.app_name, url="" args=args_with_url)
def launch_driver(self, url, options, browser_build_path):
from selenium import webdriver
- chrome_options = create_chrome_options()
- if browser_build_path:
- app_path = os.path.join(browser_build_path, self.app_name)
- binary_path = os.path.join(app_path, "Contents/MacOS", self.process_name)
- chrome_options.binary_location = binary_path
+ chrome_options = self._create_chrome_options(browser_build_path)
driver_executable = self.webdriver_binary_path
driver = webdriver.Chrome(chrome_options=chrome_options, executable_path=driver_executable)
self._launch_webdriver(url="" driver=driver)
return driver
+ def _create_chrome_options(self, browser_build_path):
+ from selenium.webdriver.chrome.options import Options
+ chrome_options = Options()
+ chrome_options.add_argument("--disable-web-security")
+ chrome_options.add_argument("--user-data-dir")
+ chrome_options.add_argument("--disable-extensions")
+ chrome_options.add_argument(self._window_size_arg())
+ self._set_chrome_binary_location(chrome_options, browser_build_path)
+ return chrome_options
+ def _window_size_arg(self):
+ screen_size = self._screen_size()
+ return '--window-size={width},{height}'.format(width=int(screen_size.width), height=int(screen_size.height))
+
+ def _set_chrome_binary_location(self, options, browser_build_path):
+ pass
+
+
+class OSXChromeDriver(OSXChromeDriverBase):
+ process_name = 'Google Chrome'
+ browser_name = 'chrome'
+ app_name = 'Google Chrome.app'
+ bundle_id = 'com.google.Chrome'
+
+ def _set_chrome_binary_location(self, options, browser_build_path):
+ if not browser_build_path:
+ return
+ app_path = os.path.join(browser_build_path, self.app_name)
+ binary_path = os.path.join(app_path, "Contents/MacOS", self.process_name)
+ options.binary_location = binary_path
+
+
class OSXChromeCanaryDriver(OSXBrowserDriver):
process_name = 'Google Chrome Canary'
browser_name = 'chrome-canary'
@@ -39,40 +64,9 @@
app_name = 'Google Chrome Canary.app'
bundle_id = 'com.google.Chrome.canary'
- def launch_url(self, url, options, browser_build_path, browser_path):
- # FIXME: handle self._browser_path.
- args_with_url = self._insert_url(create_args(), 2, url)
- self._launch_process(build_dir=browser_build_path, app_name=self.app_name, url="" args=args_with_url)
-
- def launch_driver(self, url, options, browser_build_path):
- from selenium import webdriver
- chrome_options = create_chrome_options()
+ def _set_chrome_binary_location(self, options, browser_build_path):
if not browser_build_path:
browser_build_path = '/Applications/'
app_path = os.path.join(browser_build_path, self.app_name)
binary_path = os.path.join(app_path, "Contents/MacOS", self.process_name)
- chrome_options.binary_location = binary_path
- driver_executable = self.webdriver_binary_path
- driver = webdriver.Chrome(chrome_options=chrome_options, executable_path=driver_executable)
- self._launch_webdriver(url="" driver=driver)
- return driver
-
-
-def create_args():
- args = ['--args', '--homepage', create_window_size_arg()]
- return args
-
-
-def create_chrome_options():
- from selenium.webdriver.chrome.options import Options
- chrome_options = Options()
- chrome_options.add_argument("--disable-web-security")
- chrome_options.add_argument("--user-data-dir")
- chrome_options.add_argument("--disable-extensions")
- chrome_options.add_argument(create_window_size_arg())
- return chrome_options
-
-
-def create_window_size_arg():
- window_size_arg = '--window-size={width},{height}'.format(width=int(OSXBrowserDriver._screen_size().width), height=int(OSXBrowserDriver._screen_size().height))
- return window_size_arg
+ options.binary_location = binary_path
Modified: trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_firefox_driver.py (287288 => 287289)
--- trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_firefox_driver.py 2021-12-21 00:33:43 UTC (rev 287288)
+++ trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_firefox_driver.py 2021-12-21 01:19:32 UTC (rev 287289)
@@ -2,22 +2,38 @@
import logging
import os
+import shutil
+import tempfile
from webkitpy.benchmark_runner.browser_driver.osx_browser_driver import OSXBrowserDriver
_log = logging.getLogger(__name__)
+test_profile_directory = os.path.join(os.path.dirname(__file__), '../data/firefox_profile/')
-class OSXFirefoxDriver(OSXBrowserDriver):
- process_name = 'firefox'
- browser_name = 'firefox'
- app_name = 'Firefox.app'
- bundle_id = 'org.mozilla.firefox'
+class OSXFirefoxDriverBase(OSXBrowserDriver):
+ app_name = None
+ def __init__(self, *args, **kwargs):
+ super(OSXFirefoxDriverBase, self).__init__(*args, **kwargs)
+ self._profile_directory = None
+
+ def prepare_env(self, config):
+ super(OSXFirefoxDriverBase, self).prepare_env(config)
+ self._setup_temporary_profile_directory()
+
+ def restore_env(self):
+ super(OSXFirefoxDriverBase, self).restore_env()
+ self._teardown_temporary_profile_directory()
+
def launch_url(self, url, options, browser_build_path, browser_path):
# FIXME: handle self._browser_path.
- args_with_url = self._insert_url(create_args(), 0, url)
+ screen_size = self._screen_size()
+ args_with_url = ['--args', '-width', str(int(screen_size.width)), '-height', str(int(screen_size.height))]
+ if self._profile_directory and os.path.exists(self._profile_directory):
+ args_with_url.extend(['--profile', self._profile_directory])
+ args_with_url.append(url)
self._launch_process(build_dir=browser_build_path, app_name=self.app_name, url="" args=args_with_url)
def launch_driver(self, url, options, browser_build_path):
@@ -24,43 +40,47 @@
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
firefox_options = Options()
- if browser_build_path:
- app_path = os.path.join(browser_build_path, self.app_name)
- binary_path = os.path.join(app_path, "Contents/MacOS", self.process_name)
- firefox_options.binary_location = binary_path
+ self._set_firefox_binary_location(options, browser_build_path)
driver_executable = self.webdriver_binary_path
driver = webdriver.Firefox(firefox_options=firefox_options, executable_path=driver_executable)
self._launch_webdriver(url="" driver=driver)
return driver
+ def _setup_temporary_profile_directory(self):
+ self._profile_directory = os.path.join(tempfile.mkdtemp(), 'firefox_profile')
+ shutil.copytree(test_profile_directory, self._profile_directory)
-class OSXFirefoxNightlyDriver(OSXBrowserDriver):
+ def _teardown_temporary_profile_directory(self):
+ if self._profile_directory and os.path.exists(self._profile_directory):
+ shutil.rmtree(os.path.dirname(self._profile_directory))
+
+ def _set_firefox_binary_location(self, options, browser_build_path):
+ pass
+
+
+class OSXFirefoxDriver(OSXFirefoxDriverBase):
process_name = 'firefox'
+ browser_name = 'firefox'
+ app_name = 'Firefox.app'
+ bundle_id = 'org.mozilla.firefox'
+
+ def _set_firefox_binary_location(self, options, browser_build_path):
+ if not browser_build_path:
+ return
+ app_path = os.path.join(browser_build_path, self.app_name)
+ binary_path = os.path.join(app_path, "Contents/MacOS", self.process_name)
+ options.binary_location = binary_path
+
+
+class OSXFirefoxNightlyDriver(OSXFirefoxDriverBase):
+ process_name = 'firefox'
browser_name = 'firefox-nightly'
app_name = 'FirefoxNightly.app'
bundle_id = 'org.mozilla.firefox'
-
- def launch_url(self, url, options, browser_build_path, browser_path):
- # FIXME: handle self._browser_path.
- args_with_url = self._insert_url(create_args(), 0, url)
- self._launch_process(build_dir=browser_build_path, app_name=self.app_name, url="" args=args_with_url)
-
- def launch_driver(self, url, options, browser_build_path):
- from selenium import webdriver
- from selenium.webdriver.firefox.options import Options
- firefox_options = Options()
+ def _set_firefox_binary_location(self, options, browser_build_path):
if not browser_build_path:
browser_build_path = '/Applications/'
app_path = os.path.join(browser_build_path, self.app_name)
binary_path = os.path.join(app_path, "Contents/MacOS", self.process_name)
- firefox_options.binary_location = binary_path
- driver_executable = self.webdriver_binary_path
- driver = webdriver.Firefox(firefox_options=firefox_options, executable_path=driver_executable)
- self._launch_webdriver(url="" driver=driver)
- return driver
-
-
-def create_args():
- args = ['--args', '-width', str(int(OSXBrowserDriver._screen_size().width)), '-height', str(int(OSXBrowserDriver._screen_size().height))]
- return args
+ options.binary_location = binary_path
Added: trunk/Tools/Scripts/webkitpy/benchmark_runner/data/firefox_profile/user.js (0 => 287289)
--- trunk/Tools/Scripts/webkitpy/benchmark_runner/data/firefox_profile/user.js (rev 0)
+++ trunk/Tools/Scripts/webkitpy/benchmark_runner/data/firefox_profile/user.js 2021-12-21 01:19:32 UTC (rev 287289)
@@ -0,0 +1,9 @@
+user_pref("browser.shell.checkDefaultBrowser", false);
+user_pref("browser.startup.couldRestoreSession.count", -1);
+user_pref("browser.webapps.checkForUpdates", 0);
+user_pref("startup.homepage_welcome_url", "");
+user_pref("startup.homepage_welcome_url.additional", "");
+user_pref("app.update.checkInstallTime", false);
+user_pref("app.update.disabledForTesting", true);
+user_pref("extensions.update.enabled", false);
+user_pref("datareporting.policy.dataSubmissionPolicyBypassNotification", true);
\ No newline at end of file