forked from mirrors/gecko-dev
Backed out 2 changesets (bug 1893402) for causing mochitest failures regarding nsGlobalWindowInner. CLOSED TREE
Backed out changeset e909b94c1280 (bug 1893402) Backed out changeset beef636e1562 (bug 1893402)
This commit is contained in:
parent
51fcffb106
commit
86dcf9e3dc
12 changed files with 24 additions and 312 deletions
|
|
@ -66,23 +66,9 @@ class imgCacheEntry {
|
|||
void UpdateLoadTime();
|
||||
|
||||
uint32_t GetExpiryTime() const { return mExpiryTime; }
|
||||
void AccumulateExpiryTime(uint32_t aExpiryTime, bool aForceTouch = false) {
|
||||
// 0 means "doesn't expire".
|
||||
// Otherwise, calculate the minimum value.
|
||||
if (aExpiryTime == 0) {
|
||||
if (aForceTouch) {
|
||||
Touch();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (mExpiryTime == 0 || aExpiryTime < mExpiryTime) {
|
||||
mExpiryTime = aExpiryTime;
|
||||
Touch();
|
||||
} else {
|
||||
if (aForceTouch) {
|
||||
Touch();
|
||||
}
|
||||
}
|
||||
void SetExpiryTime(uint32_t aExpiryTime) {
|
||||
mExpiryTime = aExpiryTime;
|
||||
Touch();
|
||||
}
|
||||
|
||||
bool GetMustValidate() const { return mMustValidate; }
|
||||
|
|
|
|||
|
|
@ -579,9 +579,9 @@ void imgRequest::UpdateCacheEntrySize() {
|
|||
}
|
||||
|
||||
void imgRequest::SetCacheValidation(imgCacheEntry* aCacheEntry,
|
||||
nsIRequest* aRequest,
|
||||
bool aForceTouch /* = false */) {
|
||||
if (!aCacheEntry) {
|
||||
nsIRequest* aRequest) {
|
||||
/* get the expires info */
|
||||
if (!aCacheEntry || aCacheEntry->GetExpiryTime() != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -605,7 +605,7 @@ void imgRequest::SetCacheValidation(imgCacheEntry* aCacheEntry,
|
|||
info.mExpirationTime.emplace(nsContentUtils::SecondsFromPRTime(PR_Now()) -
|
||||
1);
|
||||
}
|
||||
aCacheEntry->AccumulateExpiryTime(*info.mExpirationTime, aForceTouch);
|
||||
aCacheEntry->SetExpiryTime(*info.mExpirationTime);
|
||||
// Cache entries default to not needing to validate. We ensure that
|
||||
// multiple calls to this function don't override an earlier decision to
|
||||
// validate by making validation a one-way decision.
|
||||
|
|
@ -690,7 +690,7 @@ imgRequest::OnStartRequest(nsIRequest* aRequest) {
|
|||
}
|
||||
}
|
||||
|
||||
SetCacheValidation(mCacheEntry, aRequest, /* aForceTouch = */ true);
|
||||
SetCacheValidation(mCacheEntry, aRequest);
|
||||
|
||||
// Shouldn't we be dead already if this gets hit?
|
||||
// Probably multipart/x-mixed-replace...
|
||||
|
|
|
|||
|
|
@ -99,9 +99,9 @@ class imgRequest final : public nsIThreadRetargetableStreamListener,
|
|||
|
||||
// Set the cache validation information (expiry time, whether we must
|
||||
// validate, etc) on the cache entry based on the request information.
|
||||
// If this function is called multiple times, the most strict value wins.
|
||||
static void SetCacheValidation(imgCacheEntry* aEntry, nsIRequest* aRequest,
|
||||
bool aForceTouch = false);
|
||||
// If this function is called multiple times, the information set earliest
|
||||
// wins.
|
||||
static void SetCacheValidation(imgCacheEntry* aEntry, nsIRequest* aRequest);
|
||||
|
||||
bool GetMultipart() const;
|
||||
|
||||
|
|
|
|||
|
|
@ -1260,15 +1260,6 @@ nsresult Loader::LoadSheetSyncInternal(SheetLoadData& aLoadData,
|
|||
nsCOMPtr<nsILoadInfo> loadInfo = channel->LoadInfo();
|
||||
loadInfo->SetCspNonce(aLoadData.Nonce());
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
nsCOMPtr<nsIInterfaceRequestor> prevCallback;
|
||||
channel->GetNotificationCallbacks(getter_AddRefs(prevCallback));
|
||||
MOZ_ASSERT(!prevCallback);
|
||||
}
|
||||
#endif
|
||||
channel->SetNotificationCallbacks(streamLoader);
|
||||
|
||||
nsCOMPtr<nsIInputStream> stream;
|
||||
rv = channel->Open(getter_AddRefs(stream));
|
||||
|
||||
|
|
@ -1601,15 +1592,6 @@ nsresult Loader::LoadSheetAsyncInternal(SheetLoadData& aLoadData,
|
|||
nsINetworkPredictor::LEARN_LOAD_SUBRESOURCE, mDocument);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
nsCOMPtr<nsIInterfaceRequestor> prevCallback;
|
||||
channel->GetNotificationCallbacks(getter_AddRefs(prevCallback));
|
||||
MOZ_ASSERT(!prevCallback);
|
||||
}
|
||||
#endif
|
||||
channel->SetNotificationCallbacks(streamLoader);
|
||||
|
||||
if (aEarlyHintPreloaderId) {
|
||||
nsCOMPtr<nsIHttpChannelInternal> channelInternal =
|
||||
do_QueryInterface(channel);
|
||||
|
|
|
|||
|
|
@ -277,17 +277,6 @@ class SheetLoadData final
|
|||
|
||||
void Cancel() override { mIsCancelled = true; }
|
||||
|
||||
void AccumulateExpirationTime(uint32_t aExpirationTime) {
|
||||
// 0 means "doesn't expire".
|
||||
// Otherwise, calculate the minimum value.
|
||||
if (aExpirationTime == 0) {
|
||||
return;
|
||||
}
|
||||
if (mExpirationTime == 0 || aExpirationTime < mExpirationTime) {
|
||||
mExpirationTime = aExpirationTime;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
const SheetLoadData& RootLoadData() const {
|
||||
const auto* top = this;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@
|
|||
#include "mozilla/glean/GleanMetrics.h"
|
||||
#include "mozilla/TaskQueue.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIAsyncVerifyRedirectCallback.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIThreadRetargetableRequest.h"
|
||||
|
|
@ -35,19 +34,7 @@ StreamLoader::~StreamLoader() {
|
|||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(StreamLoader, nsIStreamListener,
|
||||
nsIThreadRetargetableStreamListener, nsIChannelEventSink,
|
||||
nsIInterfaceRequestor)
|
||||
|
||||
static uint32_t CalculateExpirationTime(nsIRequest* aRequest, nsIURI* aURI) {
|
||||
auto info = nsContentUtils::GetSubresourceCacheValidationInfo(aRequest, aURI);
|
||||
|
||||
// For now, we never cache entries that we have to revalidate, or whose
|
||||
// channel don't support caching.
|
||||
if (info.mMustRevalidate || !info.mExpirationTime) {
|
||||
return nsContentUtils::SecondsFromPRTime(PR_Now()) - 1;
|
||||
}
|
||||
return *info.mExpirationTime;
|
||||
}
|
||||
nsIThreadRetargetableStreamListener)
|
||||
|
||||
/* nsIRequestObserver implementation */
|
||||
NS_IMETHODIMP
|
||||
|
|
@ -87,8 +74,17 @@ StreamLoader::OnStartRequest(nsIRequest* aRequest) {
|
|||
rr->RetargetDeliveryTo(queue);
|
||||
}
|
||||
|
||||
mSheetLoadData->AccumulateExpirationTime(
|
||||
CalculateExpirationTime(aRequest, mSheetLoadData->mURI));
|
||||
mSheetLoadData->mExpirationTime = [&] {
|
||||
auto info = nsContentUtils::GetSubresourceCacheValidationInfo(
|
||||
aRequest, mSheetLoadData->mURI);
|
||||
|
||||
// For now, we never cache entries that we have to revalidate, or whose
|
||||
// channel don't support caching.
|
||||
if (info.mMustRevalidate || !info.mExpirationTime) {
|
||||
return nsContentUtils::SecondsFromPRTime(PR_Now()) - 1;
|
||||
}
|
||||
return *info.mExpirationTime;
|
||||
}();
|
||||
|
||||
// We need to block block resolution of parse promise until we receive
|
||||
// OnStopRequest on Main thread. This is necessary because parse promise
|
||||
|
|
@ -252,26 +248,6 @@ StreamLoader::OnDataFinished(nsresult aResult) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
StreamLoader::GetInterface(const nsIID& aIID, void** aResult) {
|
||||
if (aIID.Equals(NS_GET_IID(nsIChannelEventSink))) {
|
||||
return QueryInterface(aIID, aResult);
|
||||
}
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
nsresult StreamLoader::AsyncOnChannelRedirect(
|
||||
nsIChannel* aOld, nsIChannel* aNew, uint32_t aFlags,
|
||||
nsIAsyncVerifyRedirectCallback* aCallback) {
|
||||
mSheetLoadData->AccumulateExpirationTime(
|
||||
CalculateExpirationTime(aOld, mSheetLoadData->mURI));
|
||||
|
||||
aCallback->OnRedirectVerifyCallback(NS_OK);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult StreamLoader::WriteSegmentFun(nsIInputStream*, void* aClosure,
|
||||
const char* aSegment, uint32_t,
|
||||
uint32_t aCount, uint32_t* aWriteCount) {
|
||||
|
|
|
|||
|
|
@ -9,8 +9,6 @@
|
|||
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIThreadRetargetableStreamListener.h"
|
||||
#include "nsIChannelEventSink.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsString.h"
|
||||
#include "mozilla/css/SheetLoadData.h"
|
||||
|
|
@ -20,15 +18,11 @@ class nsIInputStream;
|
|||
|
||||
namespace mozilla::css {
|
||||
|
||||
class StreamLoader : public nsIThreadRetargetableStreamListener,
|
||||
public nsIChannelEventSink,
|
||||
public nsIInterfaceRequestor {
|
||||
class StreamLoader : public nsIThreadRetargetableStreamListener {
|
||||
public:
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_DECL_NSIREQUESTOBSERVER
|
||||
NS_DECL_NSISTREAMLISTENER
|
||||
NS_DECL_NSICHANNELEVENTSINK
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER
|
||||
|
||||
explicit StreamLoader(SheetLoadData&);
|
||||
|
|
|
|||
|
|
@ -1,20 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Load redirecting CSS</title>
|
||||
</head>
|
||||
<body>
|
||||
hello
|
||||
<script>
|
||||
var us = window.location.href;
|
||||
var baseURL = us.substring(0, us.lastIndexOf('/') + 1);
|
||||
var serverFilename = "file_resource_cache_server.sjs";
|
||||
|
||||
const s = document.createElement("link");
|
||||
s.setAttribute("rel", "stylesheet");
|
||||
s.setAttribute("type", "text/css");
|
||||
s.href = baseURL + serverFilename + "?redirect-cache";
|
||||
document.head.append(s);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Load redirecting CSS</title>
|
||||
</head>
|
||||
<body>
|
||||
hello
|
||||
<script>
|
||||
var us = window.location.href;
|
||||
var baseURL = us.substring(0, us.lastIndexOf('/') + 1);
|
||||
var serverFilename = "file_resource_cache_server.sjs";
|
||||
|
||||
const s = document.createElement("link");
|
||||
s.setAttribute("rel", "stylesheet");
|
||||
s.setAttribute("type", "text/css");
|
||||
s.href = baseURL + serverFilename + "?redirect-nocache";
|
||||
document.head.append(s);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
function handleRequest(request, response) {
|
||||
if (request.queryString == "reset") {
|
||||
// Reset the internal state.
|
||||
setState("redirected", "");
|
||||
|
||||
response.setStatusLine(request.httpVersion, 200, "OK");
|
||||
response.setHeader("Content-Type", "text/plain", false);
|
||||
const body = "reset";
|
||||
response.bodyOutputStream.write(body, body.length);
|
||||
} else if (
|
||||
request.queryString == "redirect-cache" ||
|
||||
request.queryString == "redirect-nocache"
|
||||
) {
|
||||
// Redirect to different CSS between the first and the second requests.
|
||||
|
||||
response.setStatusLine(request.httpVersion, 301, "Moved Permanently");
|
||||
if (getState("redirected")) {
|
||||
response.setHeader(
|
||||
"Location",
|
||||
"file_resource_cache_server.sjs?blue",
|
||||
false
|
||||
);
|
||||
} else {
|
||||
response.setHeader(
|
||||
"Location",
|
||||
"file_resource_cache_server.sjs?red",
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
if (request.queryString == "redirect-nocache") {
|
||||
response.setHeader("Cache-Control", "no-cache", false);
|
||||
} else {
|
||||
response.setHeader("Cache-Control", "max-age=10000", false);
|
||||
}
|
||||
|
||||
setState("redirected", "1");
|
||||
} else if (request.queryString == "blue") {
|
||||
response.setStatusLine(request.httpVersion, 200, "OK");
|
||||
response.setHeader("Cache-Control", "max-age=10000", false);
|
||||
response.setHeader("Content-Type", "text/css", false);
|
||||
const body = `body { color: blue; }`;
|
||||
response.bodyOutputStream.write(body, body.length);
|
||||
} else {
|
||||
response.setStatusLine(request.httpVersion, 200, "OK");
|
||||
response.setHeader("Cache-Control", "max-age=10000", false);
|
||||
response.setHeader("Content-Type", "text/css", false);
|
||||
const body = `body { color: red; }`;
|
||||
response.bodyOutputStream.write(body, body.length);
|
||||
}
|
||||
}
|
||||
|
|
@ -29,9 +29,6 @@ support-files = [
|
|||
"empty.html",
|
||||
"file_computed_style_bfcache_display_none.html",
|
||||
"file_computed_style_bfcache_display_none2.html",
|
||||
"file_resource_cache_server.sjs",
|
||||
"file_resource_cache_frame_not_cacheable.html",
|
||||
"file_resource_cache_frame_cacheable.html",
|
||||
"media_queries_iframe.html",
|
||||
"media_queries_iframe2.html",
|
||||
"neverending_font_load.sjs",
|
||||
|
|
@ -617,8 +614,6 @@ support-files = ["redundant_font_download.sjs"]
|
|||
|
||||
["test_rem_unit.html"]
|
||||
|
||||
["test_resource_cache.html"]
|
||||
|
||||
["test_restyle_table_wrapper.html"]
|
||||
|
||||
["test_restyles_in_smil_animation.html"]
|
||||
|
|
|
|||
|
|
@ -1,119 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for SharedSubResourceCache with redirect</title>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<iframe id="frame" src="about:blank"></iframe>
|
||||
|
||||
<script>
|
||||
const us = window.location.href;
|
||||
const baseURL = us.substring(0, us.lastIndexOf('/') + 1);
|
||||
const serverFilename = "file_resource_cache_server.sjs";
|
||||
const frame = document.getElementById("frame");
|
||||
|
||||
gWindowUtils = SpecialPowers.getDOMWindowUtils(window);
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
async function testReload({ src, clearCache, cacheable, desc }) {
|
||||
// The iframe loads CSS with "file_resource_cache_server.sjs?redirect" URL.
|
||||
// With the first access, it redirects to "file_resource_cache_server.sjs?red"
|
||||
// that makes the body color "red".
|
||||
//
|
||||
// The redirect response has "Cache-Control: no-cache", and the request
|
||||
// shouldn't be cached.
|
||||
await new Promise(r => {
|
||||
frame.addEventListener("load", r, { once: true });
|
||||
frame.src = src;
|
||||
});
|
||||
|
||||
is(frame.contentWindow.getComputedStyle(frame.contentDocument.body).color,
|
||||
"rgb(255, 0, 0)",
|
||||
`body color before reload with ${desc} should be red`);
|
||||
|
||||
if (clearCache) {
|
||||
gWindowUtils.clearSharedStyleSheetCache();
|
||||
}
|
||||
|
||||
// Reload the iframe and wait for reload.
|
||||
//
|
||||
// With the second access, "file_resource_cache_server.sjs?redirect" redirects
|
||||
// to "file_resource_cache_server.sjs?blue" that makes the body color "blue".
|
||||
await new Promise(r => {
|
||||
frame.addEventListener("load", r, { once: true });
|
||||
frame.contentWindow.location.reload();
|
||||
});
|
||||
|
||||
if (cacheable) {
|
||||
is(frame.contentWindow.getComputedStyle(frame.contentDocument.body).color,
|
||||
"rgb(255, 0, 0)",
|
||||
`body color after reload with ${desc} should be red`);
|
||||
} else {
|
||||
is(frame.contentWindow.getComputedStyle(frame.contentDocument.body).color,
|
||||
"rgb(0, 0, 255)",
|
||||
`body color after reload with ${desc} should be blue`);
|
||||
}
|
||||
}
|
||||
|
||||
async function reset() {
|
||||
// Reset the server-side script state.
|
||||
const resetResponse = await fetch(baseURL + serverFilename + "?reset");
|
||||
is(await resetResponse.text(), "reset", "server side is reset");
|
||||
|
||||
// Reset the iframe.
|
||||
await new Promise(r => {
|
||||
frame.addEventListener("load", r, { once: true });
|
||||
frame.src = "about:blank";
|
||||
});
|
||||
|
||||
// Clear cache.
|
||||
gWindowUtils.clearSharedStyleSheetCache();
|
||||
}
|
||||
|
||||
async function doTest() {
|
||||
await new Promise(r => window.addEventListener("load", r, { once: true }));
|
||||
|
||||
await testReload({
|
||||
src: "file_resource_cache_frame_not_cacheable.html",
|
||||
clearCache: true,
|
||||
cacheable: false,
|
||||
desc: "clearing SharedSubResourceCache for not-cacheable",
|
||||
});
|
||||
|
||||
await reset();
|
||||
|
||||
await testReload({
|
||||
src: "file_resource_cache_frame_not_cacheable.html",
|
||||
clearCache: false,
|
||||
cacheable: false,
|
||||
desc: "not clearing SharedSubResourceCache for not-cacheable",
|
||||
});
|
||||
|
||||
await reset();
|
||||
|
||||
await testReload({
|
||||
src: "file_resource_cache_frame_cacheable.html",
|
||||
clearCache: true,
|
||||
cacheable: true,
|
||||
desc: "clearing SharedSubResourceCache for cacheable",
|
||||
});
|
||||
|
||||
await reset();
|
||||
|
||||
await testReload({
|
||||
src: "file_resource_cache_frame_cacheable.html",
|
||||
clearCache: false,
|
||||
cacheable: true,
|
||||
desc: "not clearing SharedSubResourceCache for cacheable",
|
||||
});
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
doTest();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in a new issue