Functions for telling apart element prototypes

RESOLVED FIXED in Firefox 58

Status

Testing
Marionette
RESOLVED FIXED
a month ago
a month ago

People

(Reporter: ato, Assigned: ato)

Tracking

Version 3
mozilla58
Points:
---

Firefox Tracking Flags

(firefox58 fixed)

Details

MozReview Requests

Submitter Diff Changes Open Issues Last Updated
Loading...
Error loading review requests:

Attachments

(5 attachments)

(Assignee)

Description

a month ago
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)

Updated

a month ago
Assignee: nobody → ato
Status: NEW → ASSIGNED
Comment hidden (mozreview-request)
Comment hidden (mozreview-request)
Comment hidden (mozreview-request)
Comment hidden (mozreview-request)
(Assignee)

Updated

a month ago
Blocks: 1400256
Comment hidden (mozreview-request)
Comment hidden (mozreview-request)
Comment hidden (mozreview-request)
Comment hidden (mozreview-request)
Comment hidden (mozreview-request)

Comment 10

a month ago
mozreview-review
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 11

a month ago
mozreview-review
Comment on attachment 8918893 [details]
Bug 1409040 - Add element.isDOMElement.

https://reviewboard.mozilla.org/r/189776/#review195558
Attachment #8918893 - Flags: review?(mjzffr) → review+

Comment 12

a month ago
mozreview-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 13

a month ago
mozreview-review
Comment on attachment 8918895 [details]
Bug 1409040 - Add element.isSVGElement.

https://reviewboard.mozilla.org/r/189780/#review195564
Attachment #8918895 - Flags: review?(mjzffr) → review+

Comment 14

a month ago
mozreview-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+
(Assignee)

Comment 15

a month ago
(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?
Comment hidden (mozreview-request)
Comment hidden (mozreview-request)
Comment hidden (mozreview-request)
Comment hidden (mozreview-request)
Comment hidden (mozreview-request)
Comment hidden (mozreview-request)
Comment hidden (mozreview-request)
Comment hidden (mozreview-request)

Comment 24

a month ago
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

Comment 25

a month ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/7add260fcf97
https://hg.mozilla.org/mozilla-central/rev/3682877a6a42
https://hg.mozilla.org/mozilla-central/rev/e156787ee23b
https://hg.mozilla.org/mozilla-central/rev/207c5e066fda
https://hg.mozilla.org/mozilla-central/rev/1283b971ebd8
Status: ASSIGNED → RESOLVED
Last Resolved: a month ago
status-firefox58: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla58
You need to log in before you can comment on or make changes to this bug.