summaryrefslogtreecommitdiffstats
path: root/js/public/ShadowRealmCallbacks.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/public/ShadowRealmCallbacks.h
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/public/ShadowRealmCallbacks.h')
-rw-r--r--js/public/ShadowRealmCallbacks.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/js/public/ShadowRealmCallbacks.h b/js/public/ShadowRealmCallbacks.h
new file mode 100644
index 0000000000..bbd01b9d8c
--- /dev/null
+++ b/js/public/ShadowRealmCallbacks.h
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef js_ShadowReamCallbacks_h
+#define js_ShadowReamCallbacks_h
+
+#include "jstypes.h"
+#include "js/RootingAPI.h"
+#include "js/TypeDecls.h"
+
+struct JS_PUBLIC_API JSContext;
+
+namespace JS {
+
+class RealmOptions;
+
+using GlobalInitializeCallback = bool (*)(JSContext*, JS::Handle<JSObject*>);
+
+// Install the HostInitializeShadowRealm callback that will be invoked when
+// creating a shadow realm.
+//
+// The callback will be passed the realm's global object, so that it is possible
+// for the embedding to make any host-determined manipulations to the global,
+// such as installing interfaces or helpers that should exist even within
+// ShadowRealms. (For example, in the web platform, WebIDL with the
+// [Exposed=*] attribute should be installed within a shadow realm.)
+extern JS_PUBLIC_API void SetShadowRealmInitializeGlobalCallback(
+ JSContext* cx, GlobalInitializeCallback callback);
+
+using GlobalCreationCallback =
+ JSObject* (*)(JSContext* cx, JS::RealmOptions& creationOptions,
+ JSPrincipals* principals,
+ JS::Handle<JSObject*> enclosingGlobal);
+
+// Create the Global object for a ShadowRealm.
+//
+// This isn't directly specified, however at least in Gecko, in order to
+// correctly implement HostInitializeShadowRealm, there are requirements
+// placed on the global for the ShadowRealm.
+//
+// This callback should return a Global object compatible with the
+// callback installed by SetShadowRealmInitializeGlobalCallback
+extern JS_PUBLIC_API void SetShadowRealmGlobalCreationCallback(
+ JSContext* cx, GlobalCreationCallback callback);
+
+} // namespace JS
+
+#endif // js_ShadowReamCallbacks_h