mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-26 14:46:02 +00:00
Bug 1686441 - Add a console warning when blob URL partitioning is applied. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D104813
This commit is contained in:
parent
256efbd575
commit
44ff017837
@ -375,7 +375,8 @@ void BlobURLInputStream::RetrieveBlobData(const MutexAutoLock& aProofOfLock) {
|
||||
if (!BlobURLProtocolHandler::GetDataEntry(
|
||||
mBlobURLSpec, getter_AddRefs(blobImpl), loadingPrincipal,
|
||||
triggeringPrincipal, loadInfo->GetOriginAttributes(),
|
||||
agentClusterId, true /* AlsoIfRevoked */)) {
|
||||
loadInfo->GetInnerWindowID(), agentClusterId,
|
||||
true /* AlsoIfRevoked */)) {
|
||||
NS_WARNING("Failed to get data entry principal. URL revoked?");
|
||||
return;
|
||||
}
|
||||
@ -407,7 +408,8 @@ void BlobURLInputStream::RetrieveBlobData(const MutexAutoLock& aProofOfLock) {
|
||||
contentChild
|
||||
->SendBlobURLDataRequest(mBlobURLSpec, triggeringPrincipal,
|
||||
loadingPrincipal,
|
||||
loadInfo->GetOriginAttributes(), agentClusterId)
|
||||
loadInfo->GetOriginAttributes(),
|
||||
loadInfo->GetInnerWindowID(), agentClusterId)
|
||||
->Then(
|
||||
GetCurrentSerialEventTarget(), __func__,
|
||||
[self](const BlobURLDataRequestResult& aResult) {
|
||||
|
@ -737,7 +737,7 @@ nsresult BlobURLProtocolHandler::GenerateURIString(nsIPrincipal* aPrincipal,
|
||||
bool BlobURLProtocolHandler::GetDataEntry(
|
||||
const nsACString& aUri, mozilla::dom::BlobImpl** aBlobImpl,
|
||||
nsIPrincipal* aLoadingPrincipal, nsIPrincipal* aTriggeringPrincipal,
|
||||
const OriginAttributes& aOriginAttributes,
|
||||
const OriginAttributes& aOriginAttributes, uint64_t aInnerWindowId,
|
||||
const Maybe<nsID>& aAgentClusterId, bool aAlsoIfRevoked) {
|
||||
MOZ_ASSERT(NS_IsMainThread(),
|
||||
"without locking gDataTable is main-thread only");
|
||||
@ -778,6 +778,18 @@ bool BlobURLProtocolHandler::GetDataEntry(
|
||||
if (StaticPrefs::privacy_partition_bloburl_per_agent_cluster() &&
|
||||
aAgentClusterId.isSome() && info->mAgentClusterId.isSome() &&
|
||||
NS_WARN_IF(!aAgentClusterId->Equals(info->mAgentClusterId.value()))) {
|
||||
nsAutoString localizedMsg;
|
||||
AutoTArray<nsString, 1> param;
|
||||
CopyUTF8toUTF16(aUri, *param.AppendElement());
|
||||
nsresult rv = nsContentUtils::FormatLocalizedString(
|
||||
nsContentUtils::eDOM_PROPERTIES, "BlobDifferentClusterError", param,
|
||||
localizedMsg);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsContentUtils::ReportToConsoleByWindowID(
|
||||
localizedMsg, nsIScriptError::errorFlag, "DOM"_ns, aInnerWindowId);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -75,6 +75,7 @@ class BlobURLProtocolHandler final : public nsIProtocolHandler,
|
||||
nsIPrincipal* aLoadingPrincipal,
|
||||
nsIPrincipal* aTriggeringPrincipal,
|
||||
const OriginAttributes& aOriginAttributes,
|
||||
uint64_t aInnerWindowId,
|
||||
const Maybe<nsID>& blobAgentClusterId,
|
||||
bool aAlsoIfRevoked = false);
|
||||
|
||||
|
@ -7196,7 +7196,7 @@ PFileDescriptorSetParent* ContentParent::SendPFileDescriptorSetConstructor(
|
||||
mozilla::ipc::IPCResult ContentParent::RecvBlobURLDataRequest(
|
||||
const nsCString& aBlobURL, nsIPrincipal* aTriggeringPrincipal,
|
||||
nsIPrincipal* aLoadingPrincipal, const OriginAttributes& aOriginAttributes,
|
||||
const Maybe<nsID>& aAgentClusterId,
|
||||
uint64_t aInnerWindowId, const Maybe<nsID>& aAgentClusterId,
|
||||
BlobURLDataRequestResolver&& aResolver) {
|
||||
RefPtr<BlobImpl> blobImpl;
|
||||
|
||||
@ -7204,8 +7204,8 @@ mozilla::ipc::IPCResult ContentParent::RecvBlobURLDataRequest(
|
||||
// longer exists (due to the 5 second timeout) when execution reaches here
|
||||
if (!BlobURLProtocolHandler::GetDataEntry(
|
||||
aBlobURL, getter_AddRefs(blobImpl), aLoadingPrincipal,
|
||||
aTriggeringPrincipal, aOriginAttributes, aAgentClusterId,
|
||||
true /* AlsoIfRevoked */)) {
|
||||
aTriggeringPrincipal, aOriginAttributes, aInnerWindowId,
|
||||
aAgentClusterId, true /* AlsoIfRevoked */)) {
|
||||
aResolver(NS_ERROR_DOM_BAD_URI);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
@ -724,7 +724,7 @@ class ContentParent final
|
||||
mozilla::ipc::IPCResult RecvBlobURLDataRequest(
|
||||
const nsCString& aBlobURL, nsIPrincipal* pTriggeringPrincipal,
|
||||
nsIPrincipal* pLoadingPrincipal,
|
||||
const OriginAttributes& aOriginAttributes,
|
||||
const OriginAttributes& aOriginAttributes, uint64_t aInnerWindowId,
|
||||
const Maybe<nsID>& aAgentClusterId,
|
||||
BlobURLDataRequestResolver&& aResolver);
|
||||
|
||||
|
@ -1721,6 +1721,7 @@ parent:
|
||||
nsIPrincipal aTriggeringPrincipal,
|
||||
nsIPrincipal aLoadingPrincipal,
|
||||
OriginAttributes aOriginAttributes,
|
||||
uint64_t aInnerWindowId,
|
||||
nsID? aAgentClusterId)
|
||||
returns (BlobURLDataRequestResult aResult);
|
||||
|
||||
|
@ -411,3 +411,5 @@ ExternalProtocolFrameBlockedNoUserActivation=Iframe with external protocol was b
|
||||
MultiplePopupsBlockedNoUserActivation=Opening multiple popups was blocked due to lack of user activation.
|
||||
# LOCALIZATION NOTE: %S is the URL of the preload that was ignored.
|
||||
PreloadIgnoredInvalidAttr=Preload of %S was ignored due to unknown “as” or “type” values, or non-matching “media” attribute.
|
||||
# LOCALIZATION NOTE: %S is the blob URL. Don't translate "agent cluster".
|
||||
BlobDifferentClusterError=Cannot access blob URL “%S” from a different agent cluster.
|
||||
|
Loading…
x
Reference in New Issue
Block a user