Mozilla.com

  1. MDC
  2. Main Page
  3. SpiderMonkey
  4. JSAPI Reference
  5. JSObjectOps.checkAccess
Table of contents
  1. 1. Syntax
  2. 2. Description
Redirected from En/JSCheckAccessIdOp

JSObjectOps.checkAccess

Table of contents
  1. 1. Syntax
  2. 2. Description

Warning sign
Warning: 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.

Syntax

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.

Description

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:

  • before calling a scripted getter or setter;
  • when defining a script getter or setter on an object;
  • when a script attempts to get or set the __proto__ or __parent__ property of an object;
  • when the JavaScript engine walks an object's __parent__ chain to determine which object is the global this;
  • when generating a stack trace for an exception, when accessing the caller property of functions;
  • when evaluating an import expression (in builds with JS_HAS_EXPORT_IMPORT);
  • when a script attempts to set a watchpoint (in builds with JS_HAS_OBJ_WATCHPOINT);
  • when accessing the 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

Files (0)