Package org.htmlunit.corejs.javascript
Class NativeProxy
- java.lang.Object
-
- org.htmlunit.corejs.javascript.ScriptableObject
-
- org.htmlunit.corejs.javascript.NativeProxy
-
- All Implemented Interfaces:
java.io.Serializable
,Callable
,ConstProperties
,Constructable
,DebuggableObject
,Scriptable
,SymbolScriptable
final class NativeProxy extends ScriptableObject implements Callable, Constructable
This class implements the Proxy object.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
NativeProxy.Revoker
-
Nested classes/interfaces inherited from class org.htmlunit.corejs.javascript.ScriptableObject
ScriptableObject.KeyComparator
-
-
Field Summary
Fields Modifier and Type Field Description private Scriptable
handlerObj
private static java.lang.String
PROXY_TAG
private static long
serialVersionUID
private ScriptableObject
targetObj
private static java.lang.String
TRAP_APPLY
private static java.lang.String
TRAP_CONSTRUCT
private static java.lang.String
TRAP_DEFINE_PROPERTY
private static java.lang.String
TRAP_DELETE_PROPERTY
private static java.lang.String
TRAP_GET
private static java.lang.String
TRAP_GET_OWN_PROPERTY_DESCRIPTOR
private static java.lang.String
TRAP_GET_PROTOTYPE_OF
private static java.lang.String
TRAP_HAS
private static java.lang.String
TRAP_IS_EXTENSIBLE
private static java.lang.String
TRAP_OWN_KEYS
private static java.lang.String
TRAP_PREVENT_EXTENSIONS
private static java.lang.String
TRAP_SET
private static java.lang.String
TRAP_SET_PROTOTYPE_OF
private java.lang.String
typeOf
-
Fields inherited from class org.htmlunit.corejs.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST
-
Fields inherited from interface org.htmlunit.corejs.javascript.Scriptable
NOT_FOUND
-
-
Constructor Summary
Constructors Modifier Constructor Description private
NativeProxy(ScriptableObject target, Scriptable handler)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
call(Context cx, Scriptable scope, Scriptable thisObj, java.lang.Object[] args)
see https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-call-thisargument-argumentslistprivate java.lang.Object
callTrap(Callable trap, java.lang.Object[] args)
Scriptable
construct(Context cx, Scriptable scope, java.lang.Object[] args)
see https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-construct-argumentslist-newtargetprivate static NativeProxy
constructor(Context cx, Scriptable scope, java.lang.Object[] args)
boolean
defineOwnProperty(Context cx, java.lang.Object id, ScriptableObject desc)
see https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-defineownproperty-p-descvoid
delete(int index)
see https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-delete-pvoid
delete(java.lang.String name)
see https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-delete-pvoid
delete(Symbol key)
see https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-delete-pjava.lang.Object
get(int index, Scriptable start)
see https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-get-p-receiverjava.lang.Object
get(java.lang.String name, Scriptable start)
see https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-get-p-receiverjava.lang.Object
get(Symbol key, Scriptable start)
see https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-get-p-receiverjava.lang.String
getClassName()
Return the name of the class.(package private) java.lang.Object[]
getIds(boolean getNonEnumerable, boolean getSymbols)
see https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeysprotected ScriptableObject
getOwnPropertyDescriptor(Context cx, java.lang.Object id)
see https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-getownproperty-pScriptable
getPrototype()
see https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-getprototypeof(package private) ScriptableObject
getTargetThrowIfRevoked()
private Callable
getTrap(java.lang.String trapName)
java.lang.String
getTypeOf()
Gets the value that will be returned by calling the typeof operator on this object.boolean
has(int index, Scriptable start)
see https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-hasproperty-pboolean
has(java.lang.String name, Scriptable start)
https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-hasproperty-pboolean
has(Symbol key, Scriptable start)
see https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-hasproperty-pstatic void
init(Context cx, Scriptable scope, boolean sealed)
boolean
isExtensible()
see https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-isextensibleboolean
preventExtensions()
see https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-preventextensionsvoid
put(int index, Scriptable start, java.lang.Object value)
https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-set-p-v-receivervoid
put(java.lang.String name, Scriptable start, java.lang.Object value)
https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-set-p-v-receivervoid
put(Symbol key, Scriptable start, java.lang.Object value)
https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-set-p-v-receiverprivate static java.lang.Object
revocable(Context cx, Scriptable scope, Scriptable thisObj, java.lang.Object[] args)
void
setPrototype(Scriptable prototype)
see https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-setprototypeof-vprivate void
setPrototypeDirect(Scriptable prototype)
-
Methods inherited from class org.htmlunit.corejs.javascript.ScriptableObject
addLazilyInitializedValue, applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildClassCtor, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, checkValidAttributes, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureSymbolScriptable, equivalentValues, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getBase, getBase, getClassPrototype, getDefaultValue, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getIds, getObjectPrototype, getParentScope, getProperty, getProperty, getProperty, getPropertyIds, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, hasInstance, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, putConst, putConstProperty, putImpl, putProperty, putProperty, putProperty, querySlot, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setParentScope, size
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
PROXY_TAG
private static final java.lang.String PROXY_TAG
- See Also:
- Constant Field Values
-
TRAP_GET_PROTOTYPE_OF
private static final java.lang.String TRAP_GET_PROTOTYPE_OF
- See Also:
- Constant Field Values
-
TRAP_SET_PROTOTYPE_OF
private static final java.lang.String TRAP_SET_PROTOTYPE_OF
- See Also:
- Constant Field Values
-
TRAP_IS_EXTENSIBLE
private static final java.lang.String TRAP_IS_EXTENSIBLE
- See Also:
- Constant Field Values
-
TRAP_PREVENT_EXTENSIONS
private static final java.lang.String TRAP_PREVENT_EXTENSIONS
- See Also:
- Constant Field Values
-
TRAP_GET_OWN_PROPERTY_DESCRIPTOR
private static final java.lang.String TRAP_GET_OWN_PROPERTY_DESCRIPTOR
- See Also:
- Constant Field Values
-
TRAP_DEFINE_PROPERTY
private static final java.lang.String TRAP_DEFINE_PROPERTY
- See Also:
- Constant Field Values
-
TRAP_HAS
private static final java.lang.String TRAP_HAS
- See Also:
- Constant Field Values
-
TRAP_GET
private static final java.lang.String TRAP_GET
- See Also:
- Constant Field Values
-
TRAP_SET
private static final java.lang.String TRAP_SET
- See Also:
- Constant Field Values
-
TRAP_DELETE_PROPERTY
private static final java.lang.String TRAP_DELETE_PROPERTY
- See Also:
- Constant Field Values
-
TRAP_OWN_KEYS
private static final java.lang.String TRAP_OWN_KEYS
- See Also:
- Constant Field Values
-
TRAP_APPLY
private static final java.lang.String TRAP_APPLY
- See Also:
- Constant Field Values
-
TRAP_CONSTRUCT
private static final java.lang.String TRAP_CONSTRUCT
- See Also:
- Constant Field Values
-
targetObj
private ScriptableObject targetObj
-
handlerObj
private Scriptable handlerObj
-
typeOf
private final java.lang.String typeOf
-
-
Constructor Detail
-
NativeProxy
private NativeProxy(ScriptableObject target, Scriptable handler)
-
-
Method Detail
-
init
public static void init(Context cx, Scriptable scope, boolean sealed)
-
getClassName
public java.lang.String getClassName()
Description copied from class:ScriptableObject
Return the name of the class.This is typically the same name as the constructor. Classes extending ScriptableObject must implement this abstract method.
- Specified by:
getClassName
in interfaceScriptable
- Specified by:
getClassName
in classScriptableObject
-
construct
public Scriptable construct(Context cx, Scriptable scope, java.lang.Object[] args)
see https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-construct-argumentslist-newtarget- Specified by:
construct
in interfaceConstructable
- Parameters:
cx
- the current Context for this threadscope
- an enclosing scope of the caller except when the function is called from a closure.args
- the array of arguments- Returns:
- the allocated object
-
has
public boolean has(java.lang.String name, Scriptable start)
https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-hasproperty-p- Specified by:
has
in interfaceScriptable
- Overrides:
has
in classScriptableObject
- Parameters:
name
- the name of the propertystart
- the object in which the lookup began- Returns:
- true if and only if the property was found in the object
- See Also:
Scriptable.get(String, Scriptable)
,ScriptableObject.getProperty(Scriptable, String)
-
has
public boolean has(int index, Scriptable start)
see https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-hasproperty-p- Specified by:
has
in interfaceScriptable
- Overrides:
has
in classScriptableObject
- Parameters:
index
- the numeric index for the propertystart
- the object in which the lookup began- Returns:
- true if and only if the property was found in the object
- See Also:
Scriptable.get(int, Scriptable)
,ScriptableObject.getProperty(Scriptable, int)
-
has
public boolean has(Symbol key, Scriptable start)
see https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-hasproperty-p- Specified by:
has
in interfaceSymbolScriptable
- Overrides:
has
in classScriptableObject
-
getIds
java.lang.Object[] getIds(boolean getNonEnumerable, boolean getSymbols)
see https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys- Overrides:
getIds
in classScriptableObject
-
get
public java.lang.Object get(java.lang.String name, Scriptable start)
see https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-get-p-receiver- Specified by:
get
in interfaceScriptable
- Overrides:
get
in classScriptableObject
- Parameters:
name
- the name of the propertystart
- the object in which the lookup began- Returns:
- the value of the property (may be null), or NOT_FOUND
- See Also:
Context.getUndefinedValue()
-
get
public java.lang.Object get(int index, Scriptable start)
see https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-get-p-receiver- Specified by:
get
in interfaceScriptable
- Overrides:
get
in classScriptableObject
- Parameters:
index
- the numeric index for the propertystart
- the object in which the lookup began- Returns:
- the value of the property (may be null), or NOT_FOUND
- See Also:
Scriptable.get(String,Scriptable)
-
get
public java.lang.Object get(Symbol key, Scriptable start)
see https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-get-p-receiver- Specified by:
get
in interfaceSymbolScriptable
- Overrides:
get
in classScriptableObject
-
put
public void put(java.lang.String name, Scriptable start, java.lang.Object value)
https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-set-p-v-receiver- Specified by:
put
in interfaceScriptable
- Overrides:
put
in classScriptableObject
- Parameters:
name
- the name of the propertystart
- the object whose property is being setvalue
- value to set the property to- See Also:
Scriptable.has(String, Scriptable)
,Scriptable.get(String, Scriptable)
,ScriptableObject.putProperty(Scriptable, String, Object)
,Context.toObject(Object, Scriptable)
-
put
public void put(int index, Scriptable start, java.lang.Object value)
https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-set-p-v-receiver- Specified by:
put
in interfaceScriptable
- Overrides:
put
in classScriptableObject
- Parameters:
index
- the numeric index for the propertystart
- the object whose property is being setvalue
- value to set the property to- See Also:
Scriptable.has(int, Scriptable)
,Scriptable.get(int, Scriptable)
,ScriptableObject.putProperty(Scriptable, int, Object)
,Context.toObject(Object, Scriptable)
-
put
public void put(Symbol key, Scriptable start, java.lang.Object value)
https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-set-p-v-receiver- Specified by:
put
in interfaceSymbolScriptable
- Overrides:
put
in classScriptableObject
-
delete
public void delete(java.lang.String name)
see https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-delete-p- Specified by:
delete
in interfaceScriptable
- Overrides:
delete
in classScriptableObject
- Parameters:
name
- the name of the property- See Also:
Scriptable.get(String, Scriptable)
,ScriptableObject.deleteProperty(Scriptable, String)
-
delete
public void delete(int index)
see https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-delete-p- Specified by:
delete
in interfaceScriptable
- Overrides:
delete
in classScriptableObject
- Parameters:
index
- the numeric index for the property- See Also:
Scriptable.get(int, Scriptable)
,ScriptableObject.deleteProperty(Scriptable, int)
-
delete
public void delete(Symbol key)
see https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-delete-p- Specified by:
delete
in interfaceSymbolScriptable
- Overrides:
delete
in classScriptableObject
-
getOwnPropertyDescriptor
protected ScriptableObject getOwnPropertyDescriptor(Context cx, java.lang.Object id)
see https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-getownproperty-p- Overrides:
getOwnPropertyDescriptor
in classScriptableObject
-
defineOwnProperty
public boolean defineOwnProperty(Context cx, java.lang.Object id, ScriptableObject desc)
see https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-defineownproperty-p-desc- Overrides:
defineOwnProperty
in classScriptableObject
- Parameters:
cx
- the current Contextid
- the name/index of the propertydesc
- the new property descriptor, as described in 8.6.1
-
isExtensible
public boolean isExtensible()
see https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-isextensible- Overrides:
isExtensible
in classScriptableObject
-
preventExtensions
public boolean preventExtensions()
see https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-preventextensions- Overrides:
preventExtensions
in classScriptableObject
-
getTypeOf
public java.lang.String getTypeOf()
Description copied from class:ScriptableObject
Gets the value that will be returned by calling the typeof operator on this object.- Overrides:
getTypeOf
in classScriptableObject
- Returns:
- default is "object" unless
ScriptableObject.avoidObjectDetection()
istrue
in which case it returns "undefined"
-
getPrototype
public Scriptable getPrototype()
see https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-getprototypeof- Specified by:
getPrototype
in interfaceScriptable
- Overrides:
getPrototype
in classScriptableObject
- Returns:
- the prototype
-
setPrototypeDirect
private void setPrototypeDirect(Scriptable prototype)
-
setPrototype
public void setPrototype(Scriptable prototype)
see https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-setprototypeof-v- Specified by:
setPrototype
in interfaceScriptable
- Overrides:
setPrototype
in classScriptableObject
- Parameters:
prototype
- the prototype to set
-
call
public java.lang.Object call(Context cx, Scriptable scope, Scriptable thisObj, java.lang.Object[] args)
see https://262.ecma-international.org/12.0/#sec-proxy-object-internal-methods-and-internal-slots-call-thisargument-argumentslist
-
constructor
private static NativeProxy constructor(Context cx, Scriptable scope, java.lang.Object[] args)
-
revocable
private static java.lang.Object revocable(Context cx, Scriptable scope, Scriptable thisObj, java.lang.Object[] args)
-
getTrap
private Callable getTrap(java.lang.String trapName)
-
callTrap
private java.lang.Object callTrap(Callable trap, java.lang.Object[] args)
-
getTargetThrowIfRevoked
ScriptableObject getTargetThrowIfRevoked()
-
-