Closed Bug 1789435 Opened 3 years ago Closed 3 years ago

With middlemouse.paste enabled: Middle-click on input field triggers TypeError: can't access property "startsWith", node.closest(...).constructor.name is undefined

Categories

(Toolkit :: UI Widgets, defect)

defect

Tracking

()

RESOLVED FIXED
110 Branch
Tracking Status
firefox-esr91 --- wontfix
firefox-esr102 --- wontfix
firefox104 --- wontfix
firefox105 --- wontfix
firefox106 --- wontfix
firefox107 --- wontfix
firefox108 --- wontfix
firefox109 --- wontfix
firefox110 --- fixed

People

(Reporter: robwu, Assigned: Gijs)

References

(Regression)

Details

(Keywords: regression)

Attachments

(1 file, 1 obsolete file)

STR:

  1. Visit any page that features an input field, e.g. the default about:home or duckduckgo.com.
  2. Use the middle mouse wheel to click on it.
  3. Open the global browser console or the browser toolbox to view error messages from the content process.

Expected:

  • no errors

Actual:

The logic in AutoScrollChild.jsm was introduced by bug 1716883.

Usually, node.constructor.name would be the name of the constructor. But in this case, some weirdness is going on with XrayWrappers. The constructor does not point to the actual HTMLDivElement class, but some wrapped version that does not have the name property. This is not visible through the tab's devtools: i.e. if you inspect the element with the devtools and then type $0.constructor.name, you'd get the expected string.

To inspect the actual value, you'd have to open the debugger of the Browser Toolbox, put a breakpoint at AutoScrollChild.jsm:64 and then you can confirm that node.constructor.name is undefined. And when the XrayWrapper is unwrapped (e.g. with .wrappedJSObject), the expected string is seen (i.e. node.wrappedJSObject.constructor.name and node.constructor.wrappedJSObject.name is HTMLDivElement).

To avoid the issue in this case, the HTMLTextAreaElement.isInstance and HTMLInputElement.isInstance methods could be used instead of checking the constructor name. Or if you'd like to get a string for some reason, use Cu.getClassName(node, true) instead of .constructor.name

Set release status flags based on info from the regressing bug 1716883

:Gijs, since you are the author of the regressor, bug 1716883, could you take a look? Also, could you set the severity field?

For more information, please visit auto_nag documentation.

Flags: needinfo?(gijskruitbosch+bugs)

What is the actual consequence of this error, if any?

Flags: needinfo?(gijskruitbosch+bugs) → needinfo?(rob)

(In reply to :Gijs (he/him) from comment #2)

What is the actual consequence of this error, if any?

Just logspam. I reported this surprising error so that there is a explanation somewhere that explains that constructor.name is unreliable when XrayWrappers are involved. The actual code fix to get rid of the error is trivial.

The specific code is supposed to only disable autoscroll logic for input fields in HTML documents, i.e. continue the autoscroll blocking logic in non-HTML documents (SVG?, XUL?).
In practice, since the code has been throwing for all documents (and effectively not triggering the auto scroll logic), the very specific condition may not be required, and it could be reasonable to resolve the bug by removing the ?.constructor.name.startsWith("HTML") altogether.

The code issue is trivial to fix though; at the bottom of the report I wrote:

To avoid the issue in this case, the HTMLTextAreaElement.isInstance and HTMLInputElement.isInstance methods could be used instead of checking the constructor name. Or if you'd like to get a string for some reason, use Cu.getClassName(node, true) instead of .constructor.name

Flags: needinfo?(rob)

(In reply to Rob Wu [:robwu] from comment #3)

The code issue is trivial to fix though

Sure, but I can't prioritize it right now.

Severity: -- → S4
Priority: -- → P3

I am kinda curious why the XrayWrapper is wrong. This might be fixable. I will try to look at this at some point.

Flags: needinfo?(evilpies)
Component: General → DOM: Bindings (WebIDL)
Product: Toolkit → Core

The product::component has been changed since the backlog priority was decided, so we're resetting it.
For more information, please visit auto_nag documentation.

Priority: P3 → --
Assignee: nobody → evilpies
Flags: needinfo?(evilpies)
Attachment #9294846 - Attachment description: WIP: Bug 1789435 - Resolve the name of DOM constructors → Bug 1789435 - Xray resolve the name of DOM constructors. r?peterv

Set release status flags based on info from the regressing bug 1716883

Attachment #9294846 - Attachment is obsolete: true
Assignee: evilpies → nobody

https://searchfox.org/mozilla-central/search?q=constructor.name&path=actor&case=false&regexp=false suggests the autoscroll child is the only child-focused code that does this, so perhaps the simplest thing is to "just" fix the actor and move on.

Assignee: nobody → gijskruitbosch+bugs
Status: NEW → ASSIGNED
Component: DOM: Bindings (WebIDL) → XUL Widgets
Product: Core → Toolkit
Summary: Middle-click on input field triggers TypeError: can't access property "startsWith", node.closest(...).constructor.name is undefined → With middlemouse.paste enabled: Middle-click on input field triggers TypeError: can't access property "startsWith", node.closest(...).constructor.name is undefined
Pushed by gijskruitbosch@gmail.com: https://hg.mozilla.org/integration/autoland/rev/ecd6cde6779d fix exception in autoscroll code when middle mouse paste is enabled, r=robwu
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 110 Branch
Flags: in-testsuite+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: