mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-16 23:05:42 +00:00
Bug 1711078 - Part 1: Stop using the component manager to create non-system principals, r=ckerschb
This is necessary to remove the Init methods from principals, allowing immutable fields to be marked as const and clearly separated from mutable fields to improve threadsafety. Differential Revision: https://phabricator.services.mozilla.com/D115091
This commit is contained in:
parent
a10753402f
commit
c2a86c631c
@ -81,7 +81,6 @@ class ContentPrincipal final : public BasePrincipal {
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#define NS_PRINCIPAL_CONTRACTID "@mozilla.org/principal;1"
|
||||
#define NS_PRINCIPAL_CID \
|
||||
{ \
|
||||
0x653e0e4d, 0x3ee4, 0x45fa, { \
|
||||
|
@ -84,7 +84,6 @@ class ExpandedPrincipal : public nsIExpandedPrincipal,
|
||||
nsCOMPtr<nsIContentSecurityPolicy> mCSP;
|
||||
};
|
||||
|
||||
#define NS_EXPANDEDPRINCIPAL_CONTRACTID "@mozilla.org/expandedprincipal;1"
|
||||
#define NS_EXPANDEDPRINCIPAL_CID \
|
||||
{ \
|
||||
0xe8ee88b0, 0x5571, 0x4086, { \
|
||||
|
@ -31,7 +31,6 @@ class Value;
|
||||
0x83, 0x31, 0x7b, 0xfd, 0x05, 0xb1, 0xed, 0x90 \
|
||||
} \
|
||||
}
|
||||
#define NS_NULLPRINCIPAL_CONTRACTID "@mozilla.org/nullprincipal;1"
|
||||
|
||||
#define NS_NULLPRINCIPAL_SCHEME "moz-nullprincipal"
|
||||
|
||||
|
@ -280,7 +280,7 @@ function check_prototype(
|
||||
}
|
||||
|
||||
function createNullPrincipal() {
|
||||
return Cc["@mozilla.org/nullprincipal;1"].createInstance(Ci.nsIPrincipal);
|
||||
return Services.scriptSecurityManager.createNullPrincipal({});
|
||||
}
|
||||
|
||||
async function run_tests_in_principal(
|
||||
|
@ -416,9 +416,7 @@ add_task(
|
||||
)
|
||||
);
|
||||
|
||||
const nullPrincipal = Cc["@mozilla.org/nullprincipal;1"].createInstance(
|
||||
Ci.nsIPrincipal
|
||||
);
|
||||
const nullPrincipal = Services.scriptSecurityManager.createNullPrincipal({});
|
||||
add_task(
|
||||
threadFrontTest(
|
||||
options => {
|
||||
|
@ -2883,7 +2883,7 @@ already_AddRefed<nsIPrincipal> Document::MaybeDowngradePrincipal(
|
||||
auto* parentWin = nsGlobalWindowOuter::Cast(parent->GetDOMWindow());
|
||||
if (!parentWin || !parentWin->GetPrincipal()->IsSystemPrincipal()) {
|
||||
nsCOMPtr<nsIPrincipal> nullPrincipal =
|
||||
do_CreateInstance("@mozilla.org/nullprincipal;1");
|
||||
NullPrincipal::CreateWithoutOriginAttributes();
|
||||
return nullPrincipal.forget();
|
||||
}
|
||||
}
|
||||
|
@ -10,8 +10,7 @@
|
||||
<script type="application/javascript">
|
||||
"use strict";
|
||||
|
||||
var permManager = Cc["@mozilla.org/permissionmanager;1"]
|
||||
.getService(Ci.nsIPermissionManager);
|
||||
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
@ -85,14 +84,12 @@
|
||||
|
||||
mm.sendAsyncMessage("test:content", window.document.nodePrincipal);
|
||||
|
||||
let system = Cc["@mozilla.org/systemprincipal;1"].
|
||||
createInstance(Ci.nsIPrincipal);
|
||||
let system = Services.scriptSecurityManager.getSystemPrincipal();
|
||||
mm.sendAsyncMessage("test:system", system);
|
||||
|
||||
mm.sendAsyncMessage("test:ep", ep);
|
||||
|
||||
let nullP = Cc["@mozilla.org/nullprincipal;1"].
|
||||
createInstance(Ci.nsIPrincipal);
|
||||
let nullP = Services.scriptSecurityManager.createNullPrincipal({});
|
||||
mm.sendAsyncMessage("test:null", nullP);
|
||||
});
|
||||
|
||||
|
@ -1,10 +1,11 @@
|
||||
// Test calling SavedFrame getters across wrappers from privileged and
|
||||
// un-privileged globals.
|
||||
|
||||
const {Services} = ChromeUtils.import('resource://gre/modules/Services.jsm');
|
||||
const {addDebuggerToGlobal} = ChromeUtils.import("resource://gre/modules/jsdebugger.jsm");
|
||||
addDebuggerToGlobal(this);
|
||||
|
||||
const lowP = Cc["@mozilla.org/nullprincipal;1"].createInstance(Ci.nsIPrincipal);
|
||||
const lowP = Services.scriptSecurityManager.createNullPrincipal({});
|
||||
const highP = Cc["@mozilla.org/systemprincipal;1"].createInstance(Ci.nsIPrincipal);
|
||||
|
||||
const low = new Cu.Sandbox(lowP);
|
||||
|
@ -1,10 +1,11 @@
|
||||
// Bug 1117242: Test calling SavedFrame getters from globals that don't subsume
|
||||
// that frame's principals.
|
||||
|
||||
const {Services} = ChromeUtils.import('resource://gre/modules/Services.jsm');
|
||||
const {addDebuggerToGlobal} = ChromeUtils.import("resource://gre/modules/jsdebugger.jsm");
|
||||
addDebuggerToGlobal(this);
|
||||
|
||||
const lowP = Cc["@mozilla.org/nullprincipal;1"].createInstance(Ci.nsIPrincipal);
|
||||
const lowP = Services.scriptSecurityManager.createNullPrincipal({});
|
||||
const midP = [lowP, "http://other.com"];
|
||||
const highP = Cc["@mozilla.org/systemprincipal;1"].createInstance(Ci.nsIPrincipal);
|
||||
|
||||
|
@ -209,7 +209,7 @@ Classes = [
|
||||
},
|
||||
{
|
||||
'cid': '{e8ee88b0-5571-4086-a45b-39a716906bdb}',
|
||||
'contract_ids': ['@mozilla.org/expandedprincipal;1'],
|
||||
'contract_ids': [],
|
||||
'type': 'ExpandedPrincipal',
|
||||
'headers': ['/caps/ExpandedPrincipal.h'],
|
||||
},
|
||||
@ -333,10 +333,9 @@ Classes = [
|
||||
},
|
||||
{
|
||||
'cid': '{bd066e5f-146f-4472-8331-7bfd05b1ed90}',
|
||||
'contract_ids': ['@mozilla.org/nullprincipal;1'],
|
||||
'contract_ids': [],
|
||||
'type': 'mozilla::NullPrincipal',
|
||||
'headers': ['/caps/NullPrincipal.h'],
|
||||
'init_method': 'Init',
|
||||
},
|
||||
{
|
||||
'js_name': 'ppmm',
|
||||
@ -352,7 +351,7 @@ Classes = [
|
||||
},
|
||||
{
|
||||
'cid': '{653e0e4d-3ee4-45fa-b272-97c20bc01eb8}',
|
||||
'contract_ids': ['@mozilla.org/principal;1'],
|
||||
'contract_ids': [],
|
||||
'type': 'mozilla::ContentPrincipal',
|
||||
'headers': ['/caps/ContentPrincipal.h'],
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user