Backed out 4 changesets (bug 1722502) for causing Hazard bustage on ServiceWorkerQuotaUtils.cpp. CLOSED TREE

Backed out changeset e629eccab130 (bug 1722502)
Backed out changeset 9d8ddf54d9c6 (bug 1722502)
Backed out changeset 2e9d71f4f128 (bug 1722502)
Backed out changeset bbe06a4f707b (bug 1722502)
This commit is contained in:
criss 2021-08-27 10:11:13 +03:00
Родитель 76d6efc88e
Коммит 2aa1094a66
12 изменённых файлов: 10 добавлений и 518 удалений

Просмотреть файл

@ -162,16 +162,6 @@ interface nsIServiceWorkerManagerListener : nsISupports
void onRegister(in nsIServiceWorkerRegistrationInfo aInfo);
void onUnregister(in nsIServiceWorkerRegistrationInfo aInfo);
/**
* Called by ServiceWorker bypass mitigations when checking whether an
* origin's quota usage is sufficiently full that we need to clear the origin
* (and possibly group's) data as part of our mitigation.
* This notification is provided primarily for testing code that needs to wait
* for this check to happen but has no other mechanism for knowing it's
* completed. Probably not relevant to devtools.
*/
void onQuotaUsageCheckFinish(in nsIServiceWorkerRegistrationInfo aInfo);
};
[scriptable, builtinclass, uuid(7404c8e8-4d47-4449-8ed1-47d1261d4e33)]

Просмотреть файл

