⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 118631 in webkit


Ignore:
Timestamp:
May 27, 2012, 2:31:54 PM (14 years ago)
Author:
benjamin@webkit.org
Message:

When pages are loaded from AppCache with DeferredLoading, willSendRequest() is never called
https://bugs.webkit.org/show_bug.cgi?id=87582

Patch by Benjamin Poulain <bpoulain@apple.com> on 2012-05-27
Reviewed by Darin Adler.

Source/WebCore:

Previously, there was a shortcut when a deferred MainResourceLoader is resumed: If the data
was coming from AppCache we could jump directly to startDataLoadTimer().

The problem with the shortcut is willSendRequest() is never called in that particular case
(substituteData + deferred-resume). The imbalance between willSendRequest() and didReceiveResponse()
causes problems.

This patch removes the shortcut so that MainResourceLoader::loadNow() is used regardless of
the deferred loading. The method MainResourceLoader::loadNow() handle the substituteData as if the loading
was not deferred.

Test: http/tests/appcache/load-from-appcache-defer-resume-crash.html

  • loader/MainResourceLoader.cpp:

(WebCore::MainResourceLoader::continueAfterNavigationPolicy):
(WebCore::MainResourceLoader::handleSubstituteDataLoadSoon):
Rename the method to be consistent with the attribute it uses, making the naming more explicit.
(WebCore::MainResourceLoader::loadNow):
(WebCore::MainResourceLoader::setDefersLoading):

  • loader/MainResourceLoader.h:

(MainResourceLoader):

Tools:

Extend DumpRenderTree to support loading the main resource deferred with a delay. This makes it
possible to test pages in a similar way as they are loaded in Browsers.

  • DumpRenderTree/LayoutTestController.cpp:

(LayoutTestController::LayoutTestController):
(setUseDeferredFrameLoadingCallback):
(LayoutTestController::staticFunctions):

  • DumpRenderTree/LayoutTestController.h:

(LayoutTestController::useDeferredFrameLoading):
(LayoutTestController::setUseDeferredFrameLoading):
(LayoutTestController):

  • DumpRenderTree/mac/FrameLoadDelegate.mm:

(-[FrameLoadDelegate webView:didStartProvisionalLoadForFrame:]):

LayoutTests:

  • http/tests/appcache/load-from-appcache-defer-resume-crash-expected.txt: Added.
  • http/tests/appcache/load-from-appcache-defer-resume-crash.html: Added.
  • http/tests/appcache/resources/load-from-appcache-defer-resume-bounce-back.html: Added.
  • http/tests/appcache/resources/load-from-appcache-defer-resume-crash.manifest: Added.
