Open Bug 1704197 Opened 3 years ago Updated 3 years ago

HTMLElement.innerText returns opposite behavior for HTML elements that are descendants of XUL elements

Categories

(Core :: DOM: Core & HTML, enhancement, P3)

enhancement

Tracking

()

People

(Reporter: jaws, Unassigned)

References

Details

Test case:
Apply the patch in bug 1703958
Right-click on a tab and choose to Mute the tab
Inspect the .tab-secondary-label
Execute $0.innerText in the console

Expected:
$0.innerText returns "MUTED"

Actual:
$0.innerText returns ""

Further, select the .tab-icon-sound-playing-label child, $0.innerText returns "PLAYING". Now select the .tab-icon-sound-muted-label child, $0.innerText returns "".

:jaws: please provide more detailed STR. I couldn't reproduce the issue, because

12:09:40.014 document.querySelector(".tab-secondary-label")
12:09:40.032 null

from both the muted tab and some other tab.

Flags: needinfo?(jaws)

.innerText is super weird old IE-ism. It depends on the layout state.
And accessing it causes a style flush and possibly also layout flush, so chrome code probably shouldn't use it, at least the getter.

https://searchfox.org/mozilla-central/rev/fa48ebee58d59fa846919c3e2c3122b08db57c9c/dom/html/nsGenericHTMLElement.cpp#2723,2731-2734

I think the reason for the getter behavior is
https://searchfox.org/mozilla-central/rev/fa48ebee58d59fa846919c3e2c3122b08db57c9c/layout/xul/nsBoxFrame.h#118
https://searchfox.org/mozilla-central/rev/fa48ebee58d59fa846919c3e2c3122b08db57c9c/dom/base/nsRange.cpp#3084,3090
Maybe IsVisibleAndNotInReplacedElement could exclude XUL similarly to SVG?

(In reply to Mirko Brodesser (:mbrodesser) from comment #1)

:jaws: please provide more detailed STR. I couldn't reproduce the issue, because

12:09:40.014 document.querySelector(".tab-secondary-label")
12:09:40.032 null

from both the muted tab and some other tab.

  1. Apply the patch in bug 1703958
  2. Make sure you only have one tab open
  3. Right-click on a tab and choose to Mute the tab
  4. Open the Browser Console and execute the following: document.querySelector(".tab-secondary-label").innerText

".tab-secondary-label" is defined for all tabs regardless if Proton is enabled or not. Did you test with mozilla-central?
https://searchfox.org/mozilla-central/rev/6cbe34b441f7c7c29cd1e5f0e19c7000142f1423/browser/base/content/tabbrowser-tab.js#51

I just confirmed these STR on latest m-c (1c01cb995fc9).

Though it looks like Olli explained it and as such we will need to find a solution that doesn't use .innerText, so the priority of this bug is much lower. I am fine with closing this as "wontfix" if you agree.

Flags: needinfo?(jaws)

I think we should even consider to hide innerText from chrome context.

Severity: -- → S3
Type: defect → enhancement
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.