Bug 1527443. Add a way to create a new Realm in a given compartment. r=jandem
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 13 Feb 2019 08:42:45 +0000
changeset 458884 216b765364a3
parent 458883 56575ed63592
child 458885 a5ad662d5bbb
push id35551
push usershindli@mozilla.com
push dateWed, 13 Feb 2019 21:34:09 +0000
treeherdermozilla-central@08f794a4928e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1527443
milestone67.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 1527443. Add a way to create a new Realm in a given compartment. r=jandem Differential Revision: https://phabricator.services.mozilla.com/D19566
js/src/jsapi.cpp
js/src/jsapi.h
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -1573,16 +1573,23 @@ JS::RealmCreationOptions::setNewCompartm
 
 JS::RealmCreationOptions& JS::RealmCreationOptions::setExistingCompartment(
     JSObject* obj) {
   compSpec_ = CompartmentSpecifier::ExistingCompartment;
   comp_ = obj->compartment();
   return *this;
 }
 
+JS::RealmCreationOptions& JS::RealmCreationOptions::setExistingCompartment(
+    JS::Compartment* compartment) {
+  compSpec_ = CompartmentSpecifier::ExistingCompartment;
+  comp_ = compartment;
+  return *this;
+}
+
 JS::RealmCreationOptions& JS::RealmCreationOptions::setNewCompartmentAndZone() {
   compSpec_ = CompartmentSpecifier::NewCompartmentAndZone;
   comp_ = nullptr;
   return *this;
 }
 
 const JS::RealmCreationOptions& JS::RealmCreationOptionsRef(Realm* realm) {
   return realm->creationOptions();
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -967,16 +967,17 @@ class JS_PUBLIC_API RealmCreationOptions
   CompartmentSpecifier compartmentSpecifier() const { return compSpec_; }
 
   // Set the compartment/zone to use for the realm. See CompartmentSpecifier
   // above.
   RealmCreationOptions& setNewCompartmentInSystemZone();
   RealmCreationOptions& setNewCompartmentInExistingZone(JSObject* obj);
   RealmCreationOptions& setNewCompartmentAndZone();
   RealmCreationOptions& setExistingCompartment(JSObject* obj);
+  RealmCreationOptions& setExistingCompartment(JS::Compartment* compartment);
 
   // Certain compartments are implementation details of the embedding, and
   // references to them should never leak out to script. This flag causes this
   // realm to skip firing onNewGlobalObject and makes addDebuggee a no-op for
   // this global.
   //
   // Debugger visibility is per-compartment, not per-realm (it's only practical
   // to enforce visibility on compartment boundaries), so if a realm is being