Closed Bug 1905267 Opened 1 year ago Closed 1 year ago

Possible uncaught TypeError when detaching tab

Categories

(Core :: DOM: UI Events & Focus Handling, defect)

defect

Tracking

()

RESOLVED FIXED
130 Branch
Tracking Status
firefox-esr115 --- unaffected
firefox-esr128 --- wontfix
firefox128 --- wontfix
firefox129 --- wontfix
firefox130 --- wontfix

People

(Reporter: tabmix.onemen, Assigned: masayuki)

References

(Regression)

Details

(Keywords: regression)

Attachments

(2 files)

When holding tab title and dragging the tab to detach it, we end up with this errors if the target element of the event was the #text

Uncaught TypeError: can't access property "contains", event.target.classList is undefined
    on_mouseover chrome://browser/content/tabbrowser/tab.js:348
    handleEvent chrome://global/content/customElements.js:459
    on_mouseover(event) {
      if (event.target.classList.contains("tab-close-button")) {
        this.mOverCloseButton = true;
      }

Thanks for filing this bug!
We are unable to reproduce this.
Are you able to reproduce this bug in a new profile?

Flags: needinfo?(tabmix.onemen)

Yes,

I tested a new profile on Firefox nightly from today.
make sure to drag the mouse by its title.
see in this image where to hold your mouse for dragging the tab. then drag the tab to detach it
image

Flags: needinfo?(tabmix.onemen)

The severity field is not set for this bug.
:mak, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(mak)

I bisected the problem to
https://hg.mozilla.org/integration/autoland/pushloghtml?fromchange=23d502ed06280881577c5f9df617026ee30500f1&tochange=88c50740c90849f41b36a3ebdea5c1182d010b62
That points to Bug 1877815.
I don't know the details about that change, but it looks like it would change the event target in some cases, and that's apparently what happened here. I can confirm event.target and event.originalTarget are a #text node.
I'm not sure whether that change was expected, thus needinfo-ing Masayuki, before evaluating changes to the code here (we can surely check what the event target is).

Flags: needinfo?(mak) → needinfo?(masayuki)
Keywords: regression
Regressed by: 1877815

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

Of source, no.

Assignee: nobody → masayuki
Status: NEW → ASSIGNED
Component: Tabbed Browser → DOM: UI Events & Focus Handling
Flags: needinfo?(masayuki)
OS: Unspecified → All
Product: Firefox → Core
Hardware: Unspecified → All

PresShell::mCurrentEventTargetContent may be update to non-element node
when PresShell::mCurrentEventTargetFrame is destroyed. Therefore, for
avoiding it, I'd like to add EventMessage to the group to consider whether
the content needs to be Element. However, adding new members for current
and stack would make PresShell members more messy. Therefore, I'd like to
group the data with the simple struct.

When event target frame is destroyed, PresShell::NotifyDestroyingFrame updates
current event target content to the frame content. However, event target of
some DOM events need to be Element. Therefore,
PresShell::mCurrentEventTarget needs to store at least the handling
EventMessage to consider whether the event target can be non-element content
node or only element node. So, we need to make PresShell::EventTargetInfo
store EventMessage. Then, we can make PresShell::NotifyDestroyingFrame
prefer inclusive ancestor element as new event target from the EventMessage.

Although I don't understand what's going on the reported case, but I found the
simple case when event target is changed to a Text with the assertion in
PresShell::DispatchEventToDOM. Therefore, this patch has a new test.

Note that if target frame is a frame for element, e.g., when event target is
a focused element, IsForbiddenDispatchingToNonElementContent result won't
change the behavior. Therefore, its implementation is not optimized for
non-user input events nor user input events without ref-point.

Depends on D217204

Pushed by masayuki@d-toybox.com: https://hg.mozilla.org/integration/autoland/rev/917da27ba36c part 1: Make `PresShell` manage event target frame and content with a struct r=smaug https://hg.mozilla.org/integration/autoland/rev/d4221479caa6 part 2: Make `PresShell` not use non-element event target when target frame is destroyed and the event wants `Element` target r=smaug
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/47347 for changes under testing/web-platform/tests

The patches fix a bug of considering event target at text frame destruction which has existed since 1999 at latest. Therefore, we should not uplift the patches except when this bug causes users unhappy in some important web apps in the wild.

Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 130 Branch
Upstream PR merged by moz-wptsync-bot
Regressions: 1919145
Duplicate of this bug: 1646674
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: