Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(401)

Side by Side Diff: test/cctest/test-api.cc

Issue 7146010: Give correct error message when Object.isExtensible is called on a non object (fixes issue 1452) (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« src/v8natives.js ('K') | « src/v8natives.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 3021 matching lines...) Expand 10 before | Expand all | Expand 10 after
3032 result = script_define->Run(); 3032 result = script_define->Run();
3033 CHECK_EQ(result, v8_num(43)); 3033 CHECK_EQ(result, v8_num(43));
3034 result = script_desc->Run(); 3034 result = script_desc->Run();
3035 CHECK_EQ(result->BooleanValue(), false); 3035 CHECK_EQ(result->BooleanValue(), false);
3036 3036
3037 // Make sure that it is not possible to redefine again 3037 // Make sure that it is not possible to redefine again
3038 v8::TryCatch try_catch; 3038 v8::TryCatch try_catch;
3039 result = script_define->Run(); 3039 result = script_define->Run();
3040 CHECK(try_catch.HasCaught()); 3040 CHECK(try_catch.HasCaught());
3041 String::AsciiValue exception_value(try_catch.Exception()); 3041 String::AsciiValue exception_value(try_catch.Exception());
3042 CHECK_EQ(*exception_value, 3042 CHECK_EQ(*exception_value, "TypeError: Cannot redefine property: x");
3043 "TypeError: Cannot redefine property: defineProperty");
3044 } 3043 }
3045 3044
3046 THREADED_TEST(DefinePropertyOnDefineGetterSetter) { 3045 THREADED_TEST(DefinePropertyOnDefineGetterSetter) {
3047 v8::HandleScope scope; 3046 v8::HandleScope scope;
3048 Local<ObjectTemplate> templ = ObjectTemplate::New(); 3047 Local<ObjectTemplate> templ = ObjectTemplate::New();
3049 templ->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut")); 3048 templ->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut"));
3050 LocalContext context; 3049 LocalContext context;
3051 context->Global()->Set(v8_str("obj"), templ->NewInstance()); 3050 context->Global()->Set(v8_str("obj"), templ->NewInstance());
3052 3051
3053 Local<Script> script_desc = Script::Compile(v8_str("var prop =" 3052 Local<Script> script_desc = Script::Compile(v8_str("var prop ="
(...skipping 24 matching lines...) Expand all
3078 result = script_define->Run(); 3077 result = script_define->Run();
3079 CHECK_EQ(result, v8_num(43)); 3078 CHECK_EQ(result, v8_num(43));
3080 result = script_desc->Run(); 3079 result = script_desc->Run();
3081 3080
3082 CHECK_EQ(result->BooleanValue(), false); 3081 CHECK_EQ(result->BooleanValue(), false);
3083 3082
3084 v8::TryCatch try_catch; 3083 v8::TryCatch try_catch;
3085 result = script_define->Run(); 3084 result = script_define->Run();
3086 CHECK(try_catch.HasCaught()); 3085 CHECK(try_catch.HasCaught());
3087 String::AsciiValue exception_value(try_catch.Exception()); 3086 String::AsciiValue exception_value(try_catch.Exception());
3088 CHECK_EQ(*exception_value, 3087 CHECK_EQ(*exception_value, "TypeError: Cannot redefine property: x");
3089 "TypeError: Cannot redefine property: defineProperty");
3090 } 3088 }
3091 3089
3092 3090
3093 static v8::Handle<v8::Object> GetGlobalProperty(LocalContext* context, 3091 static v8::Handle<v8::Object> GetGlobalProperty(LocalContext* context,
3094 char const* name) { 3092 char const* name) {
3095 return v8::Handle<v8::Object>::Cast((*context)->Global()->Get(v8_str(name))); 3093 return v8::Handle<v8::Object>::Cast((*context)->Global()->Get(v8_str(name)));
3096 } 3094 }
3097 3095
3098 3096
3099 THREADED_TEST(DefineAPIAccessorOnObject) { 3097 THREADED_TEST(DefineAPIAccessorOnObject) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
3197 SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut"))); 3195 SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut")));
3198 CHECK(!GetGlobalProperty(&context, "obj2")-> 3196 CHECK(!GetGlobalProperty(&context, "obj2")->
3199 SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut"))); 3197 SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut")));
3200 3198
3201 { 3199 {
3202 v8::TryCatch try_catch; 3200 v8::TryCatch try_catch;
3203 CompileRun("Object.defineProperty(obj1, 'x'," 3201 CompileRun("Object.defineProperty(obj1, 'x',"
3204 "{get: function() { return 'func'; }})"); 3202 "{get: function() { return 'func'; }})");
3205 CHECK(try_catch.HasCaught()); 3203 CHECK(try_catch.HasCaught());
3206 String::AsciiValue exception_value(try_catch.Exception()); 3204 String::AsciiValue exception_value(try_catch.Exception());
3207 CHECK_EQ(*exception_value, 3205 CHECK_EQ(*exception_value, "TypeError: Cannot redefine property: x");
3208 "TypeError: Cannot redefine property: defineProperty");
3209 } 3206 }
3210 { 3207 {
3211 v8::TryCatch try_catch; 3208 v8::TryCatch try_catch;
3212 CompileRun("Object.defineProperty(obj2, 'x'," 3209 CompileRun("Object.defineProperty(obj2, 'x',"
3213 "{get: function() { return 'func'; }})"); 3210 "{get: function() { return 'func'; }})");
3214 CHECK(try_catch.HasCaught()); 3211 CHECK(try_catch.HasCaught());
3215 String::AsciiValue exception_value(try_catch.Exception()); 3212 String::AsciiValue exception_value(try_catch.Exception());
3216 CHECK_EQ(*exception_value, 3213 CHECK_EQ(*exception_value, "TypeError: Cannot redefine property: x");
3217 "TypeError: Cannot redefine property: defineProperty");
3218 } 3214 }
3219 } 3215 }
3220 3216
3221 3217
3222 static v8::Handle<Value> Get239Value(Local<String> name, 3218 static v8::Handle<Value> Get239Value(Local<String> name,
3223 const AccessorInfo& info) { 3219 const AccessorInfo& info) {
3224 ApiTestFuzzer::Fuzz(); 3220 ApiTestFuzzer::Fuzz();
3225 CHECK_EQ(info.Data(), v8_str("donut")); 3221 CHECK_EQ(info.Data(), v8_str("donut"));
3226 CHECK_EQ(name, v8_str("239")); 3222 CHECK_EQ(name, v8_str("239"));
3227 return name; 3223 return name;
(...skipping 11249 matching lines...) Expand 10 before | Expand all | Expand 10 after
14477 14473
14478 THREADED_TEST(CallAPIFunctionOnNonObject) { 14474 THREADED_TEST(CallAPIFunctionOnNonObject) {
14479 v8::HandleScope scope; 14475 v8::HandleScope scope;
14480 LocalContext context; 14476 LocalContext context;
14481 Handle<FunctionTemplate> templ = v8::FunctionTemplate::New(NonObjectThis); 14477 Handle<FunctionTemplate> templ = v8::FunctionTemplate::New(NonObjectThis);
14482 Handle<Function> function = templ->GetFunction(); 14478 Handle<Function> function = templ->GetFunction();
14483 context->Global()->Set(v8_str("f"), function); 14479 context->Global()->Set(v8_str("f"), function);
14484 TryCatch try_catch; 14480 TryCatch try_catch;
14485 CompileRun("f.call(2)"); 14481 CompileRun("f.call(2)");
14486 } 14482 }
OLDNEW
« src/v8natives.js ('K') | « src/v8natives.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698