It turns out that Node.isConnected (described in
https://dom.spec.whatwg.org/#dom-node-isconnected) handles an element’s
shadow root, which element.isDisconnected tries to replicate.
element.isDisconnected and element.isStale are both long and error-prone
and can be removed entirely in favour of this web platform API.
The relevant change to the WebDriver specification landed in
32a477b023.
MozReview-Commit-ID: 5Q0gWLvw8KL
--HG--
extra : rebase_source : 773ab302df27cf11be6079f918a48d3730ceb5c1
A fallout from https://bugzil.la/1392346 was that element.isStale called
element.isDisconnected incorrectly by using the old container object.
This was reported in https://bugzil.la/1392854.
Since we in the long term want to get rid of the concept
of window/shadow root containers (in preparation for
https://bugzil.la/marionette-window-tracking), we might as well fix
the fallout by making element.isDisconnected take separate window-
and shadowRoot arguments, like element.isStale.
Fixes: https://bugzil.la/1392854
MozReview-Commit-ID: ELIu8HsZUfK
--HG--
extra : rebase_source : 3f0cc83048d9f069c47c08c0a6d886033c106825
In preparation for a larger window tracking change to Marionette, we
want to decouple the element staleness check from the element.Store.
MozReview-Commit-ID: JNZqCc2eZqy
--HG--
extra : rebase_source : a21344ef9ecc01523545b2f866fbb5415afcedb3
nsIDOMWindow is the XPCOM interface and not what we mean in all these
cases. We either want to refer to the ChromeWindow or to the WindowProxy,
depending on the context of the code.
MozReview-Commit-ID: 405po1XLXRi
--HG--
extra : rebase_source : 47a179f7caed76592dab28f8e10550cda5fe3d02
Various fixes to make the generated API documentation from
testing/marionette somewhat easier to read.
MozReview-Commit-ID: F9duuQoOYBt
--HG--
extra : rebase_source : 3ade69773ceba42826aedef05b1371240b51cf82
We try to delete the element entry by "id", which is not defined.
MozReview-Commit-ID: DXAOJAV1z9Q
--HG--
extra : rebase_source : 103209d203f64bb354e46fb4fb98225b8e7165a0
In particular, XPCNativeWrapper should probably be made available
by default.
MozReview-Commit-ID: E1oYFyApbLi
--HG--
extra : rebase_source : 4e27ad6882bd4e43dadc97d4fd2a186e01510dfd
Instead of importing everything from the testing/marionette/error.js
module into the global scope, we need to be selective about what symbols
we want.
MozReview-Commit-ID: HZDAS0bs0GD
--HG--
extra : rebase_source : 14a300bb2cedc0716168d50846755a6faed83012
This patch renames element.fromJson and element.toJson to
evaluate.fromJSON and evaluate.toJSON, respectively.
The JSON (de)serialisation code belongs more naturally in the evaluate
module, which did not exist when these functions were written.
MozReview-Commit-ID: FJGbjGD1kZ6
--HG--
extra : rebase_source : b2528f545c8213b06b9116299806d8ab8a875250
Because individual <option> elements are painted and represented in the
DOM when they belong to a <select multiple> list, the center point of
the list might be one of the options.
To take this into account, we perform an inclusive descendant check
(DOMElement.contains) to see if the <option> element is a descendant of
the container <select> element.
In the case the targetted element is the element itself, the test will
still pass since it is an _inclusive_ descendant check. In other words,
containerEl.contains(tree[0]), if tree[0] is equal to containerEl,
will pass.
The relevant specification changes were made in
40abcefd6a.
MozReview-Commit-ID: ORX8zLxQJ
--HG--
extra : rebase_source : 87ca38df6696257d569ef1ffcb888426d1f569af
This change makes it possible to click elements that has its
pointer-events style property set to "none".
If an element has its style property pointer-events set to "none",
the element in view test will fail due to document.elementsFromPoint
excluding it due to non-interactability. This is only a problem when
checking if the element is inside the viewport, and not when actually
performing interaction with the element.
The relevant specification change is
ba6ee925b5.
MozReview-Commit-ID: JwZB6fm7P9A
--HG--
extra : rebase_source : 18ddf7955c7e0bc6d1d7f798aebc6e09799a99ca
We want to take shadow DOM into account when getting an element's
pointer-interactable paint tree.
Marionette is currently unable to determine if an element inside a shadow
DOM host is disconnected from the document because we are constructing
the frame container with only the main document.
MozReview-Commit-ID: IPDi8fQZYRP
--HG--
extra : rebase_source : 8c6757a032342aa6bbe50ef15025a37ac09ae413
It makes sense for element.isDisconnected to accept a container object
with frame and shadowRoot, instead of taking the shadowRoot as an optional
third argument, since this is what most consumers start out with.
MozReview-Commit-ID: 6kfEIEf8u96
--HG--
extra : rebase_source : 084b39ff6796747470bf49acdab0dbbfc8f67f98
When passing a DOM element that is an HTML element to error.pprint,
it will get pretty-printed with its ID and class properties.
This helps to identify elements when one is obscuring the other when
clicking. For example, the error message
Element <input id="foo"> is obscured by <input id="bar">
is nicer than the old error message
Element [object HTMLElement] {} is obscured by [object HTMLElement] {}
MozReview-Commit-ID: 8U2Lo8V4lmv
--HG--
extra : rebase_source : a0a0176f1fed9786da6260e27d28c23c8eb2a944
The WebDriver specification changed recently to introduce a new
'element click intercepted' error that is returned if the high-level
Element Click command attempts an element that is obscured by another
(the other element's z-index, or order in the paint tree, is higher).
This patch introduces the notion of 'container elements', which is an
element's context. For example, an <option> element's container element
or context is the nearest ancestral <select> or <datalist> element.
It also makes a distinction between an element being pointer-interactable
and merely being in-view. This is important since an element may be in
view but not pointer-interactable (i.e. clicking its centre coordinates
might be intercepted), and we do not want to wait for an element to
become pointer-interactable after scrolling it into view if it is indeed
obscured.
MozReview-Commit-ID: 8dqGZP6UyOo
--HG--
extra : rebase_source : 68f1f7ee922ab8ed6acd92d3f89d6887b23ae801
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
When returning the tree of interactable elemenets under the cursor, we
want to test the first one against the passed element, not that there
are _any_ interactable elements under the cursor.
MozReview-Commit-ID: AUvKAWKHgZk
--HG--
extra : rebase_source : 69563be46dbb18c4c814d6615b1bd2f97179b816
The old calcaulation to determine an element's in-view centre point was
wrong as pointed out in https://github.com/w3c/webdriver/issues/425,
and this is an implementation of the proposed algorithm which passes
real-world tests.
This also addresses https://github.com/w3c/webdriver/pull/441 which
checks if the `DOMRect` sequence returned from `getClientRects` is empty,
as it may be if the element's `display` style property is `none`.
MozReview-Commit-ID: 4uitUrviW2a
--HG--
extra : rebase_source : d9a3eefc9496500dffe74a28a117e29067a646f1
When scrolling an element into view using `Element.scrollIntoView`,
use the `{block: "end", inline: "nearest"}` scroll position arguments,
which are equivalent to `Element.scrollIntoView(false)`. This is what
other WebDriver implementations have used for a while, and we meant to
change to this sooner.
This ensures that the element appears at the bottom of the viewport
rather than the top, where overlaying menus with fixed style position
may more frequently appear.
In the future we might consider replacing this with `{block: "center"}`
which is specified in the CSSOM specification, but not yet implemented
in any browsers.
This implements https://github.com/w3c/webdriver/pull/440, which should
fix https://github.com/mozilla/geckodriver/issues/327.
MozReview-Commit-ID: BRMupP4fM89
--HG--
extra : rebase_source : 952edd6932b0f7e8b7d2694d428435508a4ffc8c
This patch adds marshaling of HTMLFormControlsCollection,
HTMLAllCollection, and HTMLOptionsCollection element collections to
Marionette.
It will allow us you to return from HTMLSelectElement.options,
document.forms[0].elements, and document.all. This is in
addition to the already supported document.querySelector
(NodeList), document.getElementsBy* (HTMLCollection), and
Array.from(ELEMENT...) collections.
MozReview-Commit-ID: 71a65lZRn4S
--HG--
extra : rebase_source : aff3490ceb0db110f392956baaacbd5e2e7acb62
This gives up parity with the WebDriver project and brings us in line with the current
specification http://w3c.github.io/webdriver/webdriver-spec.html#dfn-link-text
MozReview-Commit-ID: 9OD6B2pKTfx
--HG--
extra : rebase_source : 075fe800d1a82593ebb55987a2eccb2d318e0c5f
Publish the findByXPath and findAllByXPath functions to match the style
of the recently introduces findByLinkText and findByPartialLinkText
functions.
Do note that this patch rearranges the input arguments these functions
take. Possibly we do not have to send the root element as input at all.
MozReview-Commit-ID: 4H7kpZBUsTw
--HG--
extra : rebase_source : 72c11a2a3e47158d6696db2c5995bea09e57794e
Lower-case "a" matches hyperlinks in XHTML documents as well as HTML
documents. Upper-case "A" only matches HTML documents.
The patch also refactors link text- and partial link text lookup into
distinct functions, so that there is no more worry about variable scoping
in match blocks.
MozReview-Commit-ID: FB7MAmosBoR
--HG--
extra : rebase_source : 65d0807e33a279fb822078329128c3f3c219a555
This matches the Map data structure in JavaScript.
MozReview-Commit-ID: 5l2xOb4W2BC
--HG--
extra : rebase_source : 706f8e60fbfc364e56da83f15b9e1a4a94af9c9a
Moves ElementManager#wrapValue to the testing/marionette/element.js
module level and renames it to toJson.
MozReview-Commit-ID: GJBl2L1GRxZ
--HG--
extra : rebase_source : 5fc81a6b0ebfbd6a12557b3b746e6968c235d674
Moved ElementManager#convertWrappedArguments to the
testing/marionette/element.js module scope and renamed it to fromJson.
MozReview-Commit-ID: JMTZcG0JSUE
--HG--
extra : rebase_source : 613faca6a8c81b1ff435c538b0a7347ae548c288
Renames ElementManager to element.Store, exposing it on the
testing/marionette/element.js module. Shortens getKnownElement(uuid)
to get(uuid). Introduces new method has(uuid) to replace some unnecessary
checks in testing/marionette/driver.js and testing/marionette/listener.js.
MozReview-Commit-ID: D5qAlqrIxi
--HG--
extra : rebase_source : 22fda922e4c5f7bfcd1a5bcbcec6ae1003411535
Moves element retrieval methods from ElementManager to the
testing/marionette/element.js module itself. This means some more
work needs to be done by the caller, but avoids bloat by ensuring
ElementManager does not end up as a super-object.
MozReview-Commit-ID: 5LGe0vpSWwS
--HG--
extra : rebase_source : d7f4bd64cd1a92ad20a33496708d3f0136531d9f
This allows us to converge with webdriver project which scrolls to the
start of the element instead of the end.
MozReview-Commit-ID: ErQ18bTeo5m
--HG--
extra : rebase_source : 0cb69c80da561e0b0fda288841c415fd206fe907