Bug 1867190 - Add prefs for PHC probablities r=glandium
[gecko.git] / js / public / ShadowRealmCallbacks.h
blobbbd01b9d8cc6888ee2bce4418f09ab665e4abec7
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef js_ShadowReamCallbacks_h
7 #define js_ShadowReamCallbacks_h
9 #include "jstypes.h"
10 #include "js/RootingAPI.h"
11 #include "js/TypeDecls.h"
13 struct JS_PUBLIC_API JSContext;
15 namespace JS {
17 class RealmOptions;
19 using GlobalInitializeCallback = bool (*)(JSContext*, JS::Handle<JSObject*>);
21 // Install the HostInitializeShadowRealm callback that will be invoked when
22 // creating a shadow realm.
24 // The callback will be passed the realm's global object, so that it is possible
25 // for the embedding to make any host-determined manipulations to the global,
26 // such as installing interfaces or helpers that should exist even within
27 // ShadowRealms. (For example, in the web platform, WebIDL with the
28 // [Exposed=*] attribute should be installed within a shadow realm.)
29 extern JS_PUBLIC_API void SetShadowRealmInitializeGlobalCallback(
30 JSContext* cx, GlobalInitializeCallback callback);
32 using GlobalCreationCallback =
33 JSObject* (*)(JSContext* cx, JS::RealmOptions& creationOptions,
34 JSPrincipals* principals,
35 JS::Handle<JSObject*> enclosingGlobal);
37 // Create the Global object for a ShadowRealm.
39 // This isn't directly specified, however at least in Gecko, in order to
40 // correctly implement HostInitializeShadowRealm, there are requirements
41 // placed on the global for the ShadowRealm.
43 // This callback should return a Global object compatible with the
44 // callback installed by SetShadowRealmInitializeGlobalCallback
45 extern JS_PUBLIC_API void SetShadowRealmGlobalCreationCallback(
46 JSContext* cx, GlobalCreationCallback callback);
48 } // namespace JS
50 #endif // js_ShadowReamCallbacks_h