JSCheckAccessOp 编辑
Obsolete since JSAPI 29
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.
JSCheckAccessOp
is the type for JSClass.checkAccess
. (It is also the type of the callback set by JS_SetCheckObjectAccessCallback
.)
Syntax
typedef JSBool
(* JSCheckAccessOp)(JSContext *cx, JSObject *obj, jsval id,
JSAccessMode mode, jsval *vp);
Name | Type | Description |
---|---|---|
cx | JSContext * | The JS context in which the property access attempt is occurring. |
obj | JSObject * | The object whose properties are being accessed. |
id | jsval | The name or index of the property being accessed. |
mode | JSAccessMode | The type of access being checked. |
vp | jsval * | Out parameter. On success, the callback must set *vp to the stored value of the property. |
Description
Check whether obj[id]
may be accessed per mode
, returning JS_FALSE
on error/exception, JS_TRUE
on success with obj[id]
's stored value in *vp
. As for JSPropertyOp
, id
is either a string or an int jsval
.
JSCheckAccessOp
implementations generally work by using JSDBGAPI functions such as JS_FrameIterator
and JS_StackFramePrincipals
to obtain the principals of the code attempting the checked operation, then examining those principals and comparing them with the system's security policy. The nature of principals and the security policy are entirely up to the application.
If a class leaves the checkAccess
field NULL
, a runtime-wide object access callback is called instead; see JS_SetCheckObjectAccessCallback
.
JSClass hooks
JSClass
offers the following hook:
The
JSClass.checkAccess
callback is called when a script attempts to access an object property. The callback can deny the script access to the property.
See Also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论