mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-09 09:18:42 +09:00
Issue #1691 - Part 7a: Add a JS API to get the private value for the calling script or module. https://bugzilla.mozilla.org/show_bug.cgi?id=1342012
(cherry picked from commit e89e50d5047468e0bb02ee82f9cd0be282b24a1b)
This commit is contained in:
parent
e7d0b58e56
commit
62be542166
2 changed files with 21 additions and 0 deletions
|
|
@ -4771,6 +4771,20 @@ JS::GetScriptPrivate(JSScript* script)
|
|||
return script->scriptSourceUnwrap().canonicalPrivate();
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JS::Value)
|
||||
JS::GetScriptedCallerPrivate(JSContext* cx)
|
||||
{
|
||||
AssertHeapIsIdle(cx);
|
||||
CHECK_REQUEST(cx);
|
||||
|
||||
NonBuiltinFrameIter iter(cx, cx->compartment()->principals());
|
||||
if (iter.done() || !iter.hasScript()) {
|
||||
return UndefinedValue();
|
||||
}
|
||||
|
||||
return FindScriptOrModulePrivateForScript(iter.script());
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JS::ScriptPrivateFinalizeHook)
|
||||
JS::GetScriptPrivateFinalizeHook(JSContext* cx)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4410,6 +4410,13 @@ SetScriptPrivate(JSScript* script, const JS::Value& value);
|
|||
extern JS_PUBLIC_API(JS::Value)
|
||||
GetScriptPrivate(JSScript* script);
|
||||
|
||||
/*
|
||||
* Return the private value associated with currently executing script or
|
||||
* module, or undefined if there is no such script.
|
||||
*/
|
||||
extern JS_PUBLIC_API(JS::Value)
|
||||
GetScriptedCallerPrivate(JSContext* cx);
|
||||
|
||||
/**
|
||||
* A hook that's called whenever a script or module which has a private value
|
||||
* set with SetScriptPrivate() or SetModulePrivate() is finalized. This can be
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue