
JSObjectOps is not a supported API. Details of the API may change from one release to the next. This documentation should be considered SpiderMonkey internals documentation, not API documentation. See
bug 408416
.
The JSObjectOps.checkAccess determines whether a script may access a given property of an object.
typedef JSBool (*JSCheckAccessIdOp)(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode, jsval *vp, uintN *attrsp);
| Name | Type | Description |
|---|---|---|
cx |
JSContext * |
The context in which the property access attempt is happening. |
obj |
JSObject * |
The object whose properties the script is attempting to access. |
id |
jsid |
The name or index of the property the script is attempting to access. |
mode |
JSAccessMode |
The kind of property access being attempted. These flags are documented in JS_CheckAccess. |
vp |
jsval * |
Out parameter. On success, the callback sets *vp to the stored value of the property. |
attrsp |
uintN * |
Out parameter. On success, the callback sets *attrs to the property's attributes. |
It is the responsibility of each JSNative, JSFastNative or JSPropertyOp method, getter, or setter to call JS_CheckAccess if a security check is needed. The engine calls the checkAccess callback only in a few situations:
__proto__ or __parent__ property of an object;
__parent__ chain to determine which object is the global this;
caller property of functions;
import expression (in builds with JS_HAS_EXPORT_IMPORT);
JS_HAS_OBJ_WATCHPOINT);
constructor property of a function's prototype object.
The callback determines 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, and its attributes in *attrsp.
The native js_ObjectOps.checkAccess simply forwards to the object's JSClass.checkAccess, if it is non-null. Otherwise, it forwards to the runtime-wide object access callback (set with JS_SetCheckObjectAccessCallback).
See also JSClass.checkAccess.
Page last modified 19:46, 11 Apr 2008 by Jorend