зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1724768 - Part 1: Add ChromeUtils.getPartitionKeyFromURL(). r=pbz,robwu
Differential Revision: https://phabricator.services.mozilla.com/D122320
This commit is contained in:
Родитель
e7e6a469c6
Коммит
67476e5f95
|
@ -781,6 +781,26 @@ void ChromeUtils::GetBaseDomainFromPartitionKey(dom::GlobalObject& aGlobal,
|
|||
aBaseDomain = pkBaseDomain;
|
||||
}
|
||||
|
||||
/* static */
|
||||
void ChromeUtils::GetPartitionKeyFromURL(dom::GlobalObject& aGlobal,
|
||||
const nsAString& aURL,
|
||||
nsAString& aPartitionKey,
|
||||
ErrorResult& aRv) {
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = NS_NewURI(getter_AddRefs(uri), aURL);
|
||||
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
aPartitionKey.Truncate();
|
||||
aRv.Throw(rv);
|
||||
return;
|
||||
}
|
||||
|
||||
mozilla::OriginAttributes attrs;
|
||||
attrs.SetPartitionKey(uri);
|
||||
|
||||
aPartitionKey = attrs.mPartitionKey;
|
||||
}
|
||||
|
||||
#ifdef NIGHTLY_BUILD
|
||||
/* static */
|
||||
void ChromeUtils::GetRecentJSDevError(GlobalObject& aGlobal,
|
||||
|
|
|
@ -129,6 +129,11 @@ class ChromeUtils {
|
|||
nsAString& aBaseDomain,
|
||||
ErrorResult& aRv);
|
||||
|
||||
static void GetPartitionKeyFromURL(dom::GlobalObject& aGlobal,
|
||||
const nsAString& aURL,
|
||||
nsAString& aPartitionKey,
|
||||
ErrorResult& aRv);
|
||||
|
||||
// Implemented in js/xpconnect/loader/ChromeScriptLoader.cpp
|
||||
static already_AddRefed<Promise> CompileScript(
|
||||
GlobalObject& aGlobal, const nsAString& aUrl,
|
||||
|
|
|
@ -316,6 +316,18 @@ partial namespace ChromeUtils {
|
|||
DOMString
|
||||
getBaseDomainFromPartitionKey(DOMString partitionKey);
|
||||
|
||||
/**
|
||||
* Returns the partitionKey for a given URL.
|
||||
*
|
||||
* The function will treat the URL as a first party and construct the
|
||||
* partitionKey according to the scheme, site and port in the URL.
|
||||
*
|
||||
* Throws for invalid urls.
|
||||
*/
|
||||
[Throws]
|
||||
DOMString
|
||||
getPartitionKeyFromURL(DOMString url);
|
||||
|
||||
/**
|
||||
* Loads and compiles the script at the given URL and returns an object
|
||||
* which may be used to execute it repeatedly, in different globals, without
|
||||
|
|
Загрузка…
Ссылка в новой задаче