Blame testing/geckodriver/CONTRIBUTING.md

Packit f0b94e
Contributing
Packit f0b94e
============
Packit f0b94e
Packit f0b94e
We are delighted that you want to help improve geckodriver!
Packit f0b94e
Mozilla’s WebDriver implementation consists of a few different
Packit f0b94e
parts it can be useful to know about:
Packit f0b94e
Packit f0b94e
  * [_geckodriver_] provides the HTTP API described by the [WebDriver
Packit f0b94e
    protocol] to communicate with Gecko-based browsers such as
Packit f0b94e
    Firefox and Fennec.  It is a standalone executable written in
Packit f0b94e
    Rust, and can be used with compatible W3C WebDriver clients.
Packit f0b94e
Packit f0b94e
  * [_Marionette_] is the Firefox remote protocol used by geckodriver
Packit f0b94e
    to communicate with, instrument, and control Gecko.  It is
Packit f0b94e
    built in to Firefox and written in [XPCOM] flavoured JavaScript.
Packit f0b94e
Packit f0b94e
  * [_webdriver_] is a Rust crate providing interfaces, traits
Packit f0b94e
    and types, errors, type- and bounds checks, and JSON marshaling
Packit f0b94e
    for correctly parsing and emitting the [WebDriver protocol].
Packit f0b94e
Packit f0b94e
By participating in this project, you agree to abide by the Mozilla
Packit f0b94e
[Community Participation Guidelines].  Here are some guidelines
Packit f0b94e
for contributing high-quality and actionable bugs and code.
Packit f0b94e
Packit f0b94e
[_geckodriver_]: https://firefox-source-docs.mozilla.org/testing/geckodriver/geckodriver/
Packit f0b94e
[_Marionette_]: https://firefox-source-docs.mozilla.org/testing/marionette/marionette/
Packit f0b94e
[_webdriver_]: https://crates.io/crates/webdriver
Packit f0b94e
[WebDriver protocol]: https://w3c.github.io/webdriver/webdriver-spec.html#protocol
Packit f0b94e
[XPCOM]: https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Guide
Packit f0b94e
[Community Participation Guidelines]: https://www.mozilla.org/en-US/about/governance/policies/participation/
Packit f0b94e
Packit f0b94e
Packit f0b94e
Reporting bugs
Packit f0b94e
==============
Packit f0b94e
Packit f0b94e
When opening a new issue or commenting on existing issues, please
Packit f0b94e
make sure discussions are related to concrete technical issues
Packit f0b94e
with geckodriver or Marionette.  Questions or discussions are more
Packit f0b94e
appropriate for the [mailing list].
Packit f0b94e
Packit f0b94e
For issue reports to be actionable, it must be clear exactly
Packit f0b94e
what the observed and expected behaviours are, and how to set up
Packit f0b94e
the state required to observe the erroneous behaviour.  The most
Packit f0b94e
useful thing to provide is a minimal HTML document which permits
Packit f0b94e
the problem to be reproduced along with a [trace-level log] from
Packit f0b94e
geckodriver showing the exact wire protocol calls made.
Packit f0b94e
Packit f0b94e
Because of the wide variety and different charateristics of clients
Packit f0b94e
used with geckodriver, their stacktraces, logs, and code examples are
Packit f0b94e
typically not very useful as they distract from the actual underlying
Packit f0b94e
cause.  **For this reason, we cannot overstate the importance of
Packit f0b94e
always providing the [trace-level log] from geckodriver.** Bugs
Packit f0b94e
relating to a specific client should be filed with that project.
Packit f0b94e
Packit f0b94e
We welcome you to file issues in the [GitHub issue tracker] once you are
Packit f0b94e
confident it has not already been reported.  The [ISSUE_TEMPLATE.md]
Packit f0b94e
contains a helpful checklist for things we will want to know about
Packit f0b94e
the affected system, reproduction steps, and logs.
Packit f0b94e
Packit f0b94e
geckodriver development follows a rolling release model as we don’t
Packit f0b94e
release patches for older versions.  It is therefore useful to use
Packit f0b94e
the tip-of-tree geckodriver binary, or failing this, the latest
Packit f0b94e
release when verifying the problem.  geckodriver is only compatible
Packit f0b94e
with the current release channel versions of Firefox, and it
Packit f0b94e
consequently does not help to report bugs that affect outdated and
Packit f0b94e
unsupported Firefoxen.  Please always try to verify the issue in
Packit f0b94e
the latest Firefox Nightly before you file your bug.
Packit f0b94e
Packit f0b94e
Once we are satisfied the issue raised is of sufficiently actionable
Packit f0b94e
character, we will continue with triaging it and file a bug where it
Packit f0b94e
is appropriate.  Bugs specific to geckodriver will be filed in the
Packit f0b94e
[`Testing :: geckodriver`] component in Bugzilla.
Packit f0b94e
Packit f0b94e
[mailing list]: #communication
Packit f0b94e
[trace-level log]: https://firefox-source-docs.mozilla.org/testing/geckodriver/geckodriver/TraceLogs.html
Packit f0b94e
[GitHub issue tracker]: https://github.com/mozilla/geckodriver/issues
Packit f0b94e
[`Testing :: geckodriver`]: https://bugzilla.mozilla.org/buglist.cgi?component=geckodriver
Packit f0b94e
Packit f0b94e
Packit f0b94e
Writing code
Packit f0b94e
============
Packit f0b94e
Packit f0b94e
Because there are many moving parts involved remote controlling
Packit f0b94e
a web browser, it can be challenging to a new contributor to know
Packit f0b94e
where to start.  Please don’t hesitate to [ask questions]!
Packit f0b94e
Packit f0b94e
The canonical source code repository of geckodriver is now
Packit f0b94e
[mozilla-central].  We continue to use the [GitHub issue tracker] as
Packit f0b94e
a triage ground before actual, actionable bugs and tasks are filed
Packit f0b94e
in the [`Testing :: geckodriver`] component on Bugzilla.  We also
Packit f0b94e
have a curated set of [good first bugs] you may consider attempting first.
Packit f0b94e
Packit f0b94e
The purpose of this guide _is not_ to make sure you have a basic
Packit f0b94e
development environment set up.  For that there is plentiful
Packit f0b94e
documentation, such as the [Developer Guide] to get you rolling.
Packit f0b94e
Once you do, we can get started working up your first patch!
Packit f0b94e
Remember to [reach out to us] at any point if you have questions.
Packit f0b94e
Packit f0b94e
[ask questions]: #communication
Packit f0b94e
[reach out to us]: #communication
Packit f0b94e
[mozilla-central]: https://searchfox.org/mozilla-central/source/testing/geckodriver/
Packit f0b94e
[good first bugs]: https://www.joshmatthews.net/bugsahoy/?automation=1&rust=1
Packit f0b94e
[Developer Guide]: https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide
Packit f0b94e
Packit f0b94e
Packit f0b94e
Building geckodriver
Packit f0b94e
--------------------
Packit f0b94e
Packit f0b94e
geckodriver is written in [Rust], a systems programming language
Packit f0b94e
from Mozilla.  Crucially, it relies on the [webdriver crate] to
Packit f0b94e
provide the HTTPD and do most of the heavy lifting of marshalling the
Packit f0b94e
[WebDriver protocol].  geckodriver translates WebDriver [commands],
Packit f0b94e
[responses], and [errors] to the [Marionette protocol], and acts
Packit f0b94e
as a proxy between WebDriver clients and [Marionette].
Packit f0b94e
Packit f0b94e
Whilst geckodriver lives in the same source repository as Firefox
Packit f0b94e
and is built in the [Firefox CI], is _is not_ built if you build
Packit f0b94e
Firefox locally.  To enable building of geckodriver locally, ensure
Packit f0b94e
you put this in your [mozconfig]:
Packit f0b94e
Packit f0b94e
	ac_add_options --enable-geckodriver
Packit f0b94e
Packit f0b94e
When you have, you are ready to start off your first build:
Packit f0b94e
Packit f0b94e
	% ./mach build testing/geckodriver
Packit f0b94e
Packit f0b94e
To run the executable from the objdir:
Packit f0b94e
Packit f0b94e
	% ./mach geckodriver -- --version
Packit f0b94e
	 0:00.27 /home/ato/src/gecko/obj-x86_64-pc-linux-gnu/dist/bin/geckodriver --version --binary /home/ato/src/gecko/obj-x86_64-pc-linux-gnu/dist/bin/firefox
Packit f0b94e
	geckodriver 0.19.0 (f3e939a81ee1169f9501ad96eb43bbf4bf4a1bde 2017-10-11)
Packit f0b94e
Packit f0b94e
[Rust]: https://www.rust-lang.org/
Packit f0b94e
[webdriver crate]: https://crates.io/crates/webdriver
Packit f0b94e
[commands]: https://docs.rs/webdriver/newest/webdriver/command/index.html
Packit f0b94e
[responses]: https://docs.rs/webdriver/newest/webdriver/response/index.html
Packit f0b94e
[errors]: https://docs.rs/webdriver/newest/webdriver/error/enum.ErrorStatus.html
Packit f0b94e
[Marionette protocol]: https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/Protocol
Packit f0b94e
[Marionette]: https://firefox-source-docs.mozilla.org/testing/marionette/marionette/index.html
Packit f0b94e
[Firefox CI]: https://treeherder.mozilla.org/
Packit f0b94e
[mozconfig]: https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Build_Instructions/Configuring_Build_Options
Packit f0b94e
Packit f0b94e
Packit f0b94e
Running the tests
Packit f0b94e
-----------------
Packit f0b94e
Packit f0b94e
We verify and test geckodriver in a couple of different ways.
Packit f0b94e
Since it is an implementation of the WebDriver web standard, we share
Packit f0b94e
a set of conformance tests with other browser vendors through the
Packit f0b94e
[Web Platform Tests] (WPT) initiative.  This lets us ensure web
Packit f0b94e
compatibility between _different_ WebDriver implementations for
Packit f0b94e
different browsers.
Packit f0b94e
Packit f0b94e
In addition to the WPT tests, geckodriver and webdriver have unit tests.
Packit f0b94e
You can use a mach command to run them:
Packit f0b94e
Packit f0b94e
	% ./mach test testing/geckodriver
