Changeset 234684 in webkit


Ignore:
Timestamp:
Aug 7, 2018 6:41:45 PM (6 years ago)
Author:
Chris Dumez
Message:

navigator.sendBeacon does not work in pagehide callbacks
https://bugs.webkit.org/show_bug.cgi?id=188329

Reviewed by Alex Christensen.

Source/WebCore:

Add support for sending beacons from pagehide event handlers. We normally do not allow loads because we're
about to enter PageCache. However, in case of Beacon, this is fine since it uses PingLoad and does not
WebCore to do the load.

Test: http/wpt/beacon/sendBeacon-in-pagehide.html

  • loader/cache/CachedResource.cpp:

(WebCore::CachedResource::load):

  • Allow Beacon loads to go through even if the document's pageCacheState is AboutToEnterPageCache (i.e.

we're firing the 'pagehide' event)

  • Allow Becon loads to go though even if the FrameLoader's state is provisional (i.e. a load is pending)

LayoutTests:

Add layout test coverage.

  • http/wpt/beacon/sendBeacon-in-pagehide-expected.txt: Added.
  • http/wpt/beacon/sendBeacon-in-pagehide.html: Added.
  • http/wpt/beacon/support/sendBeacon-onpagehide-window.html: Added.
Location:
trunk
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r234683 r234684  
     12018-08-07  Chris Dumez  <cdumez@apple.com>
     2
     3        navigator.sendBeacon does not work in pagehide callbacks
     4        https://bugs.webkit.org/show_bug.cgi?id=188329
     5
     6        Reviewed by Alex Christensen.
     7
     8        Add layout test coverage.
     9
     10        * http/wpt/beacon/sendBeacon-in-pagehide-expected.txt: Added.
     11        * http/wpt/beacon/sendBeacon-in-pagehide.html: Added.
     12        * http/wpt/beacon/support/sendBeacon-onpagehide-window.html: Added.
     13
    1142018-08-07  Said Abou-Hallawa  <sabouhallawa@apple.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r234683 r234684  
     12018-08-07  Chris Dumez  <cdumez@apple.com>
     2
     3        navigator.sendBeacon does not work in pagehide callbacks
     4        https://bugs.webkit.org/show_bug.cgi?id=188329
     5
     6        Reviewed by Alex Christensen.
     7
     8        Add support for sending beacons from pagehide event handlers. We normally do not allow loads because we're
     9        about to enter PageCache. However, in case of Beacon, this is fine since it uses PingLoad and does not
     10        WebCore to do the load.
     11
     12        Test: http/wpt/beacon/sendBeacon-in-pagehide.html
     13
     14        * loader/cache/CachedResource.cpp:
     15        (WebCore::CachedResource::load):
     16        - Allow Beacon loads to go through even if the document's pageCacheState is AboutToEnterPageCache (i.e.
     17        we're firing the 'pagehide' event)
     18        - Allow Becon loads to go though even if the FrameLoader's state is provisional (i.e. a load is pending)
     19
    1202018-08-07  Said Abou-Hallawa  <sabouhallawa@apple.com>
    221
  • trunk/Source/WebCore/loader/cache/CachedResource.cpp

    r233839 r234684  
    202202    // cache.
    203203    if (auto* topDocument = frame.mainFrame().document()) {
    204         if (topDocument->pageCacheState() != Document::NotInPageCache) {
     204        switch (topDocument->pageCacheState()) {
     205        case Document::NotInPageCache:
     206            break;
     207        case Document::AboutToEnterPageCache:
     208            // Beacons are allowed to go through in 'pagehide' event handlers.
     209            if (shouldUsePingLoad(type()))
     210                break;
     211            FALLTHROUGH;
     212        case Document::InPageCache:
    205213            RELEASE_LOG_IF_ALLOWED("load: Already in page cache or being added to it (frame = %p)", &frame);
    206214            failBeforeStarting();
     
    210218
    211219    FrameLoader& frameLoader = frame.loader();
    212     if (m_options.securityCheck == SecurityCheckPolicy::DoSecurityCheck && (frameLoader.state() == FrameStateProvisional || !frameLoader.activeDocumentLoader() || frameLoader.activeDocumentLoader()->isStopping())) {
     220    if (m_options.securityCheck == SecurityCheckPolicy::DoSecurityCheck && !shouldUsePingLoad(type()) && (frameLoader.state() == FrameStateProvisional || !frameLoader.activeDocumentLoader() || frameLoader.activeDocumentLoader()->isStopping())) {
    213221        if (frameLoader.state() == FrameStateProvisional)
    214222            RELEASE_LOG_IF_ALLOWED("load: Failed security check -- state is provisional (frame = %p)", &frame);
Note: See TracChangeset for help on using the changeset viewer.