Changeset 245086 in webkit


Ignore:
Timestamp:
May 8, 2019 6:34:05 PM (5 years ago)
Author:
Chris Dumez
Message:

[iOS Debug] ASSERTION FAILED: !m_originalNode in WebCore::JSLazyEventListener::checkValidityForEventTarget(WebCore::EventTarget &)
https://bugs.webkit.org/show_bug.cgi?id=197696
<rdar://problem/50586956>

Reviewed by Simon Fraser.

Source/WebCore:

Setting the onorientationchange / onresize event handler on the body should set the event handler on the
window object, as per the HTML specification. However, calling body.addEventListener() with 'orientationchange'
or 'resize' should not set the event listener on the window object, only the body. Blink and Gecko seem to
behave as per specification but WebKit had a quirk for the addEventListener case. The quirk's implementation
is slightly wrong (because it is unsafe to take a JSLazyEventListener from a body element and add it to the
window, given that the JSLazyEventListener keeps a raw pointer to its element) and was causing crashes such
as <rdar://problem/24314027>. As a result, this patch simply drops the WebKit quirk, which will align our
behavior with other browsers and fix the crashes altogether.

Test: fast/events/ios/rotation/orientationchange-event-listener-on.body.html

  • dom/Node.cpp:

(WebCore::tryAddEventListener):
(WebCore::tryRemoveEventListener):

LayoutTests:

Add layout test coverage.

  • fast/events/ios/rotation/orientationchange-event-listener-on.body-expected.txt: Added.
  • fast/events/ios/rotation/orientationchange-event-listener-on.body.html: Added.
Location:
trunk
Files:
2 added
2 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r245085 r245086  
     12019-05-08  Chris Dumez  <cdumez@apple.com>
     2
     3        [iOS Debug] ASSERTION FAILED: !m_originalNode in WebCore::JSLazyEventListener::checkValidityForEventTarget(WebCore::EventTarget &)
     4        https://bugs.webkit.org/show_bug.cgi?id=197696
     5        <rdar://problem/50586956>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Add layout test coverage.
     10
     11        * fast/events/ios/rotation/orientationchange-event-listener-on.body-expected.txt: Added.
     12        * fast/events/ios/rotation/orientationchange-event-listener-on.body.html: Added.
     13
    1142019-05-08  Ryan Haddad  <ryanhaddad@apple.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r245085 r245086  
     12019-05-08  Chris Dumez  <cdumez@apple.com>
     2
     3        [iOS Debug] ASSERTION FAILED: !m_originalNode in WebCore::JSLazyEventListener::checkValidityForEventTarget(WebCore::EventTarget &)
     4        https://bugs.webkit.org/show_bug.cgi?id=197696
     5        <rdar://problem/50586956>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Setting the onorientationchange / onresize event handler on the body should set the event handler on the
     10        window object, as per the HTML specification. However, calling body.addEventListener() with 'orientationchange'
     11        or 'resize' should not set the event listener on the window object, only the body. Blink and Gecko seem to
     12        behave as per specification but WebKit had a quirk for the addEventListener case. The quirk's implementation
     13        is slightly wrong (because it is unsafe to take a JSLazyEventListener from a body element and add it to the
     14        window, given that the JSLazyEventListener keeps a raw pointer to its element) and was causing crashes such
     15        as <rdar://problem/24314027>. As a result, this patch simply drops the WebKit quirk, which will align our
     16        behavior with other browsers and fix the crashes altogether.
     17
     18        Test: fast/events/ios/rotation/orientationchange-event-listener-on.body.html
     19
     20        * dom/Node.cpp:
     21        (WebCore::tryAddEventListener):
     22        (WebCore::tryRemoveEventListener):
     23
    1242019-05-08  Ryan Haddad  <ryanhaddad@apple.com>
    225
  • trunk/Source/WebCore/dom/Node.cpp

    r244218 r245086  
    21192119        targetNode->document().domWindow()->incrementScrollEventListenersCount();
    21202120
    2121     // FIXME: Would it be sufficient to special-case this code for <body> and <frameset>?
    2122     //
    2123     // This code was added to address <rdar://problem/5846492> Onorientationchange event not working for document.body.
    2124     // Forward this call to addEventListener() to the window since these are window-only events.
    2125     if (eventType == eventNames().orientationchangeEvent || eventType == eventNames().resizeEvent)
    2126         targetNode->document().domWindow()->addEventListener(eventType, WTFMove(listener), options);
    2127 
    21282121#if ENABLE(TOUCH_EVENTS)
    21292122    if (eventNames().isTouchRelatedEventType(targetNode->document(), eventType))
     
    21602153    if (targetNode == &targetNode->document() && eventType == eventNames().scrollEvent)
    21612154        targetNode->document().domWindow()->decrementScrollEventListenersCount();
    2162 
    2163     // FIXME: Would it be sufficient to special-case this code for <body> and <frameset>? See <rdar://problem/15647823>.
    2164     // This code was added to address <rdar://problem/5846492> Onorientationchange event not working for document.body.
    2165     // Forward this call to removeEventListener() to the window since these are window-only events.
    2166     if (eventType == eventNames().orientationchangeEvent || eventType == eventNames().resizeEvent)
    2167         targetNode->document().domWindow()->removeEventListener(eventType, listener, options);
    21682155
    21692156#if ENABLE(TOUCH_EVENTS)
Note: See TracChangeset for help on using the changeset viewer.