This patch generalises logger setup and access by providing
one interface with specialised implementations for the main-
and child processes. This will mean we can get rid of ad-hoc
logger setup in testing/marionette/components/marionette.js and
testing/marionette/listener.js.
In the case for the component file, the log level and the stdout
dump appender is set up when you request the logger. The same is
true when requesting the logger in a child process, but it will
additionally request the log level from the main process.
Usage:
const {Log} = ChromeUtils.import("chrome://marionette/content/log.js", {});
let log = Log.get();
MozReview-Commit-ID: 8Ha5FSaoGXp
--HG--
extra : rebase_source : 0ad13e805cd1c6a4a8332fdbe6124a82719c4656
Normally this sort of change could be filed under "needless churn",
but by appending new files to this list we end up with constant
merge conflicts.
MozReview-Commit-ID: HnaIN2d5fOa
--HG--
extra : rebase_source : b6661417d4e7afeb8e73abe5c2ea15714b4f7dbd
This introduces a new testing/marionette/prefs.js module with shorthands
for all of Marionette's preferences. Getters are provided for all
preferences, but setters are only offered for preference we expect
to mutate at runtime.
The new module additionally provides a preference abstraction on
top of nsIPrefService instead of Preferences.jsm. We cannot use
Preferences.jsm during startup in Marionette because Marionette
gets loaded unconditionally.
Finally an EnvironmentPrefs class is provided for reading and iterating
over preferences stored in JSON Objects in environment variables.
MozReview-Commit-ID: FbgdBEkf5A
--HG--
extra : rebase_source : 0d5b2f11dc94a74aff3f742ef191b72b159b5ee7
This introduces a new testing/marionette/prefs.js module with shorthands
for all of Marionette's preferences. Getters are provided for all
preferences, but setters are only offered for preference we expect
to mutate at runtime.
The new module additionally provides a preference abstraction on
top of nsIPrefService instead of Preferences.jsm. We cannot use
Preferences.jsm during startup in Marionette because Marionette
gets loaded unconditionally.
Finally an EnvironmentPrefs class is provided for reading and iterating
over preferences stored in JSON Objects in environment variables.
MozReview-Commit-ID: FbgdBEkf5A
--HG--
extra : rebase_source : c3666ff19f4bf8092d9976bbf5e98cd45438e586
This moves the WindowState enum from testing/marionette/wm.js to
testing/marionette/browser.js in order to make it easier to apply
the forthcoming Marionette window tracking refactoring patches.
In other words, this patch functionally does not change anything.
MozReview-Commit-ID: 53MKIRHl11p
--HG--
extra : rebase_source : d048086ab48449ba02853076451e6dd1909bafa6
This removes the last remenants of frame.Manager and
testing/marionette/frame.js from Marionette. The preceding commits
in this changeset has gradually removed the unused and duplicated
features that it implemented. The only remaining pieces are the
registrating of some chrome-side IPC message handlers which we can
leave attached for the duration of the Marionette session.
MozReview-Commit-ID: EYjrJBeTybz
--HG--
extra : rebase_source : cf8b2d04c05d22eea6fe24061ccb9b21680f0d3c
The upcoming window tracking refactoring to Marionette will introduce
a new testing/marionette/wm.js module. It was originally the plan
to move WindowState there after it had landed, but it actually makes
sense to land any dependencies before to reduce churn in the window
tracking patches.
MozReview-Commit-ID: EpqnTYYGcmg
--HG--
extra : rebase_source : d6760feefa49c522738fd3930b339bc0af70e6a5
Introduces a utility that truncates strings in potentially arbitrary
object structures. This allows JSON structures that contain long
strings to be shortened with an " ..." appendix for pretty logging
when data integrity is not a vital concern.
The maximum string length is currently set to 250 characters, which
is a number I have pulled out of a hat.
MozReview-Commit-ID: 2gauOvMzBCO
--HG--
extra : rebase_source : cea57d348a61ecd11a5a9cf564ed60737923f380
testing/marionette/wait.js originally contained a utility for
poll-waiting on a condition. The module has since been expanded to
also include TimedPromise, which is a specialisation of Promise that
is rejected after a duration.
The latter is not a wait utility but a synchronisation primitive.
This terminology also covers the first, and this change renames the
wait module to sync.
MozReview-Commit-ID: Fd3LqfpiEaU
--HG--
rename : testing/marionette/wait.js => testing/marionette/sync.js
extra : rebase_source : f48ff62ca2589ab0ce4a2f3d134d392e6f0be015
testing/marionette/wait.js originally contained a utility for
poll-waiting on a condition. The module has since been expanded to
also include TimedPromise, which is a specialisation of Promise that
is rejected after a duration.
The latter is not a wait utility but a synchronisation primitive.
This terminology also covers the first, and this change renames the
wait module to sync.
MozReview-Commit-ID: Fd3LqfpiEaU
--HG--
rename : testing/marionette/wait.js => testing/marionette/sync.js
extra : rebase_source : 5e22ec5e26b5405c928ab26734a8d2ddc5d43785
This makes it possible to subscribe to DOM events in web content, in
order to facilitate fixes for cases such as https://bugzil.la/1397007.
Although the current interface, WebElementEventTarget, is associated with
browser.Context (curBrowser) it is the intention that we in the future
will associate this with representations of the marshaled web element.
This will make it quack and act like an Element's EventTarget, which
has nice parity to it.
The WebElementEventTarget works by passing IPC messages to
a backend service in the content frame script implemented by
ContentEventObserverService. This registers event handlers for specific
DOM events, and relays these events back to the browser-specific message
handler in chrome.
This will enable chrome code to wait for events to occur in content,
like this:
await new Promise(resolve => {
webElement.addEventListener("visibilitychange", resolve, {once: true});
contentBrowser.minimize();
});
MozReview-Commit-ID: B8MMHyG8n04
--HG--
extra : rebase_source : 25ac77fbcfb09435325719ac61614c4a8ce37996
This adds commands to start a reftest session, run a test, and end the
session. It as assumed that after you start a reftest session you will
just run reftests until you end the session. When starting a session
the user provides a string indicating when screenshots should be
taken, and an object mapping urls to a count of the number of times
that url is expected to be used in the session, to help with
caching. Running the tests takes a url to a test, an expected status,
a timeout, and a nested list of possible references, in which each
entry at a specific level is combined by OR and nested references are
combined by AND.
The implementation is heavilly inspired by the existing reftest
harness, starting a minimal window with no tabs, and loading the urls
directly in there. In order to get a screenshot in the e10s case we
have to pass the DRAW_VIEW and USE_WIDGET_LAYERS flags when taking the
screenshot.
For performance we heavily cache canvases; for references that will be
repeated we cache the full canvas with image, and we also cache a
single canvas to use for all other screenshots to avoid the overhead
of repeatedly creating a new canvas element.
MozReview-Commit-ID: JOFvtmH7tg
This adds commands to start a reftest session, run a test, and end the
session. It as assumed that after you start a reftest session you will
just run reftests until you end the session. When starting a session
the user provides a string indicating when screenshots should be
taken, and an object mapping urls to a count of the number of times
that url is expected to be used in the session, to help with
caching. Running the tests takes a url to a test, an expected status,
a timeout, and a nested list of possible references, in which each
entry at a specific level is combined by OR and nested references are
combined by AND.
The implementation is heavilly inspired by the existing reftest
harness, starting a minimal window with no tabs, and loading the urls
directly in there. In order to get a screenshot in the e10s case we
have to pass the DRAW_VIEW and USE_WIDGET_LAYERS flags when taking the
screenshot.
For performance we heavily cache canvases; for references that will be
repeated we cache the full canvas with image, and we also cache a
single canvas to use for all other screenshots to avoid the overhead
of repeatedly creating a new canvas element.
MozReview-Commit-ID: JOFvtmH7tg
--HG--
extra : rebase_source : ab5a2ef2e450b9bbdc6bc3c9487ed5dfda2c1d4b
Marionette uses singular module names. Make the cookie module
fall in line by renaming it from testing/marionette/cookies.js to
testing/marionette/cookie.js.
MozReview-Commit-ID: H4jyvI3lFxz
--HG--
rename : testing/marionette/cookies.js => testing/marionette/cookie.js
extra : rebase_source : 6da48d3d9215de34ccb97823c0430766538fb45f
DevTools is about to move out of mozilla-central and be released as an add-on.
So that these protocol files are going to be missing from the tree.
To accommodate that, we are doing a copy of them next to marionette.
MozReview-Commit-ID: 9PyhuwyZyXI
--HG--
extra : rebase_source : b6d96ae5e4c4ac837713e396ab72163b168871f2
Merges testing/marionette/dispatcher.js into testing/marionette/server.js
and renames it server.TCPConnection.
The rationale behind this change is that the current dispatcher is not
a single entity to which incoming requests are dispatched. The old
organisation might make sense if this was an HTTP server where all
connections are transitive and it didn't hold any connection details,
however the dispatcher is in effect a representation of a client socket
connection.
Since the module is not used elsewhere, it makes sense to pair it with
the existing server.TCPListener class.
MozReview-Commit-ID: 2HF35OiP6AY
--HG--
extra : rebase_source : 188bbc23a128642c1127694714e7fca4192827c9
This makes the `implicitWaitFor` utility from
testing/marionette/element.js generally available in Marionette.
It improves on the design of the old wait utility by providing
promise-like resolve and reject options to the evaluated function. These
can be used to indicate success or failure of waiting. If resolved, the
provided value is returned immediately. When rejected, the function is
evaluated over again until the timeout is reached or an error is thrown.
It is useful to indicate success and failure state because it saves the
calling code from guessing based on the return value. Guessing from
the return value can be problematic since there are certain types and
values in JavaScript that are ambigeous or misleading, such as the fact
that empty arrays are evaluated as a truthy value.
MozReview-Commit-ID: G8F99tdbiNb
--HG--
extra : rebase_source : 88647b1c7115f15649d5029391ff21567f9d527c
This makes the `implicitWaitFor` utility from
testing/marionette/element.js generally available in Marionette.
It improves on the design of the old wait utility by providing
promise-like resolve and reject options to the evaluated function. These
can be used to indicate success or failure of waiting. If resolved, the
provided value is returned immediately. When rejected, the function is
evaluated over again until the timeout is reached or an error is thrown.
It is useful to indicate success and failure state because it saves the
calling code from guessing based on the return value. Guessing from
the return value can be problematic since there are certain types and
values in JavaScript that are ambigeous or misleading, such as the fact
that empty arrays are evaluated as a truthy value.
MozReview-Commit-ID: G8F99tdbiNb
--HG--
extra : rebase_source : 1de77b97f0de71e0dc77fc47a6b1aab1ef88ea6f
Fennec uses a different set of DTD and properties files. As such the current
entity and property names do not work. To fix the tests a DTD and properties
file gets added for the test_dialog.xul example dialog, which means that we
have identical resources for every supported application.
MozReview-Commit-ID: LXDeADHlxja
--HG--
extra : rebase_source : 47a4023af8ebaef28ca58868529df5e78ea7b309
This patch provides a (nearly) WebDriver conforming implementation
of capabilities in Marionette. The work remaining is pending further
clarification in the specification.
Capabilities are represented internally as a complex object provided
by `session.Capabilities`. Timeouts and proxy configuration are also
represented by the similar complex objects `session.Timeouts` and
`session.Proxy`, respectively.
The capabilities stored in `GeckoDriver#sessionCapabilities` are the
result of parsing user-provided desired- and required capabilities.
WebDriver now uses `firstMatch` and `alwaysMatch` primitives for
capabilities, but as this is considered a wider breaking change, the
move to these primitives will be done at a later stage. It’s prudent
to point out that the base techniques used with the new primitives
are similar to those implemented for `desiredCapabilities` and
`requiredCapabilities` in this patch, and that the work needed to adapt
them is considered trivial.
When capabilities are presented back to the user (the so called processed
capabilities), we call the `toJSON` implementation on the complex objects.
`session.Capabilities#toJSON` calls the internal function `marshal`
which ensures empty fields are dropped. `marshal` can be considered to
be a specialisation of the standard library `JSON.stringify`, which also
calls `toJSON` on entry values if they provide this function.
The changeset overall also provides a much deeper level of testing of
WebDriver capabilities.
MozReview-Commit-ID: 97xGt3cnMys
--HG--
extra : rebase_source : 98e0bde3fdfd811775d195b488cb1255f61e5772
When the `acceptInsecureCerts` capability is set to true on creating
a new Marionette session, a `nsICertOverrideService` override service
is installed that causes all invalid TLS certificates to be ignored.
This is in line with the expectations of the WebDriver specification.
It is worth noting that this is a potential security risk and that this
feature is only available in Gecko when the Marionette server is enabled.
MozReview-Commit-ID: BXrQw17TgDy
--HG--
extra : rebase_source : 023f18b07ffbb53c7dbc588a823c62830f032e3d
When the `acceptInsecureCerts` capability is set to true on creating
a new Marionette session, a `nsICertOverrideService` override service
is installed that causes all invalid TLS certificates to be ignored.
This is in line with the expectations of the WebDriver specification.
It is worth noting that this is a potential security risk and that this
feature is only available in Gecko when the Marionette server is enabled.
MozReview-Commit-ID: BXrQw17TgDy
--HG--
extra : rebase_source : 722b7bde2b6e76a4cf0565b0504a6ce8ec53f04a
Marionette does not use specialpowers any more and it is pointless to
include it in the Marionette jar.
MozReview-Commit-ID: 8tzSO4VsMA7
--HG--
extra : rebase_source : a2a78e5a37a444b1d04dcae25551c8cbcc3aca61
Addons can be installed and uninstalled using the Marionette client
utility found in testing/marionette/client/marionette_driver/addons.py.
It injects system-privileged chrome JavaScript to manipulate the addon
manager service.
To make this feature more widely adopted, i.e. by other clients such as
WebDriver, this patch moves the addon installation code to internally
in Marionette and exposes them as so called WebDriver extension commands.
This patch also _explicitly breaks_ backwards compatibility with
older Geckos that do not support the new Marionette:installAddon and
Marionette:uninstallAddon commands.
MozReview-Commit-ID: 18IceiGIg5H
--HG--
extra : rebase_source : 007802fa0a431a1438570caac3988177c6beab1d
Many tests that result in throwing errors, amongst those many type-
and platform checks, are repeated throughout the Marionette code base.
This patch centralises the most common of these, typically reducing
consumer calls from three to one line.
Example usage:
assert.defined(cmd.parameters.value);
assert.postiveInteger(cmd.parameters.value,
error.pprint`Expected 'value' (${value}) to be a signed integer`);
// InvalidArgumentError: Expected 'value' ([object Object] {"foo": "bar"}) to be a positive integer
MozReview-Commit-ID: BHOaDazeGer
--HG--
extra : rebase_source : 1d35c10e29d4fd536829e9714ae65bcd14ad21f8
Adds support for navigating to a fragment on the currenty visible document
without waiting for a DOM event that the document has been fully loaded.
This addresses https://github.com/mozilla/geckodriver/issues/150.
MozReview-Commit-ID: 7uiPT5cjGQE
--HG--
extra : rebase_source : f9152a6623a25c17e10dc3bc6552b8e635c21317