Location:
trunk
Files:
4 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r118630 r118631  
     12012-05-27  Benjamin Poulain  <bpoulain@apple.com>
     2
     3        When pages are loaded from AppCache with DeferredLoading, willSendRequest() is never called
     4        https://bugs.webkit.org/show_bug.cgi?id=87582
     5
     6        Reviewed by Darin Adler.
     7
     8        * http/tests/appcache/load-from-appcache-defer-resume-crash-expected.txt: Added.
     9        * http/tests/appcache/load-from-appcache-defer-resume-crash.html: Added.
     10        * http/tests/appcache/resources/load-from-appcache-defer-resume-bounce-back.html: Added.
     11        * http/tests/appcache/resources/load-from-appcache-defer-resume-crash.manifest: Added.
     12
    1132012-05-27  Zan Dobersek  <zandobersek@gmail.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r118624 r118631  
     12012-05-27  Benjamin Poulain  <bpoulain@apple.com>
     2
     3        When pages are loaded from AppCache with DeferredLoading, willSendRequest() is never called
     4        https://bugs.webkit.org/show_bug.cgi?id=87582
     5
     6        Reviewed by Darin Adler.
     7
     8        Previously, there was a shortcut when a deferred MainResourceLoader is resumed: If the data
     9        was coming from AppCache we could jump directly to startDataLoadTimer().
     10
     11        The problem with the shortcut is willSendRequest() is never called in that particular case
     12        (substituteData + deferred-resume). The imbalance between willSendRequest() and didReceiveResponse()
     13        causes problems.
     14
     15        This patch removes the shortcut so that MainResourceLoader::loadNow() is used regardless of
     16        the deferred loading. The method MainResourceLoader::loadNow() handle the substituteData as if the loading
     17        was not deferred.
     18
     19        Test: http/tests/appcache/load-from-appcache-defer-resume-crash.html
     20
     21        * loader/MainResourceLoader.cpp:
     22        (WebCore::MainResourceLoader::continueAfterNavigationPolicy):
     23        (WebCore::MainResourceLoader::handleSubstituteDataLoadSoon):
     24        Rename the method to be consistent with the attribute it uses, making the naming more explicit.
     25        (WebCore::MainResourceLoader::loadNow):
     26        (WebCore::MainResourceLoader::setDefersLoading):
     27        * loader/MainResourceLoader.h:
     28        (MainResourceLoader):
     29
    1302012-05-27  David Kilzer  <ddkilzer@apple.com>
    231
  • trunk/Source/WebCore/loader/MainResourceLoader.cpp

    r118402 r118631  
    168168        ASSERT(documentLoader()->timing()->redirectCount());
    169169        handle()->cancel();
    170         handleDataLoadSoon(request);
     170        handleSubstituteDataLoadSoon(request);
    171171    }
    172172
     
    607607}
    608608
    609 void MainResourceLoader::handleDataLoadSoon(const ResourceRequest& r)
     609void MainResourceLoader::handleSubstituteDataLoadSoon(const ResourceRequest& r)
    610610{
    611611    m_initialRequest = r;
     
    643643    resourceLoadScheduler()->addMainResourceLoad(this);
    644644    if (m_substituteData.isValid())
    645         handleDataLoadSoon(r);
     645        handleSubstituteDataLoadSoon(r);
    646646    else if (shouldLoadEmpty || frameLoader()->client()->representationExistsForURLScheme(url.protocol()))
    647647        handleEmptyLoad(url, !shouldLoadEmpty);
     
    697697            return;
    698698
    699         if (m_substituteData.isValid() && m_documentLoader->deferMainResourceDataLoad())
    700             startDataLoadTimer();
    701         else {
    702             ResourceRequest r(m_initialRequest);
    703             m_initialRequest = ResourceRequest();
    704             loadNow(r);
    705         }
    706     }
    707 }
    708 
    709 }
     699        ResourceRequest initialRequest(m_initialRequest);
     700        m_initialRequest = ResourceRequest();
     701        loadNow(initialRequest);
     702    }
     703}
     704
     705}
  • trunk/Source/WebCore/loader/MainResourceLoader.h

    r117181 r118631  
    8585
    8686        void handleEmptyLoad(const KURL&, bool forURLScheme);
    87         void handleDataLoadSoon(const ResourceRequest& r);
     87        void handleSubstituteDataLoadSoon(const ResourceRequest&);
    8888
    8989        void startDataLoadTimer();
  • trunk/Tools/ChangeLog

    r118628 r118631  
     12012-05-27  Benjamin Poulain  <bpoulain@apple.com>
     2
     3        When pages are loaded from AppCache with DeferredLoading, willSendRequest() is never called
     4        https://bugs.webkit.org/show_bug.cgi?id=87582
     5
     6        Reviewed by Darin Adler.
     7
     8        Extend DumpRenderTree to support loading the main resource deferred with a delay. This makes it
     9        possible to test pages in a similar way as they are loaded in Browsers.
     10
     11        * DumpRenderTree/LayoutTestController.cpp:
     12        (LayoutTestController::LayoutTestController):
     13        (setUseDeferredFrameLoadingCallback):
     14        (LayoutTestController::staticFunctions):
     15        * DumpRenderTree/LayoutTestController.h:
     16        (LayoutTestController::useDeferredFrameLoading):
     17        (LayoutTestController::setUseDeferredFrameLoading):
     18        (LayoutTestController):
     19        * DumpRenderTree/mac/FrameLoadDelegate.mm:
     20        (-[FrameLoadDelegate webView:didStartProvisionalLoadForFrame:]):
     21
    1222012-05-27  David Barton  <dbarton@mathscribe.com>
    223
  • trunk/Tools/DumpRenderTree/LayoutTestController.cpp

    r118331 r118631  
    9090    , m_isPrinting(false)
    9191    , m_deferMainResourceDataLoad(true)
     92    , m_useDeferredFrameLoading(false)
    9293    , m_shouldPaintBrokenImage(true)
    9394    , m_shouldStayOnPageAfterHandlingBeforeUnload(false)
     
    12281229    LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
    12291230    controller->setDefersLoading(JSValueToBoolean(context, arguments[0]));
     1231
     1232    return JSValueMakeUndefined(context);
     1233}
     1234
     1235static JSValueRef setUseDeferredFrameLoadingCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
     1236{
     1237    if (argumentCount < 1)
     1238        return JSValueMakeUndefined(context);
     1239
     1240    LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
     1241    controller->setUseDeferredFrameLoading(JSValueToBoolean(context, arguments[0]));
    12301242
    12311243    return JSValueMakeUndefined(context);
     
    23732385        { "setDeferMainResourceDataLoad", setDeferMainResourceDataLoadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
    23742386        { "setDefersLoading", setDefersLoadingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     2387        { "setUseDeferredFrameLoading", setUseDeferredFrameLoadingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
    23752388        { "setDomainRelaxationForbiddenForURLScheme", setDomainRelaxationForbiddenForURLSchemeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
    23762389        { "setFrameFlatteningEnabled", setFrameFlatteningEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
  • trunk/Tools/DumpRenderTree/LayoutTestController.h

    r118331 r118631  
    283283    void setDeferMainResourceDataLoad(bool flag) { m_deferMainResourceDataLoad = flag; }
    284284
     285    bool useDeferredFrameLoading() const { return m_useDeferredFrameLoading; }
     286    void setUseDeferredFrameLoading(bool flag) { m_useDeferredFrameLoading = flag; }
     287
    285288    const std::string& testPathOrURL() const { return m_testPathOrURL; }
    286289    const std::string& expectedPixelHash() const { return m_expectedPixelHash; }
     
    413416    bool m_isPrinting;
    414417    bool m_deferMainResourceDataLoad;
     418    bool m_useDeferredFrameLoading;
    415419    bool m_shouldPaintBrokenImage;
    416420    bool m_shouldStayOnPageAfterHandlingBeforeUnload;
  • trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm

    r118018 r118631  
    526526   
    527527    [webView setContinuousSpellCheckingEnabled:YES];
     528    [webView setDefersCallbacks:NO];
    528529    [webView setGrammarCheckingEnabled:YES];
    529530    [webView setInteractiveFormValidationEnabled:YES];
  • trunk/Tools/DumpRenderTree/mac/FrameLoadDelegate.mm

    r110032 r118631  
    174174        [frame stopLoading];
    175175    }
     176
     177    if (!done && gLayoutTestController->useDeferredFrameLoading()) {
     178        [sender setDefersCallbacks:YES];
     179        NSTimeInterval deferredWaitTime = 5 * NSEC_PER_MSEC;
     180        dispatch_time_t when = dispatch_time(DISPATCH_TIME_NOW, deferredWaitTime);
     181        dispatch_after(when, dispatch_get_main_queue(), ^{
     182            [sender setDefersCallbacks:NO];
     183        });
     184    }
    176185}
    177186
Note: See TracChangeset for help on using the changeset viewer.