Bug 1729477 - Tweak SubresourceCacheValidationInfo to account for chrome uris. r=tnikkel

Turns out my patch above causes some failures because chrome:// channels
don't have cache information, so we conservatively assume they always
expire, which causes some interesting timing issues in a single test.
Fun stuff.

Tweak the code so that SubresourceCacheValidationInfo has the
pre-existing data:// URI special-case and also special-cases chrome://
URIs.

Differential Revision: https://phabricator.services.mozilla.com/D124921
This commit is contained in:
Emilio Cobos Álvarez
2021-09-09 09:32:11 +00:00
parent e166068115
commit 5217ea7f29
6 changed files with 34 additions and 22 deletions

View File

@@ -10494,7 +10494,8 @@ ScreenIntMargin nsContentUtils::GetWindowSafeAreaInsets(
/* static */
nsContentUtils::SubresourceCacheValidationInfo
nsContentUtils::GetSubresourceCacheValidationInfo(nsIRequest* aRequest) {
nsContentUtils::GetSubresourceCacheValidationInfo(nsIRequest* aRequest,
nsIURI* aURI) {
SubresourceCacheValidationInfo info;
if (nsCOMPtr<nsICacheInfoChannel> cache = do_QueryInterface(aRequest)) {
uint32_t value = 0;
@@ -10513,6 +10514,18 @@ nsContentUtils::GetSubresourceCacheValidationInfo(nsIRequest* aRequest) {
}
}
// data: URIs are safe to cache across documents under any circumstance, so we
// special-case them here even though the channel itself doesn't have any
// caching policy. Same for chrome:// uris.
//
// TODO(emilio): Figure out which other schemes that don't have caching
// policies are safe to cache. Blobs should be...
if (aURI && (aURI->SchemeIs("data") || dom::IsChromeURI(aURI))) {
MOZ_ASSERT(!info.mExpirationTime);
MOZ_ASSERT(!info.mMustRevalidate);
info.mExpirationTime = Some(0); // 0 means "doesn't expire".
}
return info;
}