Changeset 181728 in webkit


Ignore:
Timestamp:
Mar 18, 2015 10:21:40 PM (9 years ago)
Author:
Antti Koivisto
Message:

Test disk cache behavior when using back navigation cache policy
https://bugs.webkit.org/show_bug.cgi?id=142848

Reviewed by Chris Dumez.

Source/WebCore:

Add a way to override the normal cache policy so we can test reload behavior of cache without actually reloading.

Test: http/tests/cache/disk-cache-validation-back-navigation-policy.html

  • loader/FrameLoader.cpp:

(WebCore::FrameLoader::addExtraFieldsToRequest):

  • loader/FrameLoader.h:

(WebCore::FrameLoader::setOverrideCachePolicyForTesting):

  • testing/Internals.cpp:

(WebCore::Internals::setOverrideCachePolicy):

  • testing/Internals.h:
  • testing/Internals.idl:

LayoutTests:

  • http/tests/cache/disk-cache-validation-back-navigation-policy-expected.txt: Added.
  • http/tests/cache/disk-cache-validation-back-navigation-policy.html: Added.

Test permutations of cache headers on reload including Cache-control: must-revalidate.

  • platform/mac-wk1/TestExpectations:
  • platform/win/TestExpectations:
Location:
trunk
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r181724 r181728  
     12015-03-18  Antti Koivisto  <antti@apple.com>
     2
     3        Test disk cache behavior when using back navigation cache policy
     4        https://bugs.webkit.org/show_bug.cgi?id=142848
     5
     6        Reviewed by Chris Dumez.
     7
     8        * http/tests/cache/disk-cache-validation-back-navigation-policy-expected.txt: Added.
     9        * http/tests/cache/disk-cache-validation-back-navigation-policy.html: Added.
     10
     11            Test permutations of cache headers on reload including Cache-control: must-revalidate.
     12
     13        * platform/mac-wk1/TestExpectations:
     14        * platform/win/TestExpectations:
     15
    1162015-03-18  Joseph Pecoraro  <pecoraro@apple.com>
    217
  • trunk/LayoutTests/http/tests/cache/disk-cache-validation.html

    r177294 r181728  
    4040debug("");
    4141
    42 runTests(generateTests(testMatrix));
     42runTests(tests);
    4343
    4444</script>
  • trunk/LayoutTests/platform/mac-wk1/TestExpectations

    r181651 r181728  
    9494# Disk cache is WK2 only
    9595http/tests/cache/disk-cache-validation.html
     96http/tests/cache/disk-cache-validation-back-navigation-policy.html
    9697http/tests/cache/disk-cache-disable.html
    9798http/tests/cache/disk-cache-vary-cookie.html
  • trunk/LayoutTests/platform/win/TestExpectations

    r181680 r181728  
    22312231# Disk cache is WK2 only
    22322232http/tests/cache/disk-cache-validation.html
     2233http/tests/cache/disk-cache-validation-back-navigation-policy.html
    22332234http/tests/cache/disk-cache-disable.html
    22342235http/tests/cache/disk-cache-vary-cookie.html
  • trunk/Source/WebCore/ChangeLog

    r181727 r181728  
     12015-03-18  Antti Koivisto  <antti@apple.com>
     2
     3        Test disk cache behavior when using back navigation cache policy
     4        https://bugs.webkit.org/show_bug.cgi?id=142848
     5
     6        Reviewed by Chris Dumez.
     7
     8        Add a way to override the normal cache policy so we can test reload behavior of cache without actually reloading.
     9
     10        Test: http/tests/cache/disk-cache-validation-back-navigation-policy.html
     11
     12        * loader/FrameLoader.cpp:
     13        (WebCore::FrameLoader::addExtraFieldsToRequest):
     14        * loader/FrameLoader.h:
     15        (WebCore::FrameLoader::setOverrideCachePolicyForTesting):
     16        * testing/Internals.cpp:
     17        (WebCore::Internals::setOverrideCachePolicy):
     18        * testing/Internals.h:
     19        * testing/Internals.idl:
     20
    1212015-03-18  Yusuke Suzuki  <utatane.tea@gmail.com>
    222
  • trunk/Source/WebCore/loader/FrameLoader.cpp

    r181649 r181728  
    25592559        request.setCachePolicy(ReloadIgnoringCacheData);
    25602560
     2561    if (m_overrideCachePolicyForTesting)
     2562        request.setCachePolicy(m_overrideCachePolicyForTesting.value());
     2563
    25612564    if (request.cachePolicy() == ReloadIgnoringCacheData) {
    25622565        if (loadType == FrameLoadType::Reload)
  • trunk/Source/WebCore/loader/FrameLoader.h

    r180301 r181728  
    4242#include "ResourceHandleTypes.h"
    4343#include "ResourceLoadNotifier.h"
     44#include "ResourceRequestBase.h"
    4445#include "SecurityContext.h"
    4546#include "Timer.h"
    4647#include <wtf/Forward.h>
    4748#include <wtf/HashSet.h>
     49#include <wtf/Optional.h>
    4850
    4951namespace WebCore {
     
    288290    void forcePageTransitionIfNeeded();
    289291
     292    void setOverrideCachePolicyForTesting(ResourceRequestCachePolicy policy) { m_overrideCachePolicyForTesting = policy; }
     293    void clearOverrideCachePolicyForTesting() { m_overrideCachePolicyForTesting = Nullopt; }
     294
    290295private:
    291296    enum FormSubmissionCacheLoadPolicy {
     
    436441
    437442    RefPtr<FrameNetworkingContext> m_networkingContext;
     443
     444    Optional<ResourceRequestCachePolicy> m_overrideCachePolicyForTesting;
    438445
    439446    URL m_previousURL;
  • trunk/Source/WebCore/testing/Internals.cpp

    r181615 r181728  
    309309    if (page->mainFrame().editor().isOverwriteModeEnabled())
    310310        page->mainFrame().editor().toggleOverwriteModeEnabled();
     311    page->mainFrame().loader().clearOverrideCachePolicyForTesting();
    311312    ApplicationCacheStorage::singleton().setDefaultOriginQuota(ApplicationCacheStorage::noQuota());
    312313#if ENABLE(VIDEO)
     
    424425    ASSERT_NOT_REACHED();
    425426    return "Error";
     427}
     428
     429static ResourceRequestCachePolicy stringToResourceRequestCachePolicy(const String& policy)
     430{
     431    if (policy == "UseProtocolCachePolicy")
     432        return UseProtocolCachePolicy;
     433    if (policy == "ReloadIgnoringCacheData")
     434        return ReloadIgnoringCacheData;
     435    if (policy == "ReturnCacheDataElseLoad")
     436        return ReturnCacheDataElseLoad;
     437    if (policy == "ReturnCacheDataDontLoad")
     438        return ReturnCacheDataDontLoad;
     439    ASSERT_NOT_REACHED();
     440    return UseProtocolCachePolicy;
     441}
     442
     443void Internals::setOverrideCachePolicy(const String& policy)
     444{
     445    frame()->loader().setOverrideCachePolicyForTesting(stringToResourceRequestCachePolicy(policy));
    426446}
    427447
  • trunk/Source/WebCore/testing/Internals.h

    r181408 r181728  
    9090    bool isLoadingFromMemoryCache(const String& url);
    9191    String xhrResponseSource(XMLHttpRequest*);
     92    void setOverrideCachePolicy(const String&);
    9293
    9394    void clearMemoryCache();
  • trunk/Source/WebCore/testing/Internals.idl

    r181408 r181728  
    3030};
    3131
     32// These map to ResourceRequestCachePolicy.
     33enum CachePolicy {
     34    "UseProtocolCachePolicy",
     35    "ReloadIgnoringCacheData",
     36    "ReturnCacheDataElseLoad",
     37    "ReturnCacheDataDontLoad"
     38};
     39
     40
    3241[
    3342    NoInterfaceObject,
     
    4756    void pruneMemoryCacheToSize(long size);
    4857    long memoryCacheSize();
     58    void setOverrideCachePolicy(CachePolicy policy);
    4959
    5060    void clearPageCache();
Note: See TracChangeset for help on using the changeset viewer.