Make following ES5 functions work with undetectable parameters/target (document.all):
ObjectIsPrototypeOf ObjectDefineGetter ObjectLookupGetter ObjectDefineSetter ObjectLookupSetter ObjectKeys ObjectGetPrototypeOf ObjectGetOwnPropertyDescriptor ObjectGetOwnPropertyNames ObjectDefineProperty ObjectDefineProperties I did not implement tests covering calls with undetectable parameters since I would need to make these tests native. Just thought it was not worth the effort. If you think tests would make sense, I can add them. We might want to allow other functions to receive undetectable parameters, but I am not seeing any good candidates. Review URL: http://codereview.chromium.org/1297003 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4264 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
65025e4659
commit
41830911f3
@ -221,7 +221,7 @@ function ObjectHasOwnProperty(V) {
|
||||
|
||||
// ECMA-262 - 15.2.4.6
|
||||
function ObjectIsPrototypeOf(V) {
|
||||
if (!IS_OBJECT(V) && !IS_FUNCTION(V)) return false;
|
||||
if (!IS_OBJECT(V) && !IS_FUNCTION(V) && !IS_UNDETECTABLE(V)) return false;
|
||||
return %IsInPrototypeChain(this, V);
|
||||
}
|
||||
|
||||
@ -236,7 +236,7 @@ function ObjectPropertyIsEnumerable(V) {
|
||||
|
||||
// Extensions for providing property getters and setters.
|
||||
function ObjectDefineGetter(name, fun) {
|
||||
if (this == null) {
|
||||
if (this == null && !IS_UNDETECTABLE(this)) {
|
||||
throw new $TypeError('Object.prototype.__defineGetter__: this is Null');
|
||||
}
|
||||
if (!IS_FUNCTION(fun)) {
|
||||
@ -247,7 +247,7 @@ function ObjectDefineGetter(name, fun) {
|
||||
|
||||
|
||||
function ObjectLookupGetter(name) {
|
||||
if (this == null) {
|
||||
if (this == null && !IS_UNDETECTABLE(this)) {
|
||||
throw new $TypeError('Object.prototype.__lookupGetter__: this is Null');
|
||||
}
|
||||
return %LookupAccessor(ToObject(this), ToString(name), GETTER);
|
||||
@ -255,7 +255,7 @@ function ObjectLookupGetter(name) {
|
||||
|
||||
|
||||
function ObjectDefineSetter(name, fun) {
|
||||
if (this == null) {
|
||||
if (this == null && !IS_UNDETECTABLE(this)) {
|
||||
throw new $TypeError('Object.prototype.__defineSetter__: this is Null');
|
||||
}
|
||||
if (!IS_FUNCTION(fun)) {
|
||||
@ -267,7 +267,7 @@ function ObjectDefineSetter(name, fun) {
|
||||
|
||||
|
||||
function ObjectLookupSetter(name) {
|
||||
if (this == null) {
|
||||
if (this == null && !IS_UNDETECTABLE(this)) {
|
||||
throw new $TypeError('Object.prototype.__lookupSetter__: this is Null');
|
||||
}
|
||||
return %LookupAccessor(ToObject(this), ToString(name), SETTER);
|
||||
@ -275,7 +275,8 @@ function ObjectLookupSetter(name) {
|
||||
|
||||
|
||||
function ObjectKeys(obj) {
|
||||
if ((!IS_OBJECT(obj) || IS_NULL_OR_UNDEFINED(obj)) && !IS_FUNCTION(obj))
|
||||
if ((!IS_OBJECT(obj) || IS_NULL_OR_UNDEFINED(obj)) && !IS_FUNCTION(obj) &&
|
||||
!IS_UNDETECTABLE(obj))
|
||||
throw MakeTypeError("obj_ctor_property_non_object", ["keys"]);
|
||||
return %LocalKeys(obj);
|
||||
}
|
||||
@ -594,7 +595,8 @@ function DefineOwnProperty(obj, p, desc, should_throw) {
|
||||
|
||||
// ES5 section 15.2.3.2.
|
||||
function ObjectGetPrototypeOf(obj) {
|
||||
if ((!IS_OBJECT(obj) || IS_NULL_OR_UNDEFINED(obj)) && !IS_FUNCTION(obj))
|
||||
if ((!IS_OBJECT(obj) || IS_NULL_OR_UNDEFINED(obj)) && !IS_FUNCTION(obj) &&
|
||||
!IS_UNDETECTABLE(obj))
|
||||
throw MakeTypeError("obj_ctor_property_non_object", ["getPrototypeOf"]);
|
||||
return obj.__proto__;
|
||||
}
|
||||
@ -602,7 +604,8 @@ function ObjectGetPrototypeOf(obj) {
|
||||
|
||||
// ES5 section 15.2.3.3
|
||||
function ObjectGetOwnPropertyDescriptor(obj, p) {
|
||||
if ((!IS_OBJECT(obj) || IS_NULL_OR_UNDEFINED(obj)) && !IS_FUNCTION(obj))
|
||||
if ((!IS_OBJECT(obj) || IS_NULL_OR_UNDEFINED(obj)) && !IS_FUNCTION(obj) &&
|
||||
!IS_UNDETECTABLE(obj))
|
||||
throw MakeTypeError("obj_ctor_property_non_object", ["getOwnPropertyDescriptor"]);
|
||||
var desc = GetOwnProperty(obj, p);
|
||||
return FromPropertyDescriptor(desc);
|
||||
@ -611,7 +614,8 @@ function ObjectGetOwnPropertyDescriptor(obj, p) {
|
||||
|
||||
// ES5 section 15.2.3.4.
|
||||
function ObjectGetOwnPropertyNames(obj) {
|
||||
if ((!IS_OBJECT(obj) || IS_NULL_OR_UNDEFINED(obj)) && !IS_FUNCTION(obj))
|
||||
if ((!IS_OBJECT(obj) || IS_NULL_OR_UNDEFINED(obj)) && !IS_FUNCTION(obj) &&
|
||||
!IS_UNDETECTABLE(obj))
|
||||
throw MakeTypeError("obj_ctor_property_non_object", ["getOwnPropertyNames"]);
|
||||
|
||||
// Find all the indexed properties.
|
||||
@ -664,7 +668,8 @@ function ObjectCreate(proto, properties) {
|
||||
|
||||
// ES5 section 15.2.3.6.
|
||||
function ObjectDefineProperty(obj, p, attributes) {
|
||||
if ((!IS_OBJECT(obj) || IS_NULL_OR_UNDEFINED(obj)) && !IS_FUNCTION(obj))
|
||||
if ((!IS_OBJECT(obj) || IS_NULL_OR_UNDEFINED(obj)) && !IS_FUNCTION(obj) &&
|
||||
!IS_UNDETECTABLE(obj))
|
||||
throw MakeTypeError("obj_ctor_property_non_object", ["defineProperty"]);
|
||||
var name = ToString(p);
|
||||
var desc = ToPropertyDescriptor(attributes);
|
||||
@ -675,7 +680,8 @@ function ObjectDefineProperty(obj, p, attributes) {
|
||||
|
||||
// ES5 section 15.2.3.7.
|
||||
function ObjectDefineProperties(obj, properties) {
|
||||
if ((!IS_OBJECT(obj) || IS_NULL_OR_UNDEFINED(obj)) && !IS_FUNCTION(obj))
|
||||
if ((!IS_OBJECT(obj) || IS_NULL_OR_UNDEFINED(obj)) && !IS_FUNCTION(obj) &&
|
||||
!IS_UNDETECTABLE(obj))
|
||||
throw MakeTypeError("obj_ctor_property_non_object", ["defineProperties"]);
|
||||
var props = ToObject(properties);
|
||||
var key_values = [];
|
||||
|
Loading…
Reference in New Issue
Block a user