Bug 1472976 part 5 - Use xpc::GetRealmPrincipal instead of xpc::GetCompartmentPrincipal in xpc::GetObjectPrincipal. r=mrbkap
authorJan de Mooij <jdemooij@mozilla.com>
Fri, 10 Aug 2018 11:57:40 +0200
changeset 430966 efacd0e6ef9b0007aac034bf2cea86c07590db2d
parent 430965 7f26ac88d55c5ccce39797522473369b243455b2
child 430967 3c3a7d2137942e8b839e8c3f44e1d9a7474a4873
push id34417
push usernbeleuzu@mozilla.com
push dateFri, 10 Aug 2018 16:00:49 +0000
treeherdermozilla-central@61e553ff703e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs1472976
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1472976 part 5 - Use xpc::GetRealmPrincipal instead of xpc::GetCompartmentPrincipal in xpc::GetObjectPrincipal. r=mrbkap
js/xpconnect/src/xpcprivate.h
js/xpconnect/wrappers/AccessCheck.cpp
--- a/js/xpconnect/src/xpcprivate.h
+++ b/js/xpconnect/src/xpcprivate.h
@@ -3061,16 +3061,18 @@ ObjectScope(JSObject* obj)
     return RealmPrivate::Get(obj)->scope;
 }
 
 JSObject* NewOutObject(JSContext* cx);
 bool IsOutObject(JSContext* cx, JSObject* obj);
 
 nsresult HasInstance(JSContext* cx, JS::HandleObject objArg, const nsID* iid, bool* bp);
 
+// Returns the principal associated with |obj|'s realm. The object must not be a
+// cross-compartment wrapper.
 nsIPrincipal* GetObjectPrincipal(JSObject* obj);
 
 // Attempt to clean up the passed in value pointer. The pointer `value` must be
 // a pointer to a value described by the type `nsXPTType`.
 //
 // This method expects a value of the following types:
 //   TD_PNSIID
 //     value : nsID* (free)
--- a/js/xpconnect/wrappers/AccessCheck.cpp
+++ b/js/xpconnect/wrappers/AccessCheck.cpp
@@ -40,17 +40,17 @@ nsIPrincipal*
 GetRealmPrincipal(JS::Realm* realm)
 {
     return nsJSPrincipals::get(JS::GetRealmPrincipals(realm));
 }
 
 nsIPrincipal*
 GetObjectPrincipal(JSObject* obj)
 {
-    return GetCompartmentPrincipal(js::GetObjectCompartment(obj));
+    return GetRealmPrincipal(js::GetNonCCWObjectRealm(obj));
 }
 
 // Does the principal of compartment a subsume the principal of compartment b?
 bool
 AccessCheck::subsumes(JS::Compartment* a, JS::Compartment* b)
 {
     nsIPrincipal* aprin = GetCompartmentPrincipal(a);
     nsIPrincipal* bprin = GetCompartmentPrincipal(b);