Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wptrunner] Fix support for --binary-arg in Fx #13154

Merged
merged 2 commits into from
Sep 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 18 additions & 16 deletions tools/wpt/tests/test_wpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,23 +169,25 @@ def test_run_firefox(manifest_dir):
if is_port_8000_in_use():
pytest.skip("port 8000 already in use")

os.environ["MOZ_HEADLESS"] = "1"
try:
if sys.platform == "darwin":
fx_path = os.path.join(wpt.localpaths.repo_root, "_venv", "browsers", "nightly", "Firefox Nightly.app")
else:
fx_path = os.path.join(wpt.localpaths.repo_root, "_venv", "browsers", "nightly", "firefox")
if os.path.exists(fx_path):
shutil.rmtree(fx_path)
with pytest.raises(SystemExit) as excinfo:
wpt.main(argv=["run", "--no-pause", "--install-browser", "--yes",
"--metadata", manifest_dir,
"firefox", "/dom/nodes/Element-tagName.html"])
assert os.path.exists(fx_path)
if sys.platform == "darwin":
fx_path = os.path.join(wpt.localpaths.repo_root, "_venv", "browsers", "nightly", "Firefox Nightly.app")
else:
fx_path = os.path.join(wpt.localpaths.repo_root, "_venv", "browsers", "nightly", "firefox")
if os.path.exists(fx_path):
shutil.rmtree(fx_path)
assert excinfo.value.code == 0
finally:
del os.environ["MOZ_HEADLESS"]
with pytest.raises(SystemExit) as excinfo:
wpt.main(argv=["run", "--no-pause", "--install-browser", "--yes",
# The use of `--binary-args` is intentional: it
# demonstrates that internally-managed command-line
# arguments are properly merged with those specified by
# the user. See
# https://github.com/web-platform-tests/wpt/pull/13154
"--binary-arg=-headless",
"--metadata", manifest_dir,
"firefox", "/dom/nodes/Element-tagName.html"])
assert os.path.exists(fx_path)
shutil.rmtree(fx_path)
assert excinfo.value.code == 0


@pytest.mark.slow
Expand Down
6 changes: 4 additions & 2 deletions tools/wptrunner/wptrunner/browsers/firefox.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,11 @@ def start(self, group_metadata=None, **kwargs):
if self.ca_certificate_path is not None:
self.setup_ssl()

args = self.binary_args[:] if self.binary_args else []
args += [cmd_arg("marionette"), "about:blank"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we possibly want to check for duplicate arguments. It doesn't make much difference, but is a little cleaner.

If not any(item.strip("-/") == "marionette" for item in args):
  args += "--marionette"

Just appending about:blank is probably fine, although we might worry about args not starting with --, - or /, which would be interpreted as URLs and could in some future hypothetically start opening multiple tabs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we have a utility that's designated for creation of CLI arguments, I'd rather incorporate that:

marionette_flag = cmd_arg("marionette")
if not any(item == marionette_flag for item in args):
    args.append(marionette_flag)

...but I don't think this discussion should delay the bug fix. I'm also not sure how to relate the new behavior to the fix in the commit message. What do you think about deferring this for a follow-up patch?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That doesn't work because multiple variants are supported. The Firefox command line parser is something quite… special.

I'm OK on this not delaying the fix though.


debug_args, cmd = browser_command(self.binary,
self.binary_args if self.binary_args else [] +
[cmd_arg("marionette"), "about:blank"],
args,
self.debug_info)

self.runner = FirefoxRunner(profile=self.profile,
Expand Down