Changeset View
Changeset View
Standalone View
Standalone View
libraries/source/spidermonkey/include-win32-debug/js/Principals.h
Show All 12 Lines | |||||
#include <stdint.h> | #include <stdint.h> | ||||
#include "jspubtd.h" | #include "jspubtd.h" | ||||
#include "js/StructuredClone.h" | #include "js/StructuredClone.h" | ||||
namespace js { | namespace js { | ||||
struct PerformanceGroup; | struct JS_PUBLIC_API(PerformanceGroup); | ||||
} // namespace js | } // namespace js | ||||
struct JSPrincipals { | struct JSPrincipals { | ||||
/* Don't call "destroy"; use reference counting macros below. */ | /* Don't call "destroy"; use reference counting macros below. */ | ||||
mozilla::Atomic<int32_t> refcount; | mozilla::Atomic<int32_t> refcount; | ||||
#ifdef JS_DEBUG | #ifdef JS_DEBUG | ||||
/* A helper to facilitate principals debugging. */ | /* A helper to facilitate principals debugging. */ | ||||
Show All 20 Lines | # endif | ||||
*/ | */ | ||||
JS_PUBLIC_API(void) dump(); | JS_PUBLIC_API(void) dump(); | ||||
}; | }; | ||||
extern JS_PUBLIC_API(void) | extern JS_PUBLIC_API(void) | ||||
JS_HoldPrincipals(JSPrincipals* principals); | JS_HoldPrincipals(JSPrincipals* principals); | ||||
extern JS_PUBLIC_API(void) | extern JS_PUBLIC_API(void) | ||||
JS_DropPrincipals(JSRuntime* rt, JSPrincipals* principals); | JS_DropPrincipals(JSContext* cx, JSPrincipals* principals); | ||||
// Return whether the first principal subsumes the second. The exact meaning of | // Return whether the first principal subsumes the second. The exact meaning of | ||||
// 'subsumes' is left up to the browser. Subsumption is checked inside the JS | // 'subsumes' is left up to the browser. Subsumption is checked inside the JS | ||||
// engine when determining, e.g., which stack frames to display in a backtrace. | // engine when determining, e.g., which stack frames to display in a backtrace. | ||||
typedef bool | typedef bool | ||||
(* JSSubsumesOp)(JSPrincipals* first, JSPrincipals* second); | (* JSSubsumesOp)(JSPrincipals* first, JSPrincipals* second); | ||||
/* | /* | ||||
* Used to check if a CSP instance wants to disable eval() and friends. | * Used to check if a CSP instance wants to disable eval() and friends. | ||||
* See js_CheckCSPPermitsJSAction() in jsobj. | * See js_CheckCSPPermitsJSAction() in jsobj. | ||||
*/ | */ | ||||
typedef bool | typedef bool | ||||
(* JSCSPEvalChecker)(JSContext* cx); | (* JSCSPEvalChecker)(JSContext* cx); | ||||
struct JSSecurityCallbacks { | struct JSSecurityCallbacks { | ||||
JSCSPEvalChecker contentSecurityPolicyAllows; | JSCSPEvalChecker contentSecurityPolicyAllows; | ||||
JSSubsumesOp subsumes; | JSSubsumesOp subsumes; | ||||
}; | }; | ||||
extern JS_PUBLIC_API(void) | extern JS_PUBLIC_API(void) | ||||
JS_SetSecurityCallbacks(JSRuntime* rt, const JSSecurityCallbacks* callbacks); | JS_SetSecurityCallbacks(JSContext* cx, const JSSecurityCallbacks* callbacks); | ||||
extern JS_PUBLIC_API(const JSSecurityCallbacks*) | extern JS_PUBLIC_API(const JSSecurityCallbacks*) | ||||
JS_GetSecurityCallbacks(JSRuntime* rt); | JS_GetSecurityCallbacks(JSContext* cx); | ||||
/* | /* | ||||
* Code running with "trusted" principals will be given a deeper stack | * Code running with "trusted" principals will be given a deeper stack | ||||
* allocation than ordinary scripts. This allows trusted script to run after | * allocation than ordinary scripts. This allows trusted script to run after | ||||
* untrusted script has exhausted the stack. This function sets the | * untrusted script has exhausted the stack. This function sets the | ||||
* runtime-wide trusted principal. | * runtime-wide trusted principal. | ||||
* | * | ||||
* This principals is not held (via JS_HoldPrincipals/JS_DropPrincipals) since | * This principals is not held (via JS_HoldPrincipals/JS_DropPrincipals). | ||||
* there is no available JSContext. Instead, the caller must ensure that the | * Instead, the caller must ensure that the given principals stays valid for as | ||||
* given principals stays valid for as long as 'rt' may point to it. If the | * long as 'cx' may point to it. If the principals would be destroyed before | ||||
* principals would be destroyed before 'rt', JS_SetTrustedPrincipals must be | * 'cx', JS_SetTrustedPrincipals must be called again, passing nullptr for | ||||
* called again, passing nullptr for 'prin'. | * 'prin'. | ||||
*/ | */ | ||||
extern JS_PUBLIC_API(void) | extern JS_PUBLIC_API(void) | ||||
JS_SetTrustedPrincipals(JSRuntime* rt, JSPrincipals* prin); | JS_SetTrustedPrincipals(JSContext* cx, JSPrincipals* prin); | ||||
typedef void | typedef void | ||||
(* JSDestroyPrincipalsOp)(JSPrincipals* principals); | (* JSDestroyPrincipalsOp)(JSPrincipals* principals); | ||||
/* | /* | ||||
* Initialize the callback that is called to destroy JSPrincipals instance | * Initialize the callback that is called to destroy JSPrincipals instance | ||||
* when its reference counter drops to zero. The initialization can be done | * when its reference counter drops to zero. The initialization can be done | ||||
* only once per JS runtime. | * only once per JS runtime. | ||||
*/ | */ | ||||
extern JS_PUBLIC_API(void) | extern JS_PUBLIC_API(void) | ||||
JS_InitDestroyPrincipalsCallback(JSRuntime* rt, JSDestroyPrincipalsOp destroyPrincipals); | JS_InitDestroyPrincipalsCallback(JSContext* cx, JSDestroyPrincipalsOp destroyPrincipals); | ||||
/* | /* | ||||
* Read a JSPrincipals instance from the given |reader| and initialize the out | * Read a JSPrincipals instance from the given |reader| and initialize the out | ||||
* paratemer |outPrincipals| to the JSPrincipals instance read. | * paratemer |outPrincipals| to the JSPrincipals instance read. | ||||
* | * | ||||
* Return false on failure, true on success. The |outPrincipals| parameter | * Return false on failure, true on success. The |outPrincipals| parameter | ||||
* should not be modified if false is returned. | * should not be modified if false is returned. | ||||
* | * | ||||
* The caller is not responsible for calling JS_HoldPrincipals on the resulting | * The caller is not responsible for calling JS_HoldPrincipals on the resulting | ||||
* JSPrincipals instance, the JSReadPrincipalsOp must increment the refcount of | * JSPrincipals instance, the JSReadPrincipalsOp must increment the refcount of | ||||
* the resulting JSPrincipals on behalf of the caller. | * the resulting JSPrincipals on behalf of the caller. | ||||
*/ | */ | ||||
using JSReadPrincipalsOp = bool (*)(JSContext* cx, JSStructuredCloneReader* reader, | using JSReadPrincipalsOp = bool (*)(JSContext* cx, JSStructuredCloneReader* reader, | ||||
JSPrincipals** outPrincipals); | JSPrincipals** outPrincipals); | ||||
/* | /* | ||||
* Initialize the callback that is called to read JSPrincipals instances from a | * Initialize the callback that is called to read JSPrincipals instances from a | ||||
* buffer. The initialization can be done only once per JS runtime. | * buffer. The initialization can be done only once per JS runtime. | ||||
*/ | */ | ||||
extern JS_PUBLIC_API(void) | extern JS_PUBLIC_API(void) | ||||
JS_InitReadPrincipalsCallback(JSRuntime* rt, JSReadPrincipalsOp read); | JS_InitReadPrincipalsCallback(JSContext* cx, JSReadPrincipalsOp read); | ||||
#endif /* js_Principals_h */ | #endif /* js_Principals_h */ |
Wildfire Games · Phabricator