Changeset 214798 in webkit


Ignore:
Timestamp:
Apr 3, 2017 9:10:45 AM (7 years ago)
Author:
Carlos Garcia Campos
Message:

Merge r214365 - Prevent new navigations during document unload
https://bugs.webkit.org/show_bug.cgi?id=169934
<rdar://problem/31247584>

Reviewed by Chris Dumez.

Source/WebCore:

Similar to our policy of preventing new navigations from onbeforeunload handlers
we should prevent new navigations that are initiated during the document unload
process.

The significant part of this change is the instantiation of the RAII object NavigationDisabler
in Document::prepareForDestruction(). The rest of this change just renames class
NavigationDisablerForBeforeUnload to NavigationDisabler now that this RAII class is
used to prevent navigation from both onbeforeunload event handlers and when unloading
a document.

Test: fast/frames/frame-unload-navigate-and-setTimeout-assert-fail.html

  • dom/Document.cpp:

(WebCore::Document::prepareForDestruction): Disable new navigations when disconnecting
subframes. Also assert that the document is not in the page cache before we fall off
the end of the function.

  • loader/FrameLoader.cpp:

(WebCore::FrameLoader::isNavigationAllowed): Update for renaming below.
(WebCore::FrameLoader::shouldClose): Ditto.

  • loader/NavigationScheduler.cpp:

(WebCore::NavigationScheduler::shouldScheduleNavigation): Ditto.

  • loader/NavigationScheduler.h:

(WebCore::NavigationDisabler::NavigationDisabler): Renamed class; formerly named NavigationDisablerForBeforeUnload.
(WebCore::NavigationDisabler::~NavigationDisabler): Ditto.
(WebCore::NavigationDisabler::isNavigationAllowed): Ditto.
(WebCore::NavigationDisablerForBeforeUnload::NavigationDisablerForBeforeUnload): Deleted.
(WebCore::NavigationDisablerForBeforeUnload::~NavigationDisablerForBeforeUnload): Deleted.
(WebCore::NavigationDisablerForBeforeUnload::isNavigationAllowed): Deleted.

LayoutTests:

Add a test to ensure that we do not cause an assertion fail when calling setTimeout
after starting a navigation from an onunload event handler.

  • fast/frames/frame-unload-navigate-and-setTimeout-assert-fail-expected.txt: Added.
  • fast/frames/frame-unload-navigate-and-setTimeout-assert-fail.html: Added.
