зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1314361 - Part 4: Stop setting addonId origin attribute. r=billm
This commit is contained in:
Родитель
85333437e5
Коммит
45dbac3bdd
|
@ -345,20 +345,6 @@ nsScriptSecurityManager::GetChannelResultPrincipal(nsIChannel* aChannel,
|
||||||
return GetChannelURIPrincipal(aChannel, aPrincipal);
|
return GetChannelURIPrincipal(aChannel, aPrincipal);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
|
||||||
nsScriptSecurityManager::MaybeSetAddonIdFromURI(OriginAttributes& aAttrs, nsIURI* aURI)
|
|
||||||
{
|
|
||||||
nsAutoCString scheme;
|
|
||||||
nsresult rv = aURI->GetScheme(scheme);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
if (scheme.EqualsLiteral("moz-extension") && GetAddonPolicyService()) {
|
|
||||||
rv = GetAddonPolicyService()->ExtensionURIToAddonId(aURI, aAttrs.mAddonId);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
}
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The principal of the URI that this channel is loading. This is never
|
/* The principal of the URI that this channel is loading. This is never
|
||||||
* affected by things like sandboxed loads, or loads where we forcefully
|
* affected by things like sandboxed loads, or loads where we forcefully
|
||||||
* inherit the principal. Think of this as the principal of the server
|
* inherit the principal. Think of this as the principal of the server
|
||||||
|
@ -396,8 +382,6 @@ nsScriptSecurityManager::GetChannelURIPrincipal(nsIChannel* aChannel,
|
||||||
if (loadInfo) {
|
if (loadInfo) {
|
||||||
attrs.Inherit(loadInfo->GetOriginAttributes());
|
attrs.Inherit(loadInfo->GetOriginAttributes());
|
||||||
}
|
}
|
||||||
rv = MaybeSetAddonIdFromURI(attrs, uri);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
nsCOMPtr<nsIPrincipal> prin = BasePrincipal::CreateCodebasePrincipal(uri, attrs);
|
nsCOMPtr<nsIPrincipal> prin = BasePrincipal::CreateCodebasePrincipal(uri, attrs);
|
||||||
prin.forget(aPrincipal);
|
prin.forget(aPrincipal);
|
||||||
return *aPrincipal ? NS_OK : NS_ERROR_FAILURE;
|
return *aPrincipal ? NS_OK : NS_ERROR_FAILURE;
|
||||||
|
@ -1166,8 +1150,6 @@ nsScriptSecurityManager::
|
||||||
OriginAttributes attrs;
|
OriginAttributes attrs;
|
||||||
attrs.Inherit(docShellAttrs);
|
attrs.Inherit(docShellAttrs);
|
||||||
|
|
||||||
nsresult rv = MaybeSetAddonIdFromURI(attrs, aURI);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
nsCOMPtr<nsIPrincipal> prin = BasePrincipal::CreateCodebasePrincipal(aURI, attrs);
|
nsCOMPtr<nsIPrincipal> prin = BasePrincipal::CreateCodebasePrincipal(aURI, attrs);
|
||||||
prin.forget(aPrincipal);
|
prin.forget(aPrincipal);
|
||||||
return *aPrincipal ? NS_OK : NS_ERROR_FAILURE;
|
return *aPrincipal ? NS_OK : NS_ERROR_FAILURE;
|
||||||
|
@ -1181,8 +1163,6 @@ nsScriptSecurityManager::GetDocShellCodebasePrincipal(nsIURI* aURI,
|
||||||
OriginAttributes attrs;
|
OriginAttributes attrs;
|
||||||
attrs.Inherit(nsDocShell::Cast(aDocShell)->GetOriginAttributes());
|
attrs.Inherit(nsDocShell::Cast(aDocShell)->GetOriginAttributes());
|
||||||
|
|
||||||
nsresult rv = MaybeSetAddonIdFromURI(attrs, aURI);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
nsCOMPtr<nsIPrincipal> prin = BasePrincipal::CreateCodebasePrincipal(aURI, attrs);
|
nsCOMPtr<nsIPrincipal> prin = BasePrincipal::CreateCodebasePrincipal(aURI, attrs);
|
||||||
prin.forget(aPrincipal);
|
prin.forget(aPrincipal);
|
||||||
return *aPrincipal ? NS_OK : NS_ERROR_FAILURE;
|
return *aPrincipal ? NS_OK : NS_ERROR_FAILURE;
|
||||||
|
|
|
@ -111,9 +111,6 @@ private:
|
||||||
inline void
|
inline void
|
||||||
AddSitesToFileURIWhitelist(const nsCString& aSiteList);
|
AddSitesToFileURIWhitelist(const nsCString& aSiteList);
|
||||||
|
|
||||||
// If aURI is a moz-extension:// URI, set mAddonId to the associated addon.
|
|
||||||
nsresult MaybeSetAddonIdFromURI(mozilla::OriginAttributes& aAttrs, nsIURI* aURI);
|
|
||||||
|
|
||||||
nsresult GetChannelResultPrincipal(nsIChannel* aChannel,
|
nsresult GetChannelResultPrincipal(nsIChannel* aChannel,
|
||||||
nsIPrincipal** aPrincipal,
|
nsIPrincipal** aPrincipal,
|
||||||
bool aIgnoreSandboxing);
|
bool aIgnoreSandboxing);
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
#include "mozilla/BasePrincipal.h"
|
#include "mozilla/BasePrincipal.h"
|
||||||
#include "mozilla/Casting.h"
|
#include "mozilla/Casting.h"
|
||||||
#include "mozilla/dom/ContentChild.h"
|
#include "mozilla/dom/ContentChild.h"
|
||||||
#include "mozilla/dom/ChromeUtils.h"
|
|
||||||
#include "mozilla/dom/Element.h"
|
#include "mozilla/dom/Element.h"
|
||||||
#include "mozilla/dom/PendingGlobalHistoryEntry.h"
|
#include "mozilla/dom/PendingGlobalHistoryEntry.h"
|
||||||
#include "mozilla/dom/TabChild.h"
|
#include "mozilla/dom/TabChild.h"
|
||||||
|
@ -8028,9 +8027,7 @@ nsDocShell::CreateAboutBlankContentViewer(nsIPrincipal* aPrincipal,
|
||||||
|
|
||||||
if (aPrincipal && !nsContentUtils::IsSystemPrincipal(aPrincipal) &&
|
if (aPrincipal && !nsContentUtils::IsSystemPrincipal(aPrincipal) &&
|
||||||
mItemType != typeChrome) {
|
mItemType != typeChrome) {
|
||||||
MOZ_ASSERT(ChromeUtils::IsOriginAttributesEqualIgnoringAddonId(
|
MOZ_ASSERT(aPrincipal->OriginAttributesRef() == mOriginAttributes);
|
||||||
aPrincipal->OriginAttributesRef(),
|
|
||||||
mOriginAttributes));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure timing is created. But first record whether we had it
|
// Make sure timing is created. But first record whether we had it
|
||||||
|
|
|
@ -105,7 +105,7 @@ PostMessageEvent::Run()
|
||||||
// don't do that in other places it seems better to hold the line for
|
// don't do that in other places it seems better to hold the line for
|
||||||
// now. Long-term, we want HTML5 to address this so that we can
|
// now. Long-term, we want HTML5 to address this so that we can
|
||||||
// be compliant while being safer.
|
// be compliant while being safer.
|
||||||
if (!BasePrincipal::Cast(targetPrin)->EqualsIgnoringAddonId(mProvidedPrincipal)) {
|
if (!targetPrin->Equals(mProvidedPrincipal)) {
|
||||||
nsAutoString providedOrigin, targetOrigin;
|
nsAutoString providedOrigin, targetOrigin;
|
||||||
nsresult rv = nsContentUtils::GetUTFOrigin(targetPrin, targetOrigin);
|
nsresult rv = nsContentUtils::GetUTFOrigin(targetPrin, targetOrigin);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
|
@ -194,13 +194,11 @@ var UninstallObserver = {
|
||||||
// Clear any IndexedDB storage created by the extension
|
// Clear any IndexedDB storage created by the extension
|
||||||
let baseURI = NetUtil.newURI(`moz-extension://${uuid}/`);
|
let baseURI = NetUtil.newURI(`moz-extension://${uuid}/`);
|
||||||
let principal = Services.scriptSecurityManager.createCodebasePrincipal(
|
let principal = Services.scriptSecurityManager.createCodebasePrincipal(
|
||||||
baseURI, {addonId: addon.id}
|
baseURI, {});
|
||||||
);
|
|
||||||
Services.qms.clearStoragesForPrincipal(principal);
|
Services.qms.clearStoragesForPrincipal(principal);
|
||||||
|
|
||||||
// Clear localStorage created by the extension
|
// Clear localStorage created by the extension
|
||||||
let attrs = JSON.stringify({addonId: addon.id});
|
Services.domStorageManager.getStorage(null, principal).clear();
|
||||||
Services.obs.notifyObservers(null, "clear-origin-attributes-data", attrs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.leaveUuid) {
|
if (!this.leaveUuid) {
|
||||||
|
@ -712,8 +710,7 @@ this.Extension = class extends ExtensionData {
|
||||||
}
|
}
|
||||||
|
|
||||||
createPrincipal(uri = this.baseURI) {
|
createPrincipal(uri = this.baseURI) {
|
||||||
return Services.scriptSecurityManager.createCodebasePrincipal(
|
return Services.scriptSecurityManager.createCodebasePrincipal(uri, {});
|
||||||
uri, {addonId: this.id});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks that the given URL is a child of our baseURI.
|
// Checks that the given URL is a child of our baseURI.
|
||||||
|
|
|
@ -331,10 +331,9 @@ class ContentScriptContextChild extends BaseContext {
|
||||||
let contentPrincipal = contentWindow.document.nodePrincipal;
|
let contentPrincipal = contentWindow.document.nodePrincipal;
|
||||||
let ssm = Services.scriptSecurityManager;
|
let ssm = Services.scriptSecurityManager;
|
||||||
|
|
||||||
// copy origin attributes from the content window origin attributes to
|
// Copy origin attributes from the content window origin attributes to
|
||||||
// preserve the user context id. overwrite the addonId.
|
// preserve the user context id.
|
||||||
let attrs = contentPrincipal.originAttributes;
|
let attrs = contentPrincipal.originAttributes;
|
||||||
attrs.addonId = this.extension.id;
|
|
||||||
let extensionPrincipal = ssm.createCodebasePrincipal(this.extension.baseURI, attrs);
|
let extensionPrincipal = ssm.createCodebasePrincipal(this.extension.baseURI, attrs);
|
||||||
|
|
||||||
let principal;
|
let principal;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче