Closed Bug 1530110 Opened 5 years ago Closed 5 years ago

element.isInView throws for non-HTML elements.

Categories

(Remote Protocol :: Marionette, enhancement, P3)

Version 3
enhancement

Tracking

(firefox71 fixed)

RESOLVED FIXED
mozilla71
Tracking Status
firefox71 --- fixed

People

(Reporter: emilio, Assigned: fredw)

References

Details

Attachments

(1 file, 1 obsolete file)

Because it uses element.style without checking first, and element.style is only available in HTML and SVG elements:

https://drafts.csswg.org/cssom/#the-elementcssinlinestyle-interface

This is why the test in https://github.com/web-platform-tests/wpt/pull/15530 fails in Firefox.

Here the stack trace from that github PR:

UnknownException: TypeError: el.style is undefined
stacktrace:
element.isInView@chrome://marionette/content/element.js:1065:7
webdriverClickElement@chrome://marionette/content/interaction.js:148:8
interaction.clickElement@chrome://marionette/content/interaction.js:130:11
clickElement/<@chrome://marionette/content/listener.js:1208:14
navigate/<@chrome://marionette/content/listener.js:408:13
navigate@chrome://marionette/content/listener.js:407:13
clickElement@chrome://marionette/content/listener.js:1207:5

It's being used for getting/setting el.style.pointerEvents. Do MathML documents don't have pointer events, or would we only have to change the logic in how to get/set the pointer event type?

If we cannot use pointer events auto in MathML how could we get the pointer-interactable paint tree? Maybe it's not necessary for MathML?

They do have style, and thus pointer events, just no inline style interface... It'd be fairly weird to specify pointer-events in MathML I guess...

I don't know all the details about MathML. So feedback about that would be welcome.

The affected code in Marionette looks like the following:
https://searchfox.org/mozilla-central/rev/dbddac86aadf1d4871fb350bbe66db43728a9f81/testing/marionette/element.js#1060-1077

Any proposal from your side in what we would have to change?

Priority: -- → P3

(In reply to Henrik Skupin (:whimboo) [⌚️UTC+2] from comment #3)

I don't know all the details about MathML. So feedback about that would be welcome.

The affected code in Marionette looks like the following:
https://searchfox.org/mozilla-central/rev/dbddac86aadf1d4871fb350bbe66db43728a9f81/testing/marionette/element.js#1060-1077

Any proposal from your side in what we would have to change?

I expect this can be fixed by bug 1571487.

However, I wonder if what you want is actually to use window.getComputedStyle to get the exact style of the element rather than the inline style (i.e. set by the style attribute). See https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style and https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle

If so, I can try to upload a patch.

Flags: needinfo?(hskupin)
See Also: → mathml-dom

Interesting. So there is also this paragraph on MDN, which shows that we even would not get all the final values for CSS properties, and as such using Element.style could have wrong behavior:

https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style#Getting_style_information

To get the values of all CSS properties for an element you should use Window.getComputedStyle() instead.

Andreas, do you know why that code doesn't use Window.getComputedStyle() but Element.style instead? If it is just old and crufty code, and would appreciate a rewrite?

Flags: needinfo?(hskupin) → needinfo?(ato)

(In reply to Henrik Skupin (:whimboo) [⌚️UTC+2] from comment #5)

[D]o you know why that code doesn't use
Window.getComputedStyle() but Element.style instead? If it is
just old and crufty code, and would appreciate a rewrite?

That looks like an oversight: it should definitely be using the
computed style!

I want to also point out that this trycatch logic with modifying
the document is not ideal. If anyone knows of a better way to get
elements with pointer-events: none set included in the paint
tree/elementsFromPoint(), then please speak up.

Flags: needinfo?(ato)

Andreas, mind filing the topic of the 2nd paragraph as a new bug? I don't think that we should shovel it into this bug.

Frédéric Wang, if you could create a patch for using getComputedStyle() that would be really appreciated. Maybe you could also add a small MathML testcase (as best as data URI) so we can verify it?

Flags: needinfo?(fred.wang)
Flags: needinfo?(ato)
Flags: needinfo?(ato)
Attached patch bug-1530110.patch (obsolete) — Splinter Review

OK, I stand corrected: https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleDeclaration says that Window.getComputedStyle() returns a read-only interface so you can read the original value but won't be able to use it to set the inline style anyway. One would have to do something more complicate with setAttribute('style', '...') instead. I think it will be best to implement the style IDL attribute on MathML elements instead (bug 1571487).

In any case I'm attaching a patch with a tentative marionette test and the MathML href test that is expected to be fixed.

Assignee: nobody → fred.wang
Flags: needinfo?(fred.wang)

Thanks. Marking bug 1571487 as dependency then.

Depends on: mathml-dom

Marionette's element.isInView function relies on the style IDL attribute.
This patch verifies that the function works as expected for MathML elements
after bug 1571487.

For MathML this is going to be fixed by 1571487. I uploaded a patch to add a marionette test for MathML. I think things will work for HTML, SVG, MathML and XUL elements since they support the style IDL attribute. Not sure we really care about this issue for other elements....

Great to see. Thanks a lot. We can already do the review while waiting for the other bug to be fixed.

Status: NEW → ASSIGNED
Attachment #9087002 - Attachment is obsolete: true
Pushed by hskupin@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/21e3e7f5b1ff
element.isInView throws for non-HTML elements. r=whimboo
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla71
No longer blocks: 1555285
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: