Revert logic changes of Bug 1819147. This makes the behavior of clearOriginAttributes again in sync with the documentation: > Evict any cache entry having the same originAttributes.[1] `partitionKey` is part of the originAttributes[2], therefore both functions shouldn't clear unrelated partitions. To clear the cache (and other things) across partitionKeys, a wildcard with `deleteByOriginAttributes()`[3] can be used. To clear the cache for the "unpartitioned" for i.e. "http://example.com" in `userContextId: 0`, it would then be necessary to pass the partition: Services.cache2.clearOriginAttributes(JSON.stringify({ userContextId:0, paritionKey: "(http,example.com)" })) Outside of this patch it would be good to figured out why the need for clearing across origins arose in Bug 1819147 to address that use case separately. [1]: https://searchfox.org/mozilla-central/rev/e8da1e780e9b8ed2fd82a3b8d79c5f93e72697d3/netwerk/cache2/nsICacheStorageService.idl#71 [2]: https://searchfox.org/mozilla-central/rev/e8da1e780e9b8ed2fd82a3b8d79c5f93e72697d3/dom/chrome-webidl/ChromeUtils.webidl#960 [3]: https://searchfox.org/mozilla-central/rev/e8da1e780e9b8ed2fd82a3b8d79c5f93e72697d3/toolkit/components/cleardata/ClearDataService.sys.mjs#178-180 Differential Revision: https://phabricator.services.mozilla.com/D238074
87 lines
2.4 KiB
Plaintext
87 lines
2.4 KiB
Plaintext
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
/* 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 "nsISupports.idl"
|
|
|
|
%{ C++
|
|
#include "mozilla/BasePrincipal.h"
|
|
%}
|
|
native OriginAttributesNativePtr(const mozilla::OriginAttributes*);
|
|
|
|
interface nsILoadContext;
|
|
interface nsIDOMWindow;
|
|
|
|
/**
|
|
* Helper interface to carry informatin about the load context
|
|
* encapsulating origin attributes and IsAnonymous, IsPrivite properties.
|
|
* It shall be used where nsILoadContext cannot be used or is not
|
|
* available.
|
|
*/
|
|
|
|
[scriptable, builtinclass, uuid(555e2f8a-a1f6-41dd-88ca-ed4ed6b98a22)]
|
|
interface nsILoadContextInfo : nsISupports
|
|
{
|
|
/**
|
|
* Whether the context is in a Private Browsing mode
|
|
*/
|
|
readonly attribute boolean isPrivate;
|
|
|
|
/**
|
|
* Whether the load is initiated as anonymous
|
|
*/
|
|
readonly attribute boolean isAnonymous;
|
|
|
|
/**
|
|
* OriginAttributes hiding all the security context attributes
|
|
*/
|
|
[implicit_jscontext]
|
|
readonly attribute jsval originAttributes;
|
|
[noscript, notxpcom, nostdcall, binaryname(OriginAttributesPtr)]
|
|
OriginAttributesNativePtr binaryOriginAttributesPtr();
|
|
|
|
%{C++
|
|
/**
|
|
* De-XPCOMed getters
|
|
*/
|
|
bool IsPrivate()
|
|
{
|
|
bool pb;
|
|
GetIsPrivate(&pb);
|
|
return pb;
|
|
}
|
|
|
|
bool IsAnonymous()
|
|
{
|
|
bool anon;
|
|
GetIsAnonymous(&anon);
|
|
return anon;
|
|
}
|
|
|
|
bool Equals(nsILoadContextInfo *aOther)
|
|
{
|
|
return IsAnonymous() == aOther->IsAnonymous() &&
|
|
*OriginAttributesPtr() == *aOther->OriginAttributesPtr();
|
|
}
|
|
%}
|
|
};
|
|
|
|
/**
|
|
* Since OriginAttributes struct limits the implementation of
|
|
* nsILoadContextInfo (that needs to be thread safe) to C++,
|
|
* we need a scriptable factory to create instances of that
|
|
* interface from JS.
|
|
*/
|
|
[scriptable, uuid(c1c7023d-4318-4f99-8307-b5ccf0558793)]
|
|
interface nsILoadContextInfoFactory : nsISupports
|
|
{
|
|
readonly attribute nsILoadContextInfo default;
|
|
readonly attribute nsILoadContextInfo private;
|
|
readonly attribute nsILoadContextInfo anonymous;
|
|
[implicit_jscontext]
|
|
nsILoadContextInfo custom(in boolean aAnonymous, in jsval aOriginAttributes);
|
|
nsILoadContextInfo fromLoadContext(in nsILoadContext aLoadContext, in boolean aAnonymous);
|
|
nsILoadContextInfo fromWindow(in nsIDOMWindow aWindow, in boolean aAnonymous);
|
|
};
|