@ -86,7 +86,6 @@
#include "ServiceWorkerUnregisterJob.h"
#include "ServiceWorkerUpdateJob.h"
#include "ServiceWorkerUtils.h"
#include "ServiceWorkerQuotaUtils.h"
#ifdef PostMessage
# undef PostMessage
@ -1700,6 +1699,7 @@ void ServiceWorkerManager::AddScopeAndRegistration(
MOZ_ASSERT(!scopeKey.IsEmpty());
auto* const data = swm->mRegistrationInfos.GetOrInsertNew(scopeKey);
data->mScopeContainer.InsertScope(aScope);
data->mInfos.InsertOrUpdate(aScope, RefPtr{aInfo});
swm->NotifyListenersOnRegister(aInfo);
@ -1799,14 +1799,6 @@ void ServiceWorkerManager::MaybeRemoveRegistrationInfo(
if (entry.Data()->mScopeContainer.IsEmpty() &&
entry.Data()->mJobQueues.Count() == 0) {
entry.Remove();
// Need to reset the mQuotaUsageCheckCount, if
// RegistrationDataPerPrincipal:: mScopeContainer is empty. This
// RegistrationDataPerPrincipal might be reused, such that quota usage
// mitigation can be triggered for the new added registration.
} else if (entry.Data()->mScopeContainer.IsEmpty() &&
entry.Data()->mQuotaUsageCheckCount) {
entry.Data()->mQuotaUsageCheckCount = 0;
}
}
}
@ -2276,46 +2268,6 @@ int32_t ServiceWorkerManager::GetPrincipalQuotaUsageCheckCount(
return data->mQuotaUsageCheckCount;
}
void ServiceWorkerManager::CheckPrincipalQuotaUsage(nsIPrincipal* aPrincipal,
const nsACString& aScope) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aPrincipal);
nsAutoCString scopeKey;
nsresult rv = PrincipalToScopeKey(aPrincipal, scopeKey);
if (NS_WARN_IF(NS_FAILED(rv))) {
return;
}
RegistrationDataPerPrincipal* data;
if (!mRegistrationInfos.Get(scopeKey, &data)) {
return;
}
// Had already schedule a quota usage check.
if (data->mQuotaUsageCheckCount != 0) {
return;
}
++data->mQuotaUsageCheckCount;
// Get the corresponding ServiceWorkerRegistrationInfo here. Unregisteration
// might be triggered later, should get it here before it be removed from
// data.mInfos, such that NotifyListenersOnQuotaCheckFinish() can notify the
// corresponding ServiceWorkerRegistrationInfo after asynchronous quota
// checking finish.
RefPtr<ServiceWorkerRegistrationInfo> info;
data->mInfos.Get(aScope, getter_AddRefs(info));
MOZ_ASSERT(info);
RefPtr<ServiceWorkerManager> self = this;
ClearQuotaUsageIfNeeded(aPrincipal, [self, info](bool aResult) {
MOZ_ASSERT(NS_IsMainThread());
self->NotifyListenersOnQuotaUsageCheckFinish(info);
});
}
void ServiceWorkerManager::SoftUpdate(const OriginAttributes& aOriginAttributes,
const nsACString& aScope) {
MOZ_ASSERT(NS_IsMainThread());
@ -2989,15 +2941,6 @@ void ServiceWorkerManager::NotifyListenersOnUnregister(
}
}
void ServiceWorkerManager::NotifyListenersOnQuotaUsageCheckFinish(
nsIServiceWorkerRegistrationInfo* aRegistration) {
nsTArray<nsCOMPtr<nsIServiceWorkerManagerListener>> listeners(
mListeners.Clone());
for (size_t index = 0; index < listeners.Length(); ++index) {
listeners[index]->OnQuotaUsageCheckFinish(aRegistration);
}
}
class UpdateTimerCallback final : public nsITimerCallback, public nsINamed {
nsCOMPtr<nsIPrincipal> mPrincipal;
const nsCString mScope;

Просмотреть файл

@ -254,9 +254,6 @@ class ServiceWorkerManager final : public nsIServiceWorkerManager,
int32_t GetPrincipalQuotaUsageCheckCount(nsIPrincipal* aPrincipal);
void CheckPrincipalQuotaUsage(nsIPrincipal* aPrincipal,
const nsACString& aScope);
// Returns the shutdown state ID (may be an invalid ID if an
// nsIAsyncShutdownBlocker is not used).
uint32_t MaybeInitServiceWorkerShutdownProgress() const;
@ -353,9 +350,6 @@ class ServiceWorkerManager final : public nsIServiceWorkerManager,
void NotifyListenersOnUnregister(
nsIServiceWorkerRegistrationInfo* aRegistration);
void NotifyListenersOnQuotaUsageCheckFinish(
nsIServiceWorkerRegistrationInfo* aRegistration);
void ScheduleUpdateTimer(nsIPrincipal* aPrincipal, const nsACString& aScope);
void UpdateTimerFired(nsIPrincipal* aPrincipal, const nsACString& aScope);

Просмотреть файл

@ -1,326 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "MainThreadUtils.h"
#include "ServiceWorkerQuotaUtils.h"
#include "mozilla/ScopeExit.h"
#include "mozilla/Services.h"
#include "mozilla/StaticPrefs_dom.h"
#include "mozilla/dom/quota/QuotaManagerService.h"
#include "nsIClearDataService.h"
#include "nsID.h"
#include "nsIPrincipal.h"
#include "nsIQuotaCallbacks.h"
#include "nsIQuotaRequests.h"
#include "nsIQuotaResults.h"
#include "nsISupports.h"
#include "nsIVariant.h"
#include "nsServiceManagerUtils.h"
using mozilla::dom::quota::QuotaManagerService;
namespace mozilla::dom {
/*
* QuotaUsageChecker implements the quota usage checking algorithm.
*
* 1. Getting the given origin/group usage through QuotaManagerService.
* QuotaUsageCheck::Start() implements this step.
* 2. Checking if the group usage headroom is satisfied.
* It could be following three situations.
* a. Group headroom is satisfied without any usage mitigation.
* b. Group headroom is satisfied after origin usage mitigation.
* This invokes nsIClearDataService::DeleteDataFromPrincipal().
* c. Group headroom is satisfied after group usage mitigation.
* This invokes nsIClearDataService::DeleteDataFromBaseDomain().
* QuotaUsageChecker::CheckQuotaHeadroom() implements this step.
*
* If the algorithm is done or error out, the QuotaUsageCheck::mCallback will
* be called with a bool result for external handling.
*/
class QuotaUsageChecker final : public nsIQuotaCallback,
public nsIQuotaUsageCallback,
public nsIClearDataCallback {
public:
NS_DECL_ISUPPORTS
// For QuotaManagerService::Estimate()
NS_DECL_NSIQUOTACALLBACK
// For QuotaManagerService::GetUsageForPrincipal()
NS_DECL_NSIQUOTAUSAGECALLBACK
// For nsIClearDataService::DeleteDataFromPrincipal() and
// nsIClearDataService::DeleteDataFromBaseDomain()
NS_DECL_NSICLEARDATACALLBACK
QuotaUsageChecker(nsIPrincipal* aPrincipal,
ServiceWorkerQuotaMitigationCallback&& aCallback);
void Start();
void RunCallback(bool aResult);
private:
~QuotaUsageChecker() = default;
// This is a general help method to get nsIQuotaResult/nsIQuotaUsageResult
// from nsIQuotaRequest/nsIQuotaUsageRequest
template <typename T, typename U>
nsresult GetResult(T* aRequest, U&);
void CheckQuotaHeadroom();
nsCOMPtr<nsIPrincipal> mPrincipal;
// The external callback. Calling RunCallback(bool) instead of calling it
// directly, RunCallback(bool) handles the internal status.
ServiceWorkerQuotaMitigationCallback mCallback;
bool mGettingOriginUsageDone;
bool mGettingGroupUsageDone;
bool mIsChecking;
uint64_t mOriginUsage;
uint64_t mGroupUsage;
uint64_t mGroupLimit;
};
NS_IMPL_ISUPPORTS(QuotaUsageChecker, nsIQuotaCallback, nsIQuotaUsageCallback,
nsIClearDataCallback)
QuotaUsageChecker::QuotaUsageChecker(
nsIPrincipal* aPrincipal, ServiceWorkerQuotaMitigationCallback&& aCallback)
: mPrincipal(aPrincipal),
mCallback(std::move(aCallback)),
mGettingOriginUsageDone(false),
mGettingGroupUsageDone(false),
mIsChecking(false),
mOriginUsage(0),
mGroupUsage(0),
mGroupLimit(0) {}
void QuotaUsageChecker::Start() {
MOZ_ASSERT(NS_IsMainThread());
if (mIsChecking) {
return;
}
mIsChecking = true;
RefPtr<QuotaUsageChecker> self = this;
auto scopeExit = MakeScopeExit([self]() { self->RunCallback(false); });
RefPtr<QuotaManagerService> qms = QuotaManagerService::GetOrCreate();
MOZ_ASSERT(qms);
// Asynchronious getting quota usage for principal
nsCOMPtr<nsIQuotaUsageRequest> usageRequest;
if (NS_WARN_IF(NS_FAILED(qms->GetUsageForPrincipal(
mPrincipal, this, false, getter_AddRefs(usageRequest))))) {
return;
}
// Asynchronious getting group usage and limit
nsCOMPtr<nsIQuotaRequest> request;
if (NS_WARN_IF(
NS_FAILED(qms->Estimate(mPrincipal, getter_AddRefs(request))))) {
return;
}
request->SetCallback(this);
scopeExit.release();
}
void QuotaUsageChecker::RunCallback(bool aResult) {
MOZ_ASSERT(mIsChecking && mCallback);
if (!mIsChecking) {
return;
}
mIsChecking = false;
mGettingOriginUsageDone = false;
mGettingGroupUsageDone = false;
mCallback(aResult);
mCallback = nullptr;
}
template <typename T, typename U>
nsresult QuotaUsageChecker::GetResult(T* aRequest, U& aResult) {
nsCOMPtr<nsIVariant> result;
nsresult rv = aRequest->GetResult(getter_AddRefs(result));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
nsID* iid;
nsCOMPtr<nsISupports> supports;
rv = result->GetAsInterface(&iid, getter_AddRefs(supports));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
free(iid);
aResult = do_QueryInterface(supports);
return NS_OK;
}
void QuotaUsageChecker::CheckQuotaHeadroom() {
MOZ_ASSERT(NS_IsMainThread());
const uint64_t groupHeadroom =
((uint64_t const)StaticPrefs::
dom_serviceWorkers_mitigations_group_usage_headroom_kb()) *
1024U;
const uint64_t groupAvailable = mGroupLimit - mGroupUsage;
// Group usage head room is satisfied, does not need the usage mitigation.
if (groupAvailable > groupHeadroom) {
RunCallback(true);
return;
}
RefPtr<QuotaUsageChecker> self = this;
auto scopeExit = MakeScopeExit([self]() { self->RunCallback(false); });
nsCOMPtr<nsIClearDataService> csd =
do_GetService("@mozilla.org/clear-data-service;1");
MOZ_ASSERT(csd);
// Group usage headroom is not satisfied even removing the origin usage,
// clear all group usage.
if ((groupAvailable + mOriginUsage) < groupHeadroom) {
nsAutoCString host;
nsresult rv = mPrincipal->GetHost(host);
if (NS_WARN_IF(NS_FAILED(rv))) {
return;
}
rv = csd->DeleteDataFromBaseDomain(
host, false, nsIClearDataService::CLEAR_DOM_QUOTA, this);
if (NS_WARN_IF(NS_FAILED(rv))) {
return;
}
// clear the origin usage since it makes group usage headroom be satisifed.
} else {
nsresult rv = csd->DeleteDataFromPrincipal(
mPrincipal, false, nsIClearDataService::CLEAR_DOM_QUOTA, this);
if (NS_WARN_IF(NS_FAILED(rv))) {
return;
}
}
scopeExit.release();
}
// nsIQuotaUsageCallback implementation
NS_IMETHODIMP QuotaUsageChecker::OnUsageResult(
nsIQuotaUsageRequest* aUsageRequest) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aUsageRequest);
RefPtr<QuotaUsageChecker> self = this;
auto scopeExit = MakeScopeExit([self]() { self->RunCallback(false); });
nsresult resultCode;
nsresult rv = aUsageRequest->GetResultCode(&resultCode);
if (NS_WARN_IF(NS_FAILED(rv) || NS_FAILED(resultCode))) {
return rv;
}
nsCOMPtr<nsIQuotaOriginUsageResult> usageResult;
rv = GetResult(aUsageRequest, usageResult);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
MOZ_ASSERT(usageResult);
rv = usageResult->GetUsage(&mOriginUsage);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
MOZ_ASSERT(!mGettingOriginUsageDone);
mGettingOriginUsageDone = true;
scopeExit.release();
// Call CheckQuotaHeadroom() when both
// QuotaManagerService::GetUsageForPrincipal() and
// QuotaManagerService::Estimate() are done.
if (mGettingOriginUsageDone && mGettingGroupUsageDone) {
CheckQuotaHeadroom();
}
return NS_OK;
}
// nsIQuotaCallback implementation
NS_IMETHODIMP QuotaUsageChecker::OnComplete(nsIQuotaRequest* aRequest) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aRequest);
RefPtr<QuotaUsageChecker> self = this;
auto scopeExit = MakeScopeExit([self]() { self->RunCallback(false); });
nsresult resultCode;
nsresult rv = aRequest->GetResultCode(&resultCode);
if (NS_WARN_IF(NS_FAILED(rv) || NS_FAILED(resultCode))) {
return rv;
}
nsCOMPtr<nsIQuotaEstimateResult> estimateResult;
rv = GetResult(aRequest, estimateResult);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
MOZ_ASSERT(estimateResult);
rv = estimateResult->GetUsage(&mGroupUsage);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
rv = estimateResult->GetLimit(&mGroupLimit);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
MOZ_ASSERT(!mGettingGroupUsageDone);
mGettingGroupUsageDone = true;
scopeExit.release();
// Call CheckQuotaHeadroom() when both
// QuotaManagerService::GetUsageForPrincipal() and
// QuotaManagerService::Estimate() are done.
if (mGettingOriginUsageDone && mGettingGroupUsageDone) {
CheckQuotaHeadroom();
}
return NS_OK;
}
// nsIClearDataCallback implementation
NS_IMETHODIMP QuotaUsageChecker::OnDataDeleted(uint32_t aFailedFlags) {
RunCallback(true);
return NS_OK;
}
// Helper methods in ServiceWorkerQuotaUtils.h
void ClearQuotaUsageIfNeeded(nsIPrincipal* aPrincipal,
ServiceWorkerQuotaMitigationCallback&& aCallback) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aPrincipal);
RefPtr<QuotaUsageChecker> checker =
MakeRefPtr<QuotaUsageChecker>(aPrincipal, std::move(aCallback));
checker->Start();
}
} // namespace mozilla::dom

