Bug 1464374 part 7 - Use GetRealmPrincipals in GetCompartmentName. r=luke
authorJan de Mooij <jdemooij@mozilla.com>
Thu, 31 May 2018 11:28:49 +0200
changeset 474900 99519e97491ace324da0aef8a2d9d95ab7b74c68
parent 474899 f520a79d0bc1d4bb49ac1a227340a3bb01e409bb
child 474901 70d2a0e0153366c4cb9d5cebdd0352938c70ee79
push id9374
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:43:20 +0000
treeherdermozilla-beta@160e085dfb0b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs1464374
milestone62.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 1464374 part 7 - Use GetRealmPrincipals in GetCompartmentName. r=luke This will become GetRealmName at some point.
js/xpconnect/src/XPCJSRuntime.cpp
--- a/js/xpconnect/src/XPCJSRuntime.cpp
+++ b/js/xpconnect/src/XPCJSRuntime.cpp
@@ -1072,22 +1072,23 @@ XPCJSRuntime::~XPCJSRuntime()
 }
 
 // If |*anonymizeID| is non-zero and this is a user compartment, the name will
 // be anonymized.
 static void
 GetCompartmentName(JSCompartment* c, nsCString& name, int* anonymizeID,
                    bool replaceSlashes)
 {
-    if (js::IsAtomsRealm(JS::GetRealmForCompartment(c))) {
+    JS::Realm* realm = JS::GetRealmForCompartment(c);
+    if (js::IsAtomsRealm(realm)) {
         name.AssignLiteral("atoms");
     } else if (*anonymizeID && !js::IsSystemCompartment(c)) {
         name.AppendPrintf("<anonymized-%d>", *anonymizeID);
         *anonymizeID += 1;
-    } else if (JSPrincipals* principals = JS_GetCompartmentPrincipals(c)) {
+    } else if (JSPrincipals* principals = JS::GetRealmPrincipals(realm)) {
         nsresult rv = nsJSPrincipals::get(principals)->GetScriptLocation(name);
         if (NS_FAILED(rv)) {
             name.AssignLiteral("(unknown)");
         }
 
         // If the compartment's location (name) differs from the principal's
         // script location, append the compartment's location to allow
         // differentiation of multiple compartments owned by the same principal