Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Unified Diff: tools/chrome_proxy/webdriver/common.py

Issue 2538773004: Fix cmd line args override in common.py (Closed)
Patch Set: Fix style. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/chrome_proxy/webdriver/common.py
diff --git a/tools/chrome_proxy/webdriver/common.py b/tools/chrome_proxy/webdriver/common.py
index 794918fcddcedfbfa3a24e996a32d86efd568b8e..79bc3ced86d898a8d5f31fecbed1191a5bbe3fc2 100644
--- a/tools/chrome_proxy/webdriver/common.py
+++ b/tools/chrome_proxy/webdriver/common.py
@@ -77,16 +77,30 @@ class TestDriver:
def _OverrideChromeArgs(self):
"""
- Overrides any given flags in the code with those given on the command line.
+ Overrides any given arguments in the code with those given on the command
+ line. Arguments that need to be overridden may contain different values for
+ a flag given in the code. In that case, check by the flag whether to
+ override the argument.
"""
+ def GetDictKey(argument):
+ return argument.split('=', 1)[0]
if self._flags.browser_args and len(self._flags.browser_args) > 0:
- for arg in shlex.split(self._flags.browser_args):
- self._chrome_args.add(arg)
+ # Build a dict of flags mapped to the whole argument.
+ original_args = {}
+ for arg in self._chrome_args:
+ original_args[GetDictKey(arg)] = arg
+ # Override by flag.
+ for override_arg in shlex.split(self._flags.browser_args[0]):
+ arg_key = GetDictKey(override_arg)
+ if arg_key in original_args:
+ self._chrome_args.remove(original_args[arg_key])
+ self._chrome_args.add(override_arg)
def _StartDriver(self):
"""
Parses the flags to pass to Chromium, then starts the ChromeDriver.
"""
+ self._OverrideChromeArgs()
options = Options()
for arg in self._chrome_args:
options.add_argument(arg)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698