These functions currently return sequences or arrays of elements, which
wastes cycles and memory because we spend time constructing these data
collections in cases where we only need the first element. This is
the case for WebDriver:FindElement and WebDriver:FindElementFromElement.
This patch changes the Marionette element retrieval functions to
consistently provide iterators instead of sequences when looking
up elements. Making them generator functions means the iterable
can be expanded using [...iterable] when necessary.
MozReview-Commit-ID: FZbKLuRWqgA
--HG--
extra : rebase_source : 1e7dc8c614004444f8b2476cb1a136ed36943374
The "element" field on the WebDriver:SwitchToFrame command request's
body takes a string web element reference UUID as input. This patch
changes it so that it can also take a web element JSON Object.
The old behaviour can be removed with Firefox 60.
MozReview-Commit-ID: JcTD3MRxjOe
--HG--
extra : rebase_source : 3da4b30d2689b6416d89bee838df73af40db2686
For user input we will want to return the appropriate invalid
argument error. For internal input using TypeError is fine.
MozReview-Commit-ID: AlOnZuhaczN
--HG--
extra : rebase_source : 57992fc62c08736cb24f7ee229a4c8930751e068
By silently ignoring the result from 'wait_for_port' results in a
delayed socket error, which sometimes can cause strange results
as seen on bug 1410366.
MozReview-Commit-ID: 2ptIwX6upBG
--HG--
extra : rebase_source : 9f25afacf2ce65811c51af2cf4b234c8dd1f3587
Currently pprint only checks for 'id' and 'class', and adds
those to the output. Given that lots of elements might not
have those attributes a couple more should be added, which
can help to uniquly identify those.
MozReview-Commit-ID: 3thefe4oLN3
--HG--
extra : rebase_source : e9d276229a39ce5169a333ecb5b1fcc10e935d2a
The temporarily created sockets have to be removed immediately
by the operating system. Otherwise those enter the TIME_WAIT state,
and will be removed about 90s later. This can cause a pile of orphaned
sockets.
MozReview-Commit-ID: BGy9ZOjhjT0
--HG--
extra : rebase_source : f2e96d3e8d5d022b18c5f73daa15f3f8f06c74c5
Simply checking '_acceptConnections' when clients are trying to
connect to Marionette, and revoking the connection request inside
of 'onSocketAccepted' is plainly wrong, given that a connection is
already present.
Instead put the socket server into close state, which means it
does no longer listen for new connection attempts until new
connections are accepted again.
MozReview-Commit-ID: JIpOgOjnpDY
--HG--
extra : rebase_source : 6caa49fa81aec4a5fcf4bdbd3a4290b837a14281
As the method name describes the primary functionality of this method
should be to wait for the specific port to be reachable. Specific
application verification is done anyway in the 'newSession' command.
Also the temporarily created sockets have to be removed immediately
by the operating system. Otherwise those enter the TIME_WAIT state,
and will be removed about 90s later. This can cause a pile of orphaned
sockets.
MozReview-Commit-ID: BGy9ZOjhjT0
--HG--
extra : rebase_source : 54ce1fe1f9cd82dc53e205be057f11d99ccb4291
Simply checking '_acceptConnections' when clients are trying to
connect to Marionette, and revoking the connection request inside
of 'onSocketAccepted' is plainly wrong, given that a connection is
already present.
Instead put the socket server into close state, which means it
does no longer listen for new connection attempts until new
connections are accepted again.
MozReview-Commit-ID: JIpOgOjnpDY
--HG--
extra : rebase_source : 6caa49fa81aec4a5fcf4bdbd3a4290b837a14281
For ASAN builds the crashreporter is not available. As such the unit
tests for crash handling should not be executed. But it should be fine
to re-enable all the other unit tests.
MozReview-Commit-ID: BPFshl7vvqM
--HG--
extra : rebase_source : b40805e0e681eb75c7351299351447860144ba56
Since web element references are now implicitly unmarshaled when
they are passed to the content frame script, there is no need for
the actions module to check that the element origin is a reference
and try to look it up from the known element store.
MozReview-Commit-ID: 3BGBIBQMtR3
--HG--
extra : rebase_source : 1505fe15b060f85ad34628f34f67cfe96aaaa9c1
Instead of having commands serialising their own JSON-safe messages
when communicating with the content frame script, this patch changes
the AsyncMessageChannel to use evaluate.toJSON.
MozReview-Commit-ID: LmAVGEjqMTB
--HG--
extra : rebase_source : 7f39cccc1468217a8a6bcf107241fd5648cb24d2
Remove element.isWebElementReference in favour of
WebElement.isReference.
MozReview-Commit-ID: IOqx7XMUfCu
--HG--
extra : rebase_source : e25b0f709d3c11a6a26b937e9a72ca861fe34730
This patch introduces a series of web element abstraction types for
representing web element references.
Adds a series of new types for representing web element references
in Marionette: ChromeWebElement, ContentWebElement, ContentWebFrame,
and ContentWebWindow. The last three are direct representations of
web element, web frame, and web window definitions described in the
Webdriver specification. The first is a custom Marionette type as
we also support retrieving XUL elements from chrome space and must
be considered proprietary.
Each of the classes extend the WebElement abstract type, which is
the primary entry point when unmarshaling JSON input from the client.
Based on the characteristics of the JSON Object, one of the different
concrete types will be constructed.
The purpose of this change is to make marshaling of elements and
WindowProxies easier, both when we receive web element reference
objects from clients and when transporting them over IPC internally.
The WebElement.fromUUID function should be considered a temporary
workaround until we have fixed the current Marionette clients to send
web element reference JSON Objects as input, instead of plain {id:
<uuid>, …} fields.
MozReview-Commit-ID: FGcRq5H1Tzp
--HG--
extra : rebase_source : fe82087e8935adb519e2934fc37f1d46c21d9187
To avoid circular dependencies, where file A depends on B depending
on A, we should strive towards fewer inter-dependencies and more
autonomy between modules.
For example, if testing/marionette/browser.js needs access to
the Context enum it can currently only attain it by importing
testing/marionette/driver.js. Because driver.js imports browser.js,
we create a circular dependency and Cu.import enters an infinite
import recursion.
MozReview-Commit-ID: LGiA9sy9xrd
--HG--
extra : rebase_source : f1748894c4309a5bc34b72acd4931d7937e8810e
Introduces new element.isElement shorthand API for identifying DOM-,
SVG-, and XUL elements.
It is the equivalent of this:
if (element.isDOMElement(el) ||
element.isSVGElement(el) ||
element.isXULElement(el)) {
// ...
}
MozReview-Commit-ID: H8MDkP5bQmW
--HG--
extra : rebase_source : 6bef09999e47b178614e4bd307266b4449f39901
In addition to tell DOM- and XUL elements apart we will in the
future need to identify WindowProxies because WebDriver expects
there to be a separate "web window" serialisation for these.
Telling if an abritrary object is a WindowProxy is tricky but we
check if its node.toString is callable, that it returns "[object
Window"], and finally that its "self" attribute is itself. This is
not perfect, but good enough for now.
MozReview-Commit-ID: 6FLOa3qYLPP
--HG--
extra : rebase_source : 27d25d97facf73761a1600e88d938eb76b3bc005
Introduces a new element.isDOMElement function, similar to isXULElement,
for checking whether an element is a DOM element.
It follows the same formula as isXULElement by first testing if the
element is an object so we know we can accesss node.namespaceURI
and node.nodeType without causing a JS error.
MozReview-Commit-ID: 6Mlo33vu5LG
--HG--
extra : rebase_source : 547a2fc5bc0051e3bb51e14add4f57d1ff7972b9
Fixes isXULElement to recognise XBL elements, such as <xbl:framebox>.
Also tightens up the input checks so that arbitrary objects can be
tested, as checking node.namespaceURI directly could cause a JS error
if node is not an object. Before checking the namespace we also ensure
it's an element node so that text- and comment nodes are not picked up.
This patch also introduces tests, which were sorely missing.
MozReview-Commit-ID: 8LNF1z3X1gP
--HG--
extra : rebase_source : ffacc5b1336b35624aaf0534101ce5c3fbdeaa95
To avoid circular dependencies, where file A depends on B depending
on A, we should strive towards fewer inter-dependencies and more
autonomy between modules.
For example, if testing/marionette/browser.js needs access to
the Context enum it can currently only attain it by importing
testing/marionette/driver.js. Because driver.js imports browser.js,
we create a circular dependency and Cu.import enters an infinite
import recursion.
MozReview-Commit-ID: LGiA9sy9xrd
--HG--
extra : rebase_source : e4b69c91b9cf78705c902f1e5038d815b88114d0
The test currently performs checks which will no longer raise the expected
accessibility exceptions if the webdriver conforming click is enabled. In
such a condition those specific situations are already covered in
test_click.py.
As long as the legacy click has not been fully removed keep running the
checks but only if the webdriver click is not in use.
MozReview-Commit-ID: 1DbKfJYADp
--HG--
extra : rebase_source : 2f56caf977f88768b1df2ad507587091af8708ba
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
The WebDriver:FindElement command returned an array of elements when
looking up anonymous elements. This patch rectifies the behaviour
so that only a single element is returned.
It introduces a new helper function called element.findAnonymousNodes,
akin to similar helper functions for other strategies. This function
returns an iterator of anonymous nodes so that WebDriver:FindElements
(plural) and WebDriver:FindElement (singular) can share the same
code path.
MozReview-Commit-ID: 3IqPyAIZHtf
--HG--
extra : rebase_source : ceffd2b3dfe885b98ae31905f290ab9d95ef26c0
This page is now covered by geckodriver documentation and most
Selenium clients have built-in support for geckodriver.
DONTBUILD
MozReview-Commit-ID: BrqqU8trbRU
--HG--
extra : rebase_source : a699eb206915995b4fda6c6b6542dd58bcf5613c
This information is already covered in README.md.
DONTBUILD
MozReview-Commit-ID: CoaPQeIyNmA
--HG--
extra : rebase_source : 0fbd664c8d6a8bf9cf2489534ac4ba794339db57
Contribution information is covered by CONTRIBUTING.md.
DONTBUILD
MozReview-Commit-ID: 7MLBfFaFe7L
--HG--
extra : rebase_source : 8fe6ae96cfe634d73ada7d56df763124c70a43d9
If the action chain fails it will cause a JS error because its
prototype will be wrong.
MozReview-Commit-ID: 6Wbjdw2KHNV
--HG--
extra : rebase_source : 5f57b525fc846bae3bc579a3d074c0f4d793c008
Pretty-printing an object belongs more naturally to the new format module.
MozReview-Commit-ID: AfXLMPAT5ar
--HG--
extra : rebase_source : 1074febec66df49745256fc9cd04b0fecd293919
The issue here was that the cookie domain was always prepended with
'.' character. To resolve this edge-case Marionette now first checks
whether the cookie domain is in fact an IP address.
MozReview-Commit-ID: 4xBd4rscXxx
--HG--
extra : rebase_source : 92bf20ceb43c05f4610e3e0a5411027300586784
This test fails to test what it designed to test because the <input> is not
narrow enough to let 'b's overflow.
I added an <input> that have a fixed size to ensure 'B's overflows, and
remove the first long press on the first word.
MozReview-Commit-ID: 83zBj4yBXVk
--HG--
extra : rebase_source : f267a442223c318382c27852b6efbd614d410ee0
The WebDriver specification requires IPv6 addresses to be always added
with brackets for proxy hosts. But Firefox itself handles those without
brackets for both the proxy host, and the noProxy settings.
MozReview-Commit-ID: 9vpvXjDDuxd
--HG--
extra : rebase_source : f087d39e04738fff93f08fdd26d676b2daf623da
To ensure that both methods are working as expected, they cannot be
used in combination for assertions.
MozReview-Commit-ID: 57jYmPejEq0
--HG--
extra : rebase_source : 59ffe0e20cab92535270e3ed3139a9439dc24107
The WebDriver specification requires IPv6 addresses to be always added
with brackets for proxy hosts. But Firefox itself handles those without
brackets for both the proxy host, and the noProxy settings.
MozReview-Commit-ID: 9vpvXjDDuxd
--HG--
extra : rebase_source : 0fa109cd8993df980e28c57a7ec3857e9e2ff932
To ensure that both methods are working as expected, they cannot be
used in combination for assertions.
MozReview-Commit-ID: 57jYmPejEq0
--HG--
extra : rebase_source : 59ffe0e20cab92535270e3ed3139a9439dc24107
The MessageOrigin enum is removed as a separate type and
exposed as Message.Origin. The enum variants can be accessed as
Message.Origin.Client and Message.Origin.Server.
MozReview-Commit-ID: 1caPthSMIWx
--HG--
extra : rebase_source : 2e59d77e22ad1a35a072005131b45a4cfc8851a5
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
This is a plain conversion of the Marionette README to Markdown
syntax. The documentation itself is not great and could use more
love, but this is considered out of scope for this change.
DONTBUILD
MozReview-Commit-ID: IAdLyPPVFJH
--HG--
extra : rebase_source : be52f528144d70a50080f65475bd50f81b81e16b
Splits interaction.isElementSelected into two parts: one checking
whether the element DOM properties are selected/checked, and the
other checking accessibility. This so this so that the selectedness
can be unit tested, as we do not have the capability of standing
up accessibility in the xpcshell tests.
The second part of this change moves us away from atom.isElementSelected
in favour of a specification conforming implementation in Marionette.
This is a word-by-word implementation of the Is Element Selected
command from WebDriver.
MozReview-Commit-ID: 93WDKbPcEIB
The Delete Cookie command should not return an error if the cookie
does not exist.
The variable names "toDelete" and "candidateName" was also
juxtapositioned and wrong. Here I am using the approximate names
used in the specification prose for clarity.
Fixes: https://github.com/mozilla/geckodriver/issues/989
MozReview-Commit-ID: 6IIGGpB1JWn
--HG--
extra : rebase_source : f3149d2195c0e871370eef3d2c1306a8212c5751
The element.isStale function does not take into account the current
browsing context when checking an element’s staleness. This means,
for example, that an element in an <iframe> that gets retrieved, will
still be considered valid for as long as its associated document lives.
In WebDriver the expected behaviour is for the element reference to
only be valid for the current browsing context, meaning retrieving
the element reference when another browsing context is chosen should
return a stale element error.
Fixes: https://github.com/mozilla/geckodriver/issues/934
MozReview-Commit-ID: JpQVt78u5AN
The atoms were recently updated in https://bugzil.la/1375660, but
that changeset forgot to update the copyright information of this file.
DONTBUILD
MozReview-Commit-ID: CF6PYp6FlO0
--HG--
extra : rebase_source : 68f7a2a7909685f561e77a1f2a95db643add10d5
This patch moves the "timeout" and "interval" positional arguments
on PollPromise to an options dictionary.
In the following code example it is hard to know which argument means
what because they are not named:
new PollPromise(resolve => resolve(), 100, 100);
Named arguments can be achieved in JavaScript using option
dictionaries, and this patch changes the input PollPromise takes so
that the above example looks like this:
new PollPromise(resolve => resolve(), {timeout: 100, interval: 100};
This plays especially well with code in testing/marionette/element.js
as we already have named arguments that we can pass directly in through
an object literal, making the code more readable and more compact:
let timeout = 42;
new PollPromise(resolve => resolve(), {timeout});
MozReview-Commit-ID: GFWNGQAeWk1
--HG--
extra : rebase_source : 296843053e72bd07463a3018b06782f0dcc4828a
In formalising our synchronisation module, this renames wait.until
to PollPromise. It is a specialisation of a promise, just like
TimedPromise, that poll-waits a condition for a given amount of time
before either resolving (passing) or rejecting (failing) the poll-wait.
Also fix and improve documentation.
MozReview-Commit-ID: AcP3C1qCgKA
--HG--
extra : rebase_source : d17bb3be0819b0ce9de55d44741836fc00b10f46
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
This patch moves the "timeout" and "interval" positional arguments
on PollPromise to an options dictionary.
In the following code example it is hard to know which argument means
what because they are not named:
new PollPromise(resolve => resolve(), 100, 100);
Named arguments can be achieved in JavaScript using option
dictionaries, and this patch changes the input PollPromise takes so
that the above example looks like this:
new PollPromise(resolve => resolve(), {timeout: 100, interval: 100};
This plays especially well with code in testing/marionette/element.js
as we already have named arguments that we can pass directly in through
an object literal, making the code more readable and more compact:
let timeout = 42;
new PollPromise(resolve => resolve(), {timeout});
MozReview-Commit-ID: GFWNGQAeWk1
--HG--
extra : rebase_source : 06e558129f1e0acf3fbf8b6ca99c2407320b8e61
Now that we have selective imports through Cu.import we can give
wait.until a more descriptive name that matches TimedPromise.
This patch renames the wait.until utility to PollPromise.
MozReview-Commit-ID: 9gsvAV27mMl
--HG--
extra : rebase_source : ea98d63013d709d52ce234446404233d9dbe572e
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
The element 'button9' is moved off screen by CSS and as such it is not
marked as displayed.
MozReview-Commit-ID: KQCA2QfZLrT
--HG--
extra : rebase_source : bc7118324861781eaaab76005a19815a22df31e4
The Marionette server now returns a JSON containing the cause of shutdown which isn't included in previous Firefoxen. We needed to test this JSON in the quit and restart methods in the python client.
MozReview-Commit-ID: 8uL9tbNszcm
--HG--
extra : rebase_source : 7f01fe55444b034a5f07e42acac0224a981be881
There were two issues with the previous implementation:
* Domain cookies were created as host only cookies (due to lack of
leading '.' characters)
* The cookie domain included in the Marionette request was completely
ignored, which always resulted in host-only cookies
MozReview-Commit-ID: 2JLQ3vwNMrb
--HG--
extra : rebase_source : c72ba077ef1b1a1f308e4c9a1d2093c18f7483ce
With newer Selenium atoms which do not conflate attributes and
properties, the retrieval via getElementAttribute will fail. By
retrieving it directly as property will fix it.
MozReview-Commit-ID: CFy3JZDeUWq
--HG--
extra : rebase_source : ed3a358f52b7cd54f3c5dda037fddaa93173e3b6
When verifying error messages, the second parameter of Assert.throws has
to be a regular expression.
MozReview-Commit-ID: LJ6Iif8ORTs
--HG--
extra : rebase_source : 0cbe9f31880df44f9c822d8410ab4571281c17ef
Search suggestions create unneccessary network requests and the suggestions
opt-in notification interferes with tests that don't expect it to be there.
So, this patch updates the default settings in Marionette to disable both.
MozReview-Commit-ID: 8X8SYPq19tj
--HG--
extra : rebase_source : cd0fe8f3437340b1266d161e1cad46bcbcd1a6f6
The wrapper puppeteer.platform in Firefox UI test was deemed redundant.
MozReview-Commit-ID: LUocC59bLNF
--HG--
extra : rebase_source : e764ba1d09d3f752e75ec6aed80ca93781c319dc
This switches to using a timeout of 120s * timeout_multplier, which is
twice the current value. The Marionette startup_timout value is
removed because it turns out that's only used when marionette starts
the Firefox instance and therefore is ignored in this case.
MozReview-Commit-ID: 4VA8yB6M1d5
--HG--
extra : rebase_source : ba9d506d4061d49f2a95fbb24e690841fc902c97
The sizemodechange event is not strongly connected to the
visibilitychange event that the WPT minimize_window.py test is now
using to ascertain whether the window has been successfully iconified.
Because Marionette uses the sizemodechange event it is causing
intermittents such as https://bugzil.la/1397007. You can also read a
lengthy summary I did on the problem in https://bugzil.la/1397007#c11.
The fix for the problem is to wait for the visibilitychange DOM
event content.
MozReview-Commit-ID: B6i33Ee5iMC
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
On Windows TaskCluster workers Marionette could be ready within 1s.
As such the currently used timeout is too long, and needs to be
further reduced.
MozReview-Commit-ID: KbLVdpB71cu
--HG--
extra : rebase_source : 2b9139e4b7e2c9d5815e7cc481086ca779385538
Shield experiments interfer with core features of Firefox which can
cause tests run via Marionette or geckodriver to fail. Resetting the
API URL will make sure that no experiments can be downloaded.
MozReview-Commit-ID: HnE49jfnen7
--HG--
extra : rebase_source : 2fa6cf86ddce798eba88a41d227768f149cccc70
Shield experiments interfer with core features of Firefox which can
cause tests run via Marionette or geckodriver to fail. Resetting the
API URL will make sure that no experiments can be downloaded.
MozReview-Commit-ID: HnE49jfnen7
--HG--
extra : rebase_source : 9cec29085032318e9e8467d6d754afe0890ae645
When the binary gets launched we do not immediately kill the process if the
connection to Marionette server cannot be established within the given amount
of seconds. Instead "_handle_socket_failure" is getting called because
the utility method `raise_for_port` inappropriately uses the `@do_process_check`
decorator.
By removing the decorator the initial connection attempt can be handled
differently. As such the process if handled by Marionette will be immediately
killed. Currently we are waiting for the process to quit itself within 120s,
which will actually never happen due to no active session.
Further `start_session` defaults to a timeout of 60s which itself is problematic
for test harnesses using Marionette but controlling the binary themselves. In
those cases timeouts can happen often for slow starting browser processes like
debug builds. Instead this timeout should default to the `startup_timeout` value.
MozReview-Commit-ID: BZvX5KT45mK
--HG--
extra : rebase_source : 875807b75f0575a10dc9de3588237002fa6a5821
Take into account that a weak referenced element might have been destroyed
in the element staleness check.
An error is thrown when the reference object has been destroyed when
getting a weakrefs' pointer. We catch this, but element.isStale does
not take into account that the el argument in this case can be null,
or in this revision of the patch, undefined.
MozReview-Commit-ID: 7sr4YGhAotS
--HG--
extra : rebase_source : 995eeef4ec1b19bf100cb95c4dd343e947b1cf52