Closed Bug 1409040 Opened 7 years ago Closed 7 years ago

Functions for telling apart element prototypes

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)

References

Details

Attachments

(5 files)

With https://bugzil.la/1400256 we need to have more versatile and
specific functions for determining the prototypes of elements.  We
need the ability to tell DOM elements apart from SVG elements, XUL
elements, XBL elements, and WindowProxies.
Assignee: nobody → ato
Status: NEW → ASSIGNED
Blocks: 1400256
Comment on attachment 8918892 [details]
Bug 1409040 - Make element.isXULElement more resiliant.

https://reviewboard.mozilla.org/r/189774/#review195552
Attachment #8918892 - Flags: review?(mjzffr) → review+
Comment on attachment 8918894 [details]
Bug 1409040 - Add element.isDOMWindow.

https://reviewboard.mozilla.org/r/189778/#review195562

::: testing/marionette/element.js:1097
(Diff revision 2)
> + */
> +element.isDOMWindow = function(node) {
> +  return typeof node == "object" &&
> +      node !== null &&
> +      typeof node.toString == "function" &&
> +      node.toString() == "[object Window]" &&

Would it help to check `Object.prototype.toString.call(node)`?
Attachment #8918894 - Flags: review?(mjzffr) → review+
Comment on attachment 8919300 [details]
Bug 1409040 - Add element.isElement shorthand.

https://reviewboard.mozilla.org/r/190178/#review195566
Attachment #8919300 - Flags: review?(mjzffr) → review+
(In reply to Maja Frydrychowicz (:maja_zf) from comment #12)
> Comment on attachment 8918894 [details]
> Bug 1409040 - Add element.isDOMWindow.
> 
> https://reviewboard.mozilla.org/r/189778/#review195562
> 
> ::: testing/marionette/element.js:1097
> (Diff revision 2)
> > + */
> > +element.isDOMWindow = function(node) {
> > +  return typeof node == "object" &&
> > +      node !== null &&
> > +      typeof node.toString == "function" &&
> > +      node.toString() == "[object Window]" &&
> 
> Would it help to check `Object.prototype.toString.call(node)`?

This would be the correct thing to do, but I’m not sure how to
unit test it since calling that on the domWin stub will return
"[object Object]".  Perhaps there is some way to replace the
object’s prototype?
Pushed by atolfsen@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/7add260fcf97
Make element.isXULElement more resiliant. r=maja_zf
https://hg.mozilla.org/integration/autoland/rev/3682877a6a42
Add element.isDOMElement. r=maja_zf
https://hg.mozilla.org/integration/autoland/rev/e156787ee23b
Add element.isDOMWindow. r=maja_zf
https://hg.mozilla.org/integration/autoland/rev/207c5e066fda
Add element.isSVGElement. r=maja_zf
https://hg.mozilla.org/integration/autoland/rev/1283b971ebd8
Add element.isElement shorthand. r=maja_zf
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: