Bug 1297687 - Part 1: Remove nsIScriptSecurityManager.createExpandedPrincipal(); r=bholley

This commit is contained in:
Ehsan Akhgari 2016-09-21 15:37:04 -04:00
Родитель 48aef09e25
Коммит 6b65aceec2
4 изменённых файлов: 3 добавлений и 32 удалений

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

@ -200,20 +200,6 @@ interface nsIScriptSecurityManager : nsISupports
[implicit_jscontext]
nsIPrincipal createNullPrincipal(in jsval originAttributes);
/**
* Creates an expanded principal whose capabilities are the union of the
* given principals. An expanded principal has an asymmetric privilege
* relationship with its sub-principals (that is to say, it subsumes the
* sub-principals, but the sub-principals do not subsume it), even if
* there's only one. This presents a legitimate use-case for making an
* expanded principal around a single sub-principal, which we do frequently.
*
* Expanded principals cannot have origin attributes themselves, but rather
* have them through their sub-principals - so we don't accept them here.
*/
nsIPrincipal createExpandedPrincipal([array, size_is(aLength)] in nsIPrincipal aPrincipalArray,
[optional] in unsigned long aLength);
/**
* Returns OK if aSourceURI and target have the same "origin"
* (scheme, host, and port).

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

@ -1181,21 +1181,6 @@ nsScriptSecurityManager::CreateNullPrincipal(JS::Handle<JS::Value> aOriginAttrib
return NS_OK;
}
NS_IMETHODIMP
nsScriptSecurityManager::CreateExpandedPrincipal(nsIPrincipal** aPrincipalArray, uint32_t aLength,
nsIPrincipal** aResult)
{
nsTArray<nsCOMPtr<nsIPrincipal>> principals;
principals.SetCapacity(aLength);
for (uint32_t i = 0; i < aLength; ++i) {
principals.AppendElement(aPrincipalArray[i]);
}
nsCOMPtr<nsIPrincipal> p = new nsExpandedPrincipal(principals);
p.forget(aResult);
return NS_OK;
}
NS_IMETHODIMP
nsScriptSecurityManager::GetAppCodebasePrincipal(nsIURI* aURI,
uint32_t aAppId,

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

@ -80,7 +80,7 @@ function run_test() {
var ipv6NPPrin = ssm.createCodebasePrincipal(makeURI('https://[2001:db8::ff00:42:8329]'), {});
do_check_eq(ipv6NPPrin.origin, 'https://[2001:db8::ff00:42:8329]');
checkOriginAttributes(ipv6NPPrin);
var ep = ssm.createExpandedPrincipal([exampleCom, nullPrin, exampleOrg]);
var ep = Cu.getObjectPrincipal(Cu.Sandbox([exampleCom, nullPrin, exampleOrg]));
checkOriginAttributes(ep);
checkCrossOrigin(exampleCom, exampleOrg);
checkCrossOrigin(exampleOrg, nullPrin);
@ -204,7 +204,7 @@ function run_test() {
}
checkKind(ssm.createNullPrincipal({}), 'nullPrincipal');
checkKind(ssm.createCodebasePrincipal(makeURI('http://www.example.com'), {}), 'codebasePrincipal');
checkKind(ssm.createExpandedPrincipal([ssm.createCodebasePrincipal(makeURI('http://www.example.com'), {})]), 'expandedPrincipal');
checkKind(Cu.getObjectPrincipal(Cu.Sandbox([ssm.createCodebasePrincipal(makeURI('http://www.example.com'), {})])), 'expandedPrincipal');
checkKind(ssm.getSystemPrincipal(), 'systemPrincipal');
//

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

@ -170,7 +170,7 @@ add_task(function* test_stringify_inaccessible() {
add_task(function* test_stringify_accessible() {
// Test that an accessible property from another global is included
let principal = ssm.createExpandedPrincipal([PRINCIPAL1, PRINCIPAL2]);
let principal = Cu.getObjectPrincipal(Cu.Sandbox([PRINCIPAL1, PRINCIPAL2]));
let context = new Context(principal);
let sandbox = context.sandbox;
let sandbox2 = Cu.Sandbox(PRINCIPAL2);