Bug 1465728 part 3 - Rename Cu.getCompartmentLocation to Cu.getRealmLocation. r=bz
authorJan de Mooij <jdemooij@mozilla.com>
Wed, 06 Jun 2018 11:44:17 +0200
changeset 421579 ff7f3a604779d591ac9e451cf6db71e1be3933f4
parent 421578 84aa50d4663a10d18cb305b9157134139f4cc867
child 421580 11aacf3b7e93135523e0bd45f5d1b658ebd99a07
push id34098
push usernbeleuzu@mozilla.com
push dateWed, 06 Jun 2018 17:00:32 +0000
treeherdermozilla-central@04cc917f68c5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1465728
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 1465728 part 3 - Rename Cu.getCompartmentLocation to Cu.getRealmLocation. r=bz
dom/base/test/chrome/cpows_child.js
dom/base/test/chrome/cpows_parent.xul
js/xpconnect/idl/xpccomponents.idl
js/xpconnect/src/XPCComponents.cpp
--- a/dom/base/test/chrome/cpows_child.js
+++ b/dom/base/test/chrome/cpows_child.js
@@ -179,17 +179,17 @@ function compartment_test(finish)
 
   let sb = Cu.Sandbox('http://www.example.com', { wantGlobalProperties: ['XMLHttpRequest'] });
   sb.eval('function getUnprivilegedObject() { var xhr = new XMLHttpRequest(); xhr.expando = 42; return xhr; }');
   function testParentObject(obj) {
     let results = [];
     function is(a, b, msg) { results.push({ result: a === b ? "PASS" : "FAIL", message: msg }) };
     function ok(x, msg) { results.push({ result: x ? "PASS" : "FAIL", message: msg }) };
 
-    let cpowLocation = Cu.getCompartmentLocation(obj);
+    let cpowLocation = Cu.getRealmLocation(obj);
     ok(/Privileged Junk/.test(cpowLocation),
        "child->parent CPOWs should live in the privileged junk scope: " + cpowLocation);
     is(obj(), 42, "child->parent CPOW is invokable");
     try {
       obj.expando;
       ok(false, "child->parent CPOW cannot access properties");
     } catch (e) {
       ok(true, "child->parent CPOW cannot access properties");
--- a/dom/base/test/chrome/cpows_parent.xul
+++ b/dom/base/test/chrome/cpows_parent.xul
@@ -296,17 +296,17 @@
       let getUnprivilegedObject = message.objects.getUnprivilegedObject;
       let testParentObject = message.objects.testParentObject;
 
       // Make sure that parent->child CPOWs live in the parent's privileged junk scope.
       let unprivilegedObject = getUnprivilegedObject();
       is(Cu.getGlobalForObject(getUnprivilegedObject),
          Cu.getGlobalForObject(unprivilegedObject),
          "all parent->child CPOWs should live in the same scope");
-      let cpowLocation = Cu.getCompartmentLocation(getUnprivilegedObject);
+      let cpowLocation = Cu.getRealmLocation(getUnprivilegedObject);
       ok(/Privileged Junk/.test(cpowLocation),
          "parent->child CPOWs should live in the privileged junk scope: " + cpowLocation);
 
       // Make sure that parent->child CPOWs point through a privileged scope in the child
       // (the privileged junk scope, but we don't have a good way to test for that
       // specifically).
       is(unprivilegedObject.expando, undefined, "parent->child references should get Xrays");
       is(unprivilegedObject.wrappedJSObject.expando, 42, "parent->child references should get waivable Xrays");
--- a/js/xpconnect/idl/xpccomponents.idl
+++ b/js/xpconnect/idl/xpccomponents.idl
@@ -646,25 +646,25 @@ interface nsIXPCComponents_Utils : nsISu
      * Gets the principal of a script object, after unwrapping any cross-
      * compartment wrappers.
      */
     [implicit_jscontext]
     nsIPrincipal getObjectPrincipal(in jsval obj);
 
     /*
      * Gets the URI or identifier string associated with an object's
-     * compartment (the same one used by the memory reporter machinery).
+     * realm (the same one used by the memory reporter machinery).
      *
      * Unwraps cross-compartment wrappers first.
      *
      * The string formats and values may change at any time. Do not depend on
      * this from addon code.
      */
     [implicit_jscontext]
-    ACString getCompartmentLocation(in jsval obj);
+    ACString getRealmLocation(in jsval obj);
 
     /*
      * Return a fractional number of milliseconds from process
      * startup, measured with a monotonic clock.
      */
     double now();
 
     /*
--- a/js/xpconnect/src/XPCComponents.cpp
+++ b/js/xpconnect/src/XPCComponents.cpp
@@ -3006,19 +3006,19 @@ nsXPCComponents_Utils::GetObjectPrincipa
     MOZ_ASSERT(obj);
 
     nsCOMPtr<nsIPrincipal> prin = nsContentUtils::ObjectPrincipal(obj);
     prin.forget(result);
     return NS_OK;
 }
 
 NS_IMETHODIMP
-nsXPCComponents_Utils::GetCompartmentLocation(HandleValue val,
-                                              JSContext* cx,
-                                              nsACString& result)
+nsXPCComponents_Utils::GetRealmLocation(HandleValue val,
+                                        JSContext* cx,
+                                        nsACString& result)
 {
     if (!val.isObject())
         return NS_ERROR_INVALID_ARG;
     RootedObject obj(cx, &val.toObject());
     obj = js::CheckedUnwrap(obj);
     MOZ_ASSERT(obj);
 
     result = xpc::RealmPrivate::Get(obj)->GetLocation();