Changeset 198924 in webkit


Ignore:
Timestamp:
Mar 31, 2016 3:43:45 PM (8 years ago)
Author:
dbates@webkit.org
Message:

REGRESSION (r195605): ASSERTION FAILED: !NoEventDispatchAssertion::isEventDispatchForbidden()
when pressing the back button on a page with a focused subframe
https://bugs.webkit.org/show_bug.cgi?id=156033
<rdar://problem/25446561>

Reviewed by Chris Dumez.

Source/WebCore:

Fixes an assertion failure when navigating back, by pressing the browser back button, to
the previous page from a page with a focused subframe.

Following r195605 (https://bugs.webkit.org/show_bug.cgi?id=153449), the responsibility for
dispatching a DOM pagehide event moved from CachedFrame to PageCache and we now instantiate
a NoEventDispatchAssertion object to enforce the invariant that no additional DOM events are
dispatched as part of adding a page to the page cache. When adding a page with a focused
subframe to the page cache we focus its main frame, which implicitly defocuses the subframe
and dispatches a DOM blur event at it. Therefore an assertion failure occurs when dispatching
this DOM blur event (because a NoEventDispatchAssertion object was allocated on the stack).

Test: fast/history/back-from-page-with-focused-iframe.html

  • history/CachedFrame.cpp:

(WebCore::CachedFrame::CachedFrame): Move logic to focus the main frame from here...

  • history/PageCache.cpp:

(WebCore::PageCache::addIfCacheable): to here such that any DOM blur and focus events
are dispatched before instantiate the NoEventDispatchAssertion object and enter the page
cache.

LayoutTests:

Add a test to ensure that when navigating back from a page with a focused <iframe> f, a DOM
blur event is dispatched to f, a DOM focus event is dispatched at the main frame and that
an assertion failure does not occur (only applicable in a debug build).

  • fast/history/back-from-page-with-focused-iframe-expected.txt: Added.
  • fast/history/back-from-page-with-focused-iframe.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r198917 r198924  
     12016-03-31  Daniel Bates  <dabates@apple.com>
     2
     3        REGRESSION (r195605): ASSERTION FAILED: !NoEventDispatchAssertion::isEventDispatchForbidden()
     4        when pressing the back button on a page with a focused subframe
     5        https://bugs.webkit.org/show_bug.cgi?id=156033
     6        <rdar://problem/25446561>
     7
     8        Reviewed by Chris Dumez.
     9
     10        Add a test to ensure that when navigating back from a page with a focused <iframe> f, a DOM
     11        blur event is dispatched to f, a DOM focus event is dispatched at the main frame and that
     12        an assertion failure does not occur (only applicable in a debug build).
     13
     14        * fast/history/back-from-page-with-focused-iframe-expected.txt: Added.
     15        * fast/history/back-from-page-with-focused-iframe.html: Added.
     16
    1172016-03-31  Chris Dumez  <cdumez@apple.com>
    218
  • trunk/Source/WebCore/ChangeLog

    r198917 r198924  
     12016-03-31  Daniel Bates  <dabates@apple.com>
     2
     3        REGRESSION (r195605): ASSERTION FAILED: !NoEventDispatchAssertion::isEventDispatchForbidden()
     4        when pressing the back button on a page with a focused subframe
     5        https://bugs.webkit.org/show_bug.cgi?id=156033
     6        <rdar://problem/25446561>
     7
     8        Reviewed by Chris Dumez.
     9
     10        Fixes an assertion failure when navigating back, by pressing the browser back button, to
     11        the previous page from a page with a focused subframe.
     12
     13        Following r195605 (https://bugs.webkit.org/show_bug.cgi?id=153449), the responsibility for
     14        dispatching a DOM pagehide event moved from CachedFrame to PageCache and we now instantiate
     15        a NoEventDispatchAssertion object to enforce the invariant that no additional DOM events are
     16        dispatched as part of adding a page to the page cache. When adding a page with a focused
     17        subframe to the page cache we focus its main frame, which implicitly defocuses the subframe
     18        and dispatches a DOM blur event at it. Therefore an assertion failure occurs when dispatching
     19        this DOM blur event (because a NoEventDispatchAssertion object was allocated on the stack).
     20
     21        Test: fast/history/back-from-page-with-focused-iframe.html
     22
     23        * history/CachedFrame.cpp:
     24        (WebCore::CachedFrame::CachedFrame): Move logic to focus the main frame from here...
     25        * history/PageCache.cpp:
     26        (WebCore::PageCache::addIfCacheable): to here such that any DOM blur and focus events
     27        are dispatched before instantiate the NoEventDispatchAssertion object and enter the page
     28        cache.
     29
    1302016-03-31  Chris Dumez  <cdumez@apple.com>
    231
  • trunk/Source/WebCore/history/CachedFrame.cpp

    r196641 r198924  
    3434#include "EventNames.h"
    3535#include "ExceptionCode.h"
    36 #include "FocusController.h"
    3736#include "FrameLoader.h"
    3837#include "FrameLoaderClient.h"
     
    148147    ASSERT(m_view);
    149148
    150     if (frame.page()->focusController().focusedFrame() == &frame)
    151         frame.page()->focusController().setFocusedFrame(&frame.mainFrame());
    152 
    153149    // Custom scrollbar renderers will get reattached when the document comes out of the page cache
    154150    m_view->detachCustomScrollbars();
  • trunk/Source/WebCore/history/PageCache.cpp

    r198476 r198924  
    3838#include "Document.h"
    3939#include "DocumentLoader.h"
     40#include "FocusController.h"
    4041#include "FrameLoader.h"
    4142#include "FrameLoaderClient.h"
     
    393394    setInPageCache(*page, true);
    394395
     396    // Focus the main frame, defocusing a focused subframe (if we have one). We do this here,
     397    // before the page enters the page cache, while we still can dispatch DOM blur/focus events.
     398    if (page->focusController().focusedFrame())
     399        page->focusController().setFocusedFrame(&page->mainFrame());
     400
    395401    // Fire the pagehide event in all frames.
    396402    firePageHideEventRecursively(page->mainFrame());
Note: See TracChangeset for help on using the changeset viewer.