Bug 1233885 - fix up docInfo and permission manager to use default user context. r=sicking

(HEAD -> oa, refs/patches/oa/Bug_1233885)
fix up docInfo and permission manager to use default user context
This commit is contained in:
Dave Huseby 2016-03-26 15:07:00 +01:00
Родитель b68d05d398
Коммит b815db526b
5 изменённых файлов: 20 добавлений и 14 удалений

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

@ -1019,6 +1019,7 @@ var PageInfoListener = {
docInfo.contentType = document.contentType;
docInfo.characterSet = document.characterSet;
docInfo.lastModified = document.lastModified;
docInfo.principal = document.nodePrincipal;
let documentURIObject = {};
documentURIObject.spec = document.documentURIObject.spec;

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

@ -375,6 +375,7 @@ function loadPageInfo(frameOuterWindowID, imageElement)
let windowInfo = pageInfoData.windowInfo;
let uri = makeURI(docInfo.documentURIObject.spec,
docInfo.documentURIObject.originCharset);
let principal = docInfo.principal;
gDocInfo = docInfo;
gImageElement = pageInfoData.imageInfo;
@ -387,7 +388,7 @@ function loadPageInfo(frameOuterWindowID, imageElement)
makeGeneralTab(pageInfoData.metaViewRows, docInfo);
initFeedTab(pageInfoData.feeds);
onLoadPermission(uri);
onLoadPermission(uri, principal);
securityOnLoad(uri, windowInfo);
});

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

@ -8,6 +8,7 @@ Components.utils.import("resource://gre/modules/BrowserUtils.jsm");
const nsIQuotaManagerService = Components.interfaces.nsIQuotaManagerService;
var gPermURI;
var gPermPrincipal;
var gUsageRequest;
var gPermissions = SitePermissions.listPermissions();
@ -28,11 +29,12 @@ var permissionObserver = {
}
};
function onLoadPermission(uri)
function onLoadPermission(uri, principal)
{
var permTab = document.getElementById("permTab");
if (SitePermissions.isSupportedURI(uri)) {
gPermURI = uri;
gPermPrincipal = principal;
var hostText = document.getElementById("hostText");
hostText.value = gPermURI.prePath;
@ -189,11 +191,8 @@ function initIndexedDBRow()
var quotaManagerService =
Components.classes["@mozilla.org/dom/quota-manager-service;1"]
.getService(nsIQuotaManagerService);
let principal = Components.classes["@mozilla.org/scriptsecuritymanager;1"]
.getService(Components.interfaces.nsIScriptSecurityManager)
.createCodebasePrincipal(gPermURI, {});
gUsageRequest =
quotaManagerService.getUsageForPrincipal(principal,
quotaManagerService.getUsageForPrincipal(gPermPrincipal,
onIndexedDBUsageCallback);
var status = document.getElementById("indexedDBStatus");
@ -206,13 +205,9 @@ function initIndexedDBRow()
function onIndexedDBClear()
{
let principal = Components.classes["@mozilla.org/scriptsecuritymanager;1"]
.getService(Components.interfaces.nsIScriptSecurityManager)
.createCodebasePrincipal(gPermURI, {});
Components.classes["@mozilla.org/dom/quota-manager-service;1"]
.getService(nsIQuotaManagerService)
.clearStoragesForPrincipal(principal);
.clearStoragesForPrincipal(gPermPrincipal);
Components.classes["@mozilla.org/serviceworkers/manager;1"]
.getService(Components.interfaces.nsIServiceWorkerManager)

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

@ -112,6 +112,9 @@ GetPrincipalFromOrigin(const nsACString& aOrigin, nsIPrincipal** aPrincipal)
return NS_ERROR_FAILURE;
}
// set to default to disable user context isolation for permissions
attrs.mUserContextId = nsIScriptSecurityManager::DEFAULT_USER_CONTEXT_ID;
nsCOMPtr<nsIURI> uri;
nsresult rv = NS_NewURI(getter_AddRefs(uri), originNoSuffix);
NS_ENSURE_SUCCESS(rv, rv);
@ -2165,8 +2168,14 @@ nsPermissionManager::GetPermissionHashKey(nsIPrincipal* aPrincipal,
}
// Copy the attributes over
mozilla::PrincipalOriginAttributes attrs = mozilla::BasePrincipal::Cast(aPrincipal)->OriginAttributesRef();
nsCOMPtr<nsIPrincipal> principal = mozilla::BasePrincipal::CreateCodebasePrincipal(newURI, attrs);
mozilla::PrincipalOriginAttributes attrs =
mozilla::BasePrincipal::Cast(aPrincipal)->OriginAttributesRef();
// ensure that the user context isolation is disabled
attrs.mUserContextId = nsIScriptSecurityManager::DEFAULT_USER_CONTEXT_ID;
nsCOMPtr<nsIPrincipal> principal =
mozilla::BasePrincipal::CreateCodebasePrincipal(newURI, attrs);
return GetPermissionHashKey(principal, aType, aExactHostMatch);
}

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

@ -64,7 +64,7 @@ interface nsIPermission : nsISupports
/**
* Test whether a URI would be affected by this permission.
* This performs a matches with a NO_APP_ID identifier.
* NOTE: This performs matches with default origin attribute values.
*
* @param uri the uri to test
* @param exactHost If true, only the specific host will be matched,