Location:
releases/WebKitGTK/webkit-2.16
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • releases/WebKitGTK/webkit-2.16/LayoutTests/ChangeLog

    r214796 r214798  
     12017-03-24  Daniel Bates  <dabates@apple.com>
     2
     3        Prevent new navigations during document unload
     4        https://bugs.webkit.org/show_bug.cgi?id=169934
     5        <rdar://problem/31247584>
     6
     7        Reviewed by Chris Dumez.
     8
     9        Add a test to ensure that we do not cause an assertion fail when calling setTimeout
     10        after starting a navigation from an onunload event handler.
     11
     12        * fast/frames/frame-unload-navigate-and-setTimeout-assert-fail-expected.txt: Added.
     13        * fast/frames/frame-unload-navigate-and-setTimeout-assert-fail.html: Added.
     14
    1152017-03-24  Per Arne Vollan  <pvollan@apple.com>
    216
  • releases/WebKitGTK/webkit-2.16/Source/WebCore/ChangeLog

    r214796 r214798  
     12017-03-24  Daniel Bates  <dabates@apple.com>
     2
     3        Prevent new navigations during document unload
     4        https://bugs.webkit.org/show_bug.cgi?id=169934
     5        <rdar://problem/31247584>
     6
     7        Reviewed by Chris Dumez.
     8
     9        Similar to our policy of preventing new navigations from onbeforeunload handlers
     10        we should prevent new navigations that are initiated during the document unload
     11        process.
     12
     13        The significant part of this change is the instantiation of the RAII object NavigationDisabler
     14        in Document::prepareForDestruction(). The rest of this change just renames class
     15        NavigationDisablerForBeforeUnload to NavigationDisabler now that this RAII class is
     16        used to prevent navigation from both onbeforeunload event handlers and when unloading
     17        a document.
     18
     19        Test: fast/frames/frame-unload-navigate-and-setTimeout-assert-fail.html
     20
     21        * dom/Document.cpp:
     22        (WebCore::Document::prepareForDestruction): Disable new navigations when disconnecting
     23        subframes. Also assert that the document is not in the page cache before we fall off
     24        the end of the function.
     25        * loader/FrameLoader.cpp:
     26        (WebCore::FrameLoader::isNavigationAllowed): Update for renaming below.
     27        (WebCore::FrameLoader::shouldClose): Ditto.
     28        * loader/NavigationScheduler.cpp:
     29        (WebCore::NavigationScheduler::shouldScheduleNavigation): Ditto.
     30        * loader/NavigationScheduler.h:
     31        (WebCore::NavigationDisabler::NavigationDisabler): Renamed class; formerly named NavigationDisablerForBeforeUnload.
     32        (WebCore::NavigationDisabler::~NavigationDisabler): Ditto.
     33        (WebCore::NavigationDisabler::isNavigationAllowed): Ditto.
     34        (WebCore::NavigationDisablerForBeforeUnload::NavigationDisablerForBeforeUnload): Deleted.
     35        (WebCore::NavigationDisablerForBeforeUnload::~NavigationDisablerForBeforeUnload): Deleted.
     36        (WebCore::NavigationDisablerForBeforeUnload::isNavigationAllowed): Deleted.
     37
    1382017-03-24  Per Arne Vollan  <pvollan@apple.com>
    239
  • releases/WebKitGTK/webkit-2.16/Source/WebCore/dom/Document.cpp

    r214747 r214798  
    22732273    }
    22742274#endif
    2275    
    2276     disconnectDescendantFrames();
     2275
     2276    {
     2277        NavigationDisabler navigationDisabler;
     2278        disconnectDescendantFrames();
     2279    }
     2280
    22772281    if (m_domWindow && m_frame)
    22782282        m_domWindow->willDetachDocumentFromFrame();
     
    23282332
    23292333    m_hasPreparedForDestruction = true;
     2334
     2335    // Note that m_pageCacheState can be Document::AboutToEnterPageCache if our frame
     2336    // was removed in an onpagehide event handler fired when the top-level frame is
     2337    // about to enter the page cache.
     2338    ASSERT_WITH_SECURITY_IMPLICATION(m_pageCacheState != Document::InPageCache);
    23302339}
    23312340
  • releases/WebKitGTK/webkit-2.16/Source/WebCore/loader/FrameLoader.cpp

    r214783 r214798  
    11881188bool FrameLoader::isNavigationAllowed() const
    11891189{
    1190     return m_pageDismissalEventBeingDispatched == PageDismissalType::None && NavigationDisablerForBeforeUnload::isNavigationAllowed();
     1190    return m_pageDismissalEventBeingDispatched == PageDismissalType::None && NavigationDisabler::isNavigationAllowed();
    11911191}
    11921192
     
    29092909    bool shouldClose = false;
    29102910    {
    2911         NavigationDisablerForBeforeUnload navigationDisabler;
     2911        NavigationDisabler navigationDisabler;
    29122912        size_t i;
    29132913
  • releases/WebKitGTK/webkit-2.16/Source/WebCore/loader/NavigationScheduler.cpp

    r212250 r214798  
    5656namespace WebCore {
    5757
    58 unsigned NavigationDisablerForBeforeUnload::s_navigationDisableCount = 0;
     58unsigned NavigationDisabler::s_navigationDisableCount = 0;
    5959
    6060class ScheduledNavigation {
     
    365365    if (protocolIsJavaScript(url))
    366366        return true;
    367     return NavigationDisablerForBeforeUnload::isNavigationAllowed();
     367    return NavigationDisabler::isNavigationAllowed();
    368368}
    369369
  • releases/WebKitGTK/webkit-2.16/Source/WebCore/loader/NavigationScheduler.h

    r210859 r214798  
    4444class URL;
    4545
    46 class NavigationDisablerForBeforeUnload {
     46class NavigationDisabler {
    4747public:
    48     NavigationDisablerForBeforeUnload()
     48    NavigationDisabler()
    4949    {
    5050        s_navigationDisableCount++;
    5151    }
    52     ~NavigationDisablerForBeforeUnload()
     52    ~NavigationDisabler()
    5353    {
    5454        ASSERT(s_navigationDisableCount);
Note: See TracChangeset for help on using the changeset viewer.