Просмотреть файл

@ -1,25 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef _mozilla_dom_ServiceWorkerQuotaUtils_h
#define _mozilla_dom_ServiceWorkerQuotaUtils_h
#include <functional>
class nsIPrincipal;
class nsIQuotaUsageRequest;
namespace mozilla {
namespace dom {
using ServiceWorkerQuotaMitigationCallback = std::function<void(bool)>;
void ClearQuotaUsageIfNeeded(nsIPrincipal* aPrincipal,
ServiceWorkerQuotaMitigationCallback&& aCallback);
} // namespace dom
} // namespace mozilla
#endif

Просмотреть файл

@ -517,7 +517,6 @@ void ServiceWorkerRegistrationInfo::MaybeScheduleUpdate() {
// Disable unregister mitigation when navigation fault threshold is 0.
if (navigationFaultThreshold <= navigationFaultCount &&
navigationFaultThreshold != 0) {
CheckQuotaUsage();
swm->Unregister(mPrincipal, nullptr, NS_ConvertUTF8toUTF16(Scope()));
return;
}
@ -896,14 +895,5 @@ void ServiceWorkerRegistrationInfo::ForEachWorker(
}
}
void ServiceWorkerRegistrationInfo::CheckQuotaUsage() {
MOZ_ASSERT(NS_IsMainThread());
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
MOZ_ASSERT(swm);
swm->CheckPrincipalQuotaUsage(mPrincipal, Scope());
}
} // namespace dom
} // namespace mozilla

