Geve correct error message when Object.isExtensible is called on a non object (fixes issue 1452)

Review URL: http://codereview.chromium.org/7146010

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8275 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
ricow@chromium.org 2011-06-14 11:28:14 +00:00
parent a4cf7be941
commit 38a75cf731
3 changed files with 13 additions and 17 deletions

View File

@ -190,7 +190,7 @@ function FormatMessage(message) {
proto_object_or_null: ["Object prototype may only be an Object or null"],
property_desc_object: ["Property description must be an object: ", "%0"],
redefine_disallowed: ["Cannot redefine property: ", "%0"],
define_disallowed: ["Cannot define property, object is not extensible: ", "%0"],
define_disallowed: ["Cannot define property:", "%0", ", object is not extensible."],
non_extensible_proto: ["%0", " is not extensible"],
handler_non_object: ["Proxy.", "%0", " called with non-object as handler"],
handler_trap_missing: ["Proxy handler ", "%0", " has no '", "%1", "' trap"],

View File

@ -629,7 +629,7 @@ function DefineOwnProperty(obj, p, desc, should_throw) {
// Step 3
if (IS_UNDEFINED(current) && !extensible) {
if (should_throw) {
throw MakeTypeError("define_disallowed", ["defineProperty"]);
throw MakeTypeError("define_disallowed", [p]);
} else {
return;
}
@ -659,7 +659,7 @@ function DefineOwnProperty(obj, p, desc, should_throw) {
(desc.hasEnumerable() &&
desc.isEnumerable() != current.isEnumerable())) {
if (should_throw) {
throw MakeTypeError("redefine_disallowed", ["defineProperty"]);
throw MakeTypeError("redefine_disallowed", [p]);
} else {
return;
}
@ -669,7 +669,7 @@ function DefineOwnProperty(obj, p, desc, should_throw) {
// Step 9a
if (IsDataDescriptor(current) != IsDataDescriptor(desc)) {
if (should_throw) {
throw MakeTypeError("redefine_disallowed", ["defineProperty"]);
throw MakeTypeError("redefine_disallowed", [p]);
} else {
return;
}
@ -678,7 +678,7 @@ function DefineOwnProperty(obj, p, desc, should_throw) {
if (IsDataDescriptor(current) && IsDataDescriptor(desc)) {
if (!current.isWritable() && desc.isWritable()) {
if (should_throw) {
throw MakeTypeError("redefine_disallowed", ["defineProperty"]);
throw MakeTypeError("redefine_disallowed", [p]);
} else {
return;
}
@ -686,7 +686,7 @@ function DefineOwnProperty(obj, p, desc, should_throw) {
if (!current.isWritable() && desc.hasValue() &&
!SameValue(desc.getValue(), current.getValue())) {
if (should_throw) {
throw MakeTypeError("redefine_disallowed", ["defineProperty"]);
throw MakeTypeError("redefine_disallowed", [p]);
} else {
return;
}
@ -696,14 +696,14 @@ function DefineOwnProperty(obj, p, desc, should_throw) {
if (IsAccessorDescriptor(desc) && IsAccessorDescriptor(current)) {
if (desc.hasSetter() && !SameValue(desc.getSet(), current.getSet())) {
if (should_throw) {
throw MakeTypeError("redefine_disallowed", ["defineProperty"]);
throw MakeTypeError("redefine_disallowed", [p]);
} else {
return;
}
}
if (desc.hasGetter() && !SameValue(desc.getGet(),current.getGet())) {
if (should_throw) {
throw MakeTypeError("redefine_disallowed", ["defineProperty"]);
throw MakeTypeError("redefine_disallowed", [p]);
} else {
return;
}
@ -1016,7 +1016,7 @@ function ObjectIsFrozen(obj) {
// ES5 section 15.2.3.13
function ObjectIsExtensible(obj) {
if (!IS_SPEC_OBJECT(obj)) {
throw MakeTypeError("obj_ctor_property_non_object", ["preventExtension"]);
throw MakeTypeError("obj_ctor_property_non_object", ["isExtensible"]);
}
return %IsExtensible(obj);
}

View File

@ -3039,8 +3039,7 @@ THREADED_TEST(DefinePropertyOnAPIAccessor) {
result = script_define->Run();
CHECK(try_catch.HasCaught());
String::AsciiValue exception_value(try_catch.Exception());
CHECK_EQ(*exception_value,
"TypeError: Cannot redefine property: defineProperty");
CHECK_EQ(*exception_value, "TypeError: Cannot redefine property: x");
}
THREADED_TEST(DefinePropertyOnDefineGetterSetter) {
@ -3085,8 +3084,7 @@ THREADED_TEST(DefinePropertyOnDefineGetterSetter) {
result = script_define->Run();
CHECK(try_catch.HasCaught());
String::AsciiValue exception_value(try_catch.Exception());
CHECK_EQ(*exception_value,
"TypeError: Cannot redefine property: defineProperty");
CHECK_EQ(*exception_value, "TypeError: Cannot redefine property: x");
}
@ -3204,8 +3202,7 @@ THREADED_TEST(DontDeleteAPIAccessorsCannotBeOverriden) {
"{get: function() { return 'func'; }})");
CHECK(try_catch.HasCaught());
String::AsciiValue exception_value(try_catch.Exception());
CHECK_EQ(*exception_value,
"TypeError: Cannot redefine property: defineProperty");
CHECK_EQ(*exception_value, "TypeError: Cannot redefine property: x");
}
{
v8::TryCatch try_catch;
@ -3213,8 +3210,7 @@ THREADED_TEST(DontDeleteAPIAccessorsCannotBeOverriden) {
"{get: function() { return 'func'; }})");
CHECK(try_catch.HasCaught());
String::AsciiValue exception_value(try_catch.Exception());
CHECK_EQ(*exception_value,
"TypeError: Cannot redefine property: defineProperty");
CHECK_EQ(*exception_value, "TypeError: Cannot redefine property: x");
}
}