Packit f0b94e
Packit f0b94e
The webdriver crate tests are unfortunately not yet runnable through mach.
Packit f0b94e
Work to make this possible is tracked in [[https://bugzil.la/1424369]].
Packit f0b94e
For the moment you must run them manually through `cargo`:
Packit f0b94e
Packit f0b94e
	% cd testing/webdriver
Packit f0b94e
	% cargo test
Packit f0b94e
Packit f0b94e
To run the more extensive WPT tests you can use mach, but first
Packit f0b94e
make sure you have a build of Firefox:
Packit f0b94e
Packit f0b94e
	% ./mach build
Packit f0b94e
	% ./mach wpt testing/web-platform/tests/webdriver
Packit f0b94e
Packit f0b94e
As these are functional integration tests and pop up Firefox windows
Packit f0b94e
sporadically, a helpful tip is to surpress the window whilst you
Packit f0b94e
are running them by using Firefox’ [headless mode]:
Packit f0b94e
Packit f0b94e
	% MOZ_HEADLESS=1 ./mach wpt testing/web-platform/tests/webdriver
Packit f0b94e
Packit f0b94e
In addition to the `MOZ_HEADLESS` output variable there is also
Packit f0b94e
`MOZ_HEADLESS_WIDTH` and `MOZ_HEADLESS_HEIGHT` to control the
Packit f0b94e
dimensions of the no-op virtual display.  This is similar to using
Packit f0b94e
xvfb(1) which you may know from the X windowing system, but has
Packit f0b94e
the additional benefit of also working on macOS and Windows.
Packit f0b94e
Packit f0b94e
As you get in to development of geckodriver and Marionette you will
Packit f0b94e
increasingly grow to understand our love for [trace-level logs].
Packit f0b94e
They provide us with the input—the HTTP requests—from the client
Packit f0b94e
(in WPT’s case from the tests’ use of a custom WebDriver client),
Packit f0b94e
the translation geckodriver makes to the [Marionette protocol],
Packit f0b94e
the log output from Marionette, its responses back to geckodriver,
Packit f0b94e
and finally the output—or the HTTP response—back to the client.
Packit f0b94e
Packit f0b94e
The [trace-level logs] can be surfaced by passing on the `-vv`
Packit f0b94e
flag to geckodriver through WPT:
Packit f0b94e
Packit f0b94e
	% ./mach wpt --webdriver-arg=-vv testing/web-platform/tests/webdriver
Packit f0b94e
Packit f0b94e
[Web Platform Tests]: http://web-platform-tests.org/
Packit f0b94e
[cargo]: http://doc.crates.io/guide.html
Packit f0b94e
[headless mode]: https://developer.mozilla.org/en-US/Firefox/Headless_mode
Packit f0b94e
Packit f0b94e
Packit f0b94e
Submitting patches
Packit f0b94e
------------------
Packit f0b94e
Packit f0b94e
You can submit patches by uploading .diff files to Bugzilla or by
Packit f0b94e
sending them to [MozReview].
Packit f0b94e
Packit f0b94e
Once you have contributed a couple of patches, we are happy to
Packit f0b94e
sponsor you in [becoming a Mozilla committer].  When you have been
Packit f0b94e
granted commit access level 1 you will have permission to use the
Packit f0b94e
[Firefox CI] to trigger your own “try runs” to test your changes.
Packit f0b94e
Packit f0b94e
[MozReview]: http://mozilla-version-control-tools.readthedocs.io/en/latest/mozreview.html
Packit f0b94e
[becoming a Mozilla committer]: https://www.mozilla.org/en-US/about/governance/policies/commit/
Packit f0b94e
Packit f0b94e
Packit f0b94e
Communication
Packit f0b94e
=============
Packit f0b94e
Packit f0b94e
The mailing list for geckodriver discussion is
Packit f0b94e
tools-marionette@lists.mozilla.org ([subscribe], [archive]).
Packit f0b94e
Packit f0b94e
If you prefer real-time chat, there is often someone in the #ateam IRC
Packit f0b94e
channel on irc.mozilla.org.  Don’t ask if you can ask a question, just
Packit f0b94e
ask, and please wait for an answer as we might not be in your timezone.
Packit f0b94e
Packit f0b94e
[subscribe]: https://lists.mozilla.org/listinfo/tools-marionette
Packit f0b94e
[archive]: https://groups.google.com/group/mozilla.tools.marionette