Просмотреть файл

@ -261,8 +261,6 @@ class ServiceWorkerRegistrationInfo final
// call to `aFunc`, so `aFunc` will always get a reference to a non-null
// pointer.
void ForEachWorker(void (*aFunc)(RefPtr<ServiceWorkerInfo>&));
void CheckQuotaUsage();
};
} // namespace dom

Просмотреть файл

@ -72,7 +72,6 @@ UNIFIED_SOURCES += [
"ServiceWorkerPrivate.cpp",
"ServiceWorkerPrivateImpl.cpp",
"ServiceWorkerProxy.cpp",
"ServiceWorkerQuotaUtils.cpp",
"ServiceWorkerRegisterJob.cpp",
"ServiceWorkerRegistrar.cpp",
"ServiceWorkerRegistration.cpp",

Просмотреть файл

@ -25,11 +25,6 @@ const SWM = Cc["@mozilla.org/serviceworkers/manager;1"].getService(
Ci.nsIServiceWorkerManager
);
// The expected minimum usage for an origin that has any Cache API storage in
// use. Currently, the DB uses a page size of 4k and a minimum growth size of
// 32k and has enough tables/indices for this to round up to 64k.
const kMinimumOriginUsageBytes = 65536;
function getPrincipal(url, attrs) {
const uri = Services.io.newURI(url);
if (!attrs) {
@ -52,13 +47,6 @@ async function _qm_requestFinished(request) {
return request.result;
}
async function qm_reset_storage() {
return new Promise(resolve => {
let request = Services.qms.reset();
request.callback = resolve;
});
}
async function get_qm_origin_usage(origin) {
return new Promise(resolve => {
const principal = Services.scriptSecurityManager.createContentPrincipalFromOrigin(
@ -82,7 +70,7 @@ async function clear_qm_origin_group_via_clearData(origin) {
// Initiate group clearing and wait for it.
await new Promise((resolve, reject) => {
Services.clearData.deleteDataFromBaseDomain(
Services.clearData.deleteDataFromHost(
baseDomain,
false,
Services.clearData.CLEAR_DOM_QUOTA,
@ -177,12 +165,6 @@ async function consume_storage(origin, storageDesc) {
);
}
// Check if the origin is effectively empty, but allowing for the minimum size
// Cache API database to be present.
function is_minimum_origin_usage(originUsageBytes) {
return originUsageBytes <= kMinimumOriginUsageBytes;
}
/**
* Perform a navigation, waiting until the navigation stops, then returning
* the `textContent` of the body node. The expectation is this will be used
@ -271,23 +253,6 @@ function waitForUnregister(scope) {
});
}
// Be careful using this helper function, please make sure QuotaUsageCheck must
// happen, otherwise test would be stucked in this function.
function waitForQuotaUsageCheckFinish(scope) {
return new Promise(function(resolve) {
let listener = {
onQuotaUsageCheckFinish(registration) {
if (registration.scope !== scope) {
return;
}
SWM.removeListener(listener);
resolve(registration);
},
};
SWM.addListener(listener);
});
}
function waitForServiceWorkerRegistrationChange(registration, callback) {
return new Promise(function(resolve) {
let listener = {

Просмотреть файл

@ -104,8 +104,8 @@ const TEST_SW_SETUP = {
};
const TEST_STORAGE_SETUP = {
cacheBytes: 4 * 1024 * 1024, // 4 MiB
idbBytes: 4 * 1024 * 1024, // 4 MiB
cacheBytes: 4 * 1024 * 1024,
idbBytes: 4 * 1024 * 1024,
};
const FAULTS_BEFORE_MITIGATION = 3;
@ -139,7 +139,7 @@ async function do_fault_injection_test({
// ## Generate quota usage if appropriate
if (consumeQuotaOrigin) {
await consume_storage(consumeQuotaOrigin, TEST_STORAGE_SETUP);
await consume_storage(consumeQuotaOrigin, TEST_SW_SETUP);
}
// ## Verify normal navigation is served by the SW.
@ -164,17 +164,13 @@ async function do_fault_injection_test({
// we expect it happens after navigation fault threshold reached.
const unregisteredPromise = waitForUnregister(reg.scope);
// Make sure the test is listening on the finish of quota checking, since we
// expect it happens after navigation fault threshold reached.
const quotaUsageCheckFinishPromise = waitForQuotaUsageCheckFinish(reg.scope);
// ## Inject faults in a loop until expected mitigation.
sw.testingInjectCancellation = useError;
for (let iFault = 0; iFault < FAULTS_BEFORE_MITIGATION; iFault++) {
info(`## Testing with injected fault number ${iFault + 1}`);
// We should never have triggered an origin quota usage check before the
// final fault injection.
is(reg.quotaUsageCheckCount, 0, "No quota usage check yet");
is(reg.quotaUsageCheckCount, 0, "No quota usage check yet.");
// Make sure our loads encode the specific
const debugTag = `err=${name}&fault=${iFault + 1}`;
@ -198,23 +194,17 @@ async function do_fault_injection_test({
}
await unregisteredPromise;
is(reg.unregistered, true, "registration should be unregistered");
//is(reg.quotaUsageCheckCount, 1, "Quota usage check must be started");
await quotaUsageCheckFinishPromise;
is(reg.unregistered, true, "registration should not exist.");
if (consumeQuotaOrigin) {
// Check that there is no longer any storage usaged by the origin in this
// case.
const originUsage = await get_qm_origin_usage(TEST_ORIGIN);
ok(
is_minimum_origin_usage(originUsage),
"origin usage should be mitigated"
);
ok(originUsage > 0, "origin should still have usage until mitigated");
if (consumeQuotaOrigin === SAME_GROUP_ORIGIN) {
const sameGroupUsage = await get_qm_origin_usage(SAME_GROUP_ORIGIN);
ok(sameGroupUsage === 0, "same group usage should be mitigated");
ok(sameGroupUsage > 0, "same group should still have usage for now");
}
}
}
@ -226,8 +216,6 @@ add_task(async function test_navigation_fetch_fault_handling() {
["dom.serviceWorkers.exemptFromPerDomainMax", true],
["dom.serviceWorkers.testing.enabled", true],
["dom.serviceWorkers.mitigations.bypass_on_fault", true],
["dom.serviceWorkers.mitigations.group_usage_headroom_kb", 5 * 1024],
["dom.quotaManager.testing", true],
// We want the temporary global limit to be 10 MiB (the pref is in KiB).
// This will result in the group limit also being 10 MiB because on small
// disks we provide a group limit value of min(10 MiB, global limit).
@ -235,10 +223,6 @@ add_task(async function test_navigation_fetch_fault_handling() {
],
});
// Need to reset the storages to make dom.quotaManager.temporaryStorage.fixedLimit
// works.
await qm_reset_storage();
const quotaOriginVariations = [
// Don't put us near the storage limit.
undefined,

Просмотреть файл

@ -94,18 +94,7 @@ async function unregisterAll() {
*/
function makeRandomBlob(size) {
const arr = new Uint8Array(size);
let offset = 0;
/**
* getRandomValues will only provide a maximum of 64k of data at a time and
* will error if we ask for more, so using a while loop for get a random value
* which much larger than 64k.
* https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues#exceptions
*/
while (offset < size) {
const nextSize = Math.min(size - offset, 65536);
window.crypto.getRandomValues(new Uint8Array(arr.buffer, offset, nextSize));
offset += nextSize;
}
window.crypto.getRandomValues(arr);
return new Blob([arr], { type: "application/octet-stream" });
}

Просмотреть файл

@ -3221,15 +3221,6 @@
value: 3
mirror: always
# This is the group usage head room for service workers.
# The quota usage mitigation algorithm uses this preference to determine if the
# origin or also group data should be cleared or not.
# The default value is 400 MiB.
- name: dom.serviceWorkers.mitigations.group_usage_headroom_kb
type: uint32_t
value: 400 * 1024
mirror: always
- name: dom.serviceWorkers.testing.enabled
type: RelaxedAtomicBool
value: false