Bug 1440775 Make fetch API force-cache and only-if-cached use VALIDATE_NEVER instead of LOAD_FROM_CACHE. r=mayhemer

This commit is contained in:
Ben Kelly 2018-03-01 07:37:31 -08:00
parent 03c8a9b27c
commit 6a92d27239

View File

@ -2855,10 +2855,10 @@ HttpBaseChannel::GetFetchCacheMode(uint32_t* aFetchCacheMode)
*aFetchCacheMode = nsIHttpChannelInternal::FETCH_CACHE_MODE_RELOAD; *aFetchCacheMode = nsIHttpChannelInternal::FETCH_CACHE_MODE_RELOAD;
} else if (ContainsAllFlags(mLoadFlags, VALIDATE_ALWAYS)) { } else if (ContainsAllFlags(mLoadFlags, VALIDATE_ALWAYS)) {
*aFetchCacheMode = nsIHttpChannelInternal::FETCH_CACHE_MODE_NO_CACHE; *aFetchCacheMode = nsIHttpChannelInternal::FETCH_CACHE_MODE_NO_CACHE;
} else if (ContainsAllFlags(mLoadFlags, LOAD_FROM_CACHE | } else if (ContainsAllFlags(mLoadFlags, VALIDATE_NEVER |
nsICachingChannel::LOAD_ONLY_FROM_CACHE)) { nsICachingChannel::LOAD_ONLY_FROM_CACHE)) {
*aFetchCacheMode = nsIHttpChannelInternal::FETCH_CACHE_MODE_ONLY_IF_CACHED; *aFetchCacheMode = nsIHttpChannelInternal::FETCH_CACHE_MODE_ONLY_IF_CACHED;
} else if (ContainsAllFlags(mLoadFlags, LOAD_FROM_CACHE)) { } else if (ContainsAllFlags(mLoadFlags, VALIDATE_NEVER)) {
*aFetchCacheMode = nsIHttpChannelInternal::FETCH_CACHE_MODE_FORCE_CACHE; *aFetchCacheMode = nsIHttpChannelInternal::FETCH_CACHE_MODE_FORCE_CACHE;
} else { } else {
*aFetchCacheMode = nsIHttpChannelInternal::FETCH_CACHE_MODE_DEFAULT; *aFetchCacheMode = nsIHttpChannelInternal::FETCH_CACHE_MODE_DEFAULT;
@ -2915,7 +2915,7 @@ HttpBaseChannel::SetFetchCacheMode(uint32_t aFetchCacheMode)
break; break;
case nsIHttpChannelInternal::FETCH_CACHE_MODE_FORCE_CACHE: case nsIHttpChannelInternal::FETCH_CACHE_MODE_FORCE_CACHE:
// force-cache means don't validate unless if the response would vary. // force-cache means don't validate unless if the response would vary.
SetCacheFlags(mLoadFlags, LOAD_FROM_CACHE); SetCacheFlags(mLoadFlags, VALIDATE_NEVER);
break; break;
case nsIHttpChannelInternal::FETCH_CACHE_MODE_ONLY_IF_CACHED: case nsIHttpChannelInternal::FETCH_CACHE_MODE_ONLY_IF_CACHED:
// only-if-cached means only from cache, no network, no validation, generate // only-if-cached means only from cache, no network, no validation, generate
@ -2924,7 +2924,7 @@ HttpBaseChannel::SetFetchCacheMode(uint32_t aFetchCacheMode)
// the user has things in their cache without any network traffic side // the user has things in their cache without any network traffic side
// effects) are addressed in the Request constructor which enforces/requires // effects) are addressed in the Request constructor which enforces/requires
// same-origin request mode. // same-origin request mode.
SetCacheFlags(mLoadFlags, LOAD_FROM_CACHE | SetCacheFlags(mLoadFlags, VALIDATE_NEVER |
nsICachingChannel::LOAD_ONLY_FROM_CACHE); nsICachingChannel::LOAD_ONLY_FROM_CACHE);
break; break;
} }