Closed Bug 1411307 Opened 7 years ago Closed 7 years ago

Rewrite element retrieval functions to use generators

Categories

(Remote Protocol :: Marionette, enhancement)

Version 3
enhancement
Not set
normal

Tracking

(firefox58 fixed)

RESOLVED FIXED
mozilla58
Tracking Status
firefox58 --- fixed

People

(Reporter: ato, Assigned: ato)

Details

Attachments

(1 file)

The various strategy-specific element retrieval function in
testing/marionette/element.js return arrays or sequences of elements,
but this entails extra computation work when the underlying data
representation is an iterator.

This means we exhaust the iterable, storing each item in an array,
return the sequence, then extract the first item and throw away
the remainder, when retrieving individual elements.

Instead, each function can be made to consistently return an iterable
which can be expanded when necessary.
Assignee: nobody → ato
Status: NEW → ASSIGNED
Comment on attachment 8921514 [details]
Bug 1411307 - Return iterators for element retrieval.

https://reviewboard.mozilla.org/r/192542/#review198286

r=wc

::: testing/marionette/element.js:396
(Diff revision 2)
>  
>  /**
>   * Find a single element by XPath expression.
>   *
> - * @param {DOMElement} root
> - *     Document root
> + * @param {HTMLDocument} rootNode
> + *     Document root.

I don't want that we conflict with [1] by using the term `rootNode`. Can we simply name the parameter just `doc`? It would also apply to the other changes.

[1] https://developer.mozilla.org/en-US/docs/Web/API/Node/rootNode
Attachment #8921514 - Flags: review?(hskupin) → review+
Comment on attachment 8921514 [details]
Bug 1411307 - Return iterators for element retrieval.

https://reviewboard.mozilla.org/r/192542/#review198286

> I don't want that we conflict with [1] by using the term `rootNode`. Can we simply name the parameter just `doc`? It would also apply to the other changes.
> 
> [1] https://developer.mozilla.org/en-US/docs/Web/API/Node/rootNode

Fine, I’ve had to make a series of more changes because it was
referred to as a rootNode in the entry-point element.findElement and
element.findElements functions as well, but I’ve largely replaced
rootNode with document now.
Pushed by atolfsen@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/b993bccfeebb
Return iterators for element retrieval. r=whimboo
https://hg.mozilla.org/mozilla-central/rev/b993bccfeebb
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla58
Product: Testing → Remote Protocol
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: