Commit 41830911 authored by pfeldman@chromium.org's avatar pfeldman@chromium.org

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
parent 65025e46
...@@ -221,7 +221,7 @@ function ObjectHasOwnProperty(V) { ...@@ -221,7 +221,7 @@ function ObjectHasOwnProperty(V) {
// ECMA-262 - 15.2.4.6 // ECMA-262 - 15.2.4.6
function ObjectIsPrototypeOf(V) { 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); return %IsInPrototypeChain(this, V);
} }
...@@ -236,7 +236,7 @@ function ObjectPropertyIsEnumerable(V) { ...@@ -236,7 +236,7 @@ function ObjectPropertyIsEnumerable(V) {
// Extensions for providing property getters and setters. // Extensions for providing property getters and setters.
function ObjectDefineGetter(name, fun) { function ObjectDefineGetter(name, fun) {
if (this == null) { if (this == null && !IS_UNDETECTABLE(this)) {
throw new $TypeError('Object.prototype.__defineGetter__: this is Null'); throw new $TypeError('Object.prototype.__defineGetter__: this is Null');
} }
if (!IS_FUNCTION(fun)) { if (!IS_FUNCTION(fun)) {
...@@ -247,7 +247,7 @@ function ObjectDefineGetter(name, fun) { ...@@ -247,7 +247,7 @@ function ObjectDefineGetter(name, fun) {
function ObjectLookupGetter(name) { function ObjectLookupGetter(name) {
if (this == null) { if (this == null && !IS_UNDETECTABLE(this)) {
throw new $TypeError('Object.prototype.__lookupGetter__: this is Null'); throw new $TypeError('Object.prototype.__lookupGetter__: this is Null');
} }
return %LookupAccessor(ToObject(this), ToString(name), GETTER); return %LookupAccessor(ToObject(this), ToString(name), GETTER);
...@@ -255,7 +255,7 @@ function ObjectLookupGetter(name) { ...@@ -255,7 +255,7 @@ function ObjectLookupGetter(name) {
function ObjectDefineSetter(name, fun) { function ObjectDefineSetter(name, fun) {
if (this == null) { if (this == null && !IS_UNDETECTABLE(this)) {
throw new $TypeError('Object.prototype.__defineSetter__: this is Null'); throw new $TypeError('Object.prototype.__defineSetter__: this is Null');
} }
if (!IS_FUNCTION(fun)) { if (!IS_FUNCTION(fun)) {
...@@ -267,7 +267,7 @@ function ObjectDefineSetter(name, fun) { ...@@ -267,7 +267,7 @@ function ObjectDefineSetter(name, fun) {
function ObjectLookupSetter(name) { function ObjectLookupSetter(name) {
if (this == null) { if (this == null && !IS_UNDETECTABLE(this)) {
throw new $TypeError('Object.prototype.__lookupSetter__: this is Null'); throw new $TypeError('Object.prototype.__lookupSetter__: this is Null');
} }
return %LookupAccessor(ToObject(this), ToString(name), SETTER); return %LookupAccessor(ToObject(this), ToString(name), SETTER);
...@@ -275,7 +275,8 @@ function ObjectLookupSetter(name) { ...@@ -275,7 +275,8 @@ function ObjectLookupSetter(name) {
function ObjectKeys(obj) { 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"]); throw MakeTypeError("obj_ctor_property_non_object", ["keys"]);
return %LocalKeys(obj); return %LocalKeys(obj);
} }
...@@ -594,7 +595,8 @@ function DefineOwnProperty(obj, p, desc, should_throw) { ...@@ -594,7 +595,8 @@ function DefineOwnProperty(obj, p, desc, should_throw) {
// ES5 section 15.2.3.2. // ES5 section 15.2.3.2.
function ObjectGetPrototypeOf(obj) { 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"]); throw MakeTypeError("obj_ctor_property_non_object", ["getPrototypeOf"]);
return obj.__proto__; return obj.__proto__;
} }
...@@ -602,7 +604,8 @@ function ObjectGetPrototypeOf(obj) { ...@@ -602,7 +604,8 @@ function ObjectGetPrototypeOf(obj) {
// ES5 section 15.2.3.3 // ES5 section 15.2.3.3
function ObjectGetOwnPropertyDescriptor(obj, p) { 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"]); throw MakeTypeError("obj_ctor_property_non_object", ["getOwnPropertyDescriptor"]);
var desc = GetOwnProperty(obj, p); var desc = GetOwnProperty(obj, p);
return FromPropertyDescriptor(desc); return FromPropertyDescriptor(desc);
...@@ -611,7 +614,8 @@ function ObjectGetOwnPropertyDescriptor(obj, p) { ...@@ -611,7 +614,8 @@ function ObjectGetOwnPropertyDescriptor(obj, p) {
// ES5 section 15.2.3.4. // ES5 section 15.2.3.4.
function ObjectGetOwnPropertyNames(obj) { 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"]); throw MakeTypeError("obj_ctor_property_non_object", ["getOwnPropertyNames"]);
// Find all the indexed properties. // Find all the indexed properties.
...@@ -664,7 +668,8 @@ function ObjectCreate(proto, properties) { ...@@ -664,7 +668,8 @@ function ObjectCreate(proto, properties) {
// ES5 section 15.2.3.6. // ES5 section 15.2.3.6.
function ObjectDefineProperty(obj, p, attributes) { 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"]); throw MakeTypeError("obj_ctor_property_non_object", ["defineProperty"]);
var name = ToString(p); var name = ToString(p);
var desc = ToPropertyDescriptor(attributes); var desc = ToPropertyDescriptor(attributes);
...@@ -675,7 +680,8 @@ function ObjectDefineProperty(obj, p, attributes) { ...@@ -675,7 +680,8 @@ function ObjectDefineProperty(obj, p, attributes) {
// ES5 section 15.2.3.7. // ES5 section 15.2.3.7.
function ObjectDefineProperties(obj, properties) { 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"]); throw MakeTypeError("obj_ctor_property_non_object", ["defineProperties"]);
var props = ToObject(properties); var props = ToObject(properties);
var key_values = []; var key_values = [];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment