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

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

Issue 291153005: Consistently say 'own' property (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add new files Created 6 years, 7 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
« no previous file with comments | « src/v8natives.js ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 10264 matching lines...) Expand 10 before | Expand all | Expand 10 after
10275 CHECK(proto1->IsObject()); 10275 CHECK(proto1->IsObject());
10276 CHECK_EQ(proto1.As<v8::Object>(), o2); 10276 CHECK_EQ(proto1.As<v8::Object>(), o2);
10277 10277
10278 Local<Value> proto2 = o2->GetPrototype(); 10278 Local<Value> proto2 = o2->GetPrototype();
10279 CHECK(proto2->IsObject()); 10279 CHECK(proto2->IsObject());
10280 CHECK_EQ(proto2.As<v8::Object>(), o3); 10280 CHECK_EQ(proto2.As<v8::Object>(), o3);
10281 } 10281 }
10282 10282
10283 10283
10284 // Getting property names of an object with a prototype chain that 10284 // Getting property names of an object with a prototype chain that
10285 // triggers dictionary elements in GetLocalPropertyNames() shouldn't 10285 // triggers dictionary elements in GetOwnPropertyNames() shouldn't
10286 // crash the runtime. 10286 // crash the runtime.
10287 THREADED_TEST(Regress91517) { 10287 THREADED_TEST(Regress91517) {
10288 i::FLAG_allow_natives_syntax = true; 10288 i::FLAG_allow_natives_syntax = true;
10289 LocalContext context; 10289 LocalContext context;
10290 v8::Isolate* isolate = context->GetIsolate(); 10290 v8::Isolate* isolate = context->GetIsolate();
10291 v8::HandleScope handle_scope(isolate); 10291 v8::HandleScope handle_scope(isolate);
10292 10292
10293 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate); 10293 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate);
10294 t1->SetHiddenPrototype(true); 10294 t1->SetHiddenPrototype(true);
10295 t1->InstanceTemplate()->Set(v8_str("foo"), v8_num(1)); 10295 t1->InstanceTemplate()->Set(v8_str("foo"), v8_num(1));
(...skipping 18 matching lines...) Expand all
10314 Local<v8::Object> o1 = t1->GetFunction()->NewInstance(); 10314 Local<v8::Object> o1 = t1->GetFunction()->NewInstance();
10315 Local<v8::Object> o2 = t2->GetFunction()->NewInstance(); 10315 Local<v8::Object> o2 = t2->GetFunction()->NewInstance();
10316 Local<v8::Object> o3 = t3->GetFunction()->NewInstance(); 10316 Local<v8::Object> o3 = t3->GetFunction()->NewInstance();
10317 Local<v8::Object> o4 = t4->GetFunction()->NewInstance(); 10317 Local<v8::Object> o4 = t4->GetFunction()->NewInstance();
10318 10318
10319 // Create prototype chain of hidden prototypes. 10319 // Create prototype chain of hidden prototypes.
10320 CHECK(o4->SetPrototype(o3)); 10320 CHECK(o4->SetPrototype(o3));
10321 CHECK(o3->SetPrototype(o2)); 10321 CHECK(o3->SetPrototype(o2));
10322 CHECK(o2->SetPrototype(o1)); 10322 CHECK(o2->SetPrototype(o1));
10323 10323
10324 // Call the runtime version of GetLocalPropertyNames() on the natively 10324 // Call the runtime version of GetOwnPropertyNames() on the natively
10325 // created object through JavaScript. 10325 // created object through JavaScript.
10326 context->Global()->Set(v8_str("obj"), o4); 10326 context->Global()->Set(v8_str("obj"), o4);
10327 // PROPERTY_ATTRIBUTES_NONE = 0 10327 // PROPERTY_ATTRIBUTES_NONE = 0
10328 CompileRun("var names = %GetLocalPropertyNames(obj, 0);"); 10328 CompileRun("var names = %GetOwnPropertyNames(obj, 0);");
10329 10329
10330 ExpectInt32("names.length", 1006); 10330 ExpectInt32("names.length", 1006);
10331 ExpectTrue("names.indexOf(\"baz\") >= 0"); 10331 ExpectTrue("names.indexOf(\"baz\") >= 0");
10332 ExpectTrue("names.indexOf(\"boo\") >= 0"); 10332 ExpectTrue("names.indexOf(\"boo\") >= 0");
10333 ExpectTrue("names.indexOf(\"foo\") >= 0"); 10333 ExpectTrue("names.indexOf(\"foo\") >= 0");
10334 ExpectTrue("names.indexOf(\"fuz1\") >= 0"); 10334 ExpectTrue("names.indexOf(\"fuz1\") >= 0");
10335 ExpectTrue("names.indexOf(\"fuz2\") >= 0"); 10335 ExpectTrue("names.indexOf(\"fuz2\") >= 0");
10336 ExpectFalse("names[1005] == undefined"); 10336 ExpectFalse("names[1005] == undefined");
10337 } 10337 }
10338 10338
(...skipping 30 matching lines...) Expand all
10369 10369
10370 Local<v8::Object> o2 = t2->GetFunction()->NewInstance(); 10370 Local<v8::Object> o2 = t2->GetFunction()->NewInstance();
10371 CHECK(o2->SetPrototype(o1)); 10371 CHECK(o2->SetPrototype(o1));
10372 10372
10373 v8::Local<v8::Symbol> sym = 10373 v8::Local<v8::Symbol> sym =
10374 v8::Symbol::New(context->GetIsolate(), v8_str("s1")); 10374 v8::Symbol::New(context->GetIsolate(), v8_str("s1"));
10375 o1->Set(sym, v8_num(3)); 10375 o1->Set(sym, v8_num(3));
10376 o1->SetHiddenValue( 10376 o1->SetHiddenValue(
10377 v8_str("h1"), v8::Integer::New(context->GetIsolate(), 2013)); 10377 v8_str("h1"), v8::Integer::New(context->GetIsolate(), 2013));
10378 10378
10379 // Call the runtime version of GetLocalPropertyNames() on 10379 // Call the runtime version of GetOwnPropertyNames() on
10380 // the natively created object through JavaScript. 10380 // the natively created object through JavaScript.
10381 context->Global()->Set(v8_str("obj"), o2); 10381 context->Global()->Set(v8_str("obj"), o2);
10382 context->Global()->Set(v8_str("sym"), sym); 10382 context->Global()->Set(v8_str("sym"), sym);
10383 // PROPERTY_ATTRIBUTES_NONE = 0 10383 // PROPERTY_ATTRIBUTES_NONE = 0
10384 CompileRun("var names = %GetLocalPropertyNames(obj, 0);"); 10384 CompileRun("var names = %GetOwnPropertyNames(obj, 0);");
10385 10385
10386 ExpectInt32("names.length", 7); 10386 ExpectInt32("names.length", 7);
10387 ExpectTrue("names.indexOf(\"foo\") >= 0"); 10387 ExpectTrue("names.indexOf(\"foo\") >= 0");
10388 ExpectTrue("names.indexOf(\"bar\") >= 0"); 10388 ExpectTrue("names.indexOf(\"bar\") >= 0");
10389 ExpectTrue("names.indexOf(\"baz\") >= 0"); 10389 ExpectTrue("names.indexOf(\"baz\") >= 0");
10390 ExpectTrue("names.indexOf(\"n1\") >= 0"); 10390 ExpectTrue("names.indexOf(\"n1\") >= 0");
10391 ExpectTrue("names.indexOf(\"n2\") >= 0"); 10391 ExpectTrue("names.indexOf(\"n2\") >= 0");
10392 ExpectTrue("names.indexOf(sym) >= 0"); 10392 ExpectTrue("names.indexOf(sym) >= 0");
10393 ExpectTrue("names.indexOf(\"mine\") >= 0"); 10393 ExpectTrue("names.indexOf(\"mine\") >= 0");
10394 } 10394 }
(...skipping 8850 matching lines...) Expand 10 before | Expand all | Expand 10 after
19245 global0->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("x"))); 19245 global0->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("x")));
19246 19246
19247 // Define JavaScript accessor. 19247 // Define JavaScript accessor.
19248 ExpectUndefined("Object.prototype.__defineGetter__.call(" 19248 ExpectUndefined("Object.prototype.__defineGetter__.call("
19249 " other, \'x\', function() { return 42; })"); 19249 " other, \'x\', function() { return 42; })");
19250 19250
19251 // LookupAccessor. 19251 // LookupAccessor.
19252 ExpectUndefined("Object.prototype.__lookupGetter__.call(" 19252 ExpectUndefined("Object.prototype.__lookupGetter__.call("
19253 " other, \'x\')"); 19253 " other, \'x\')");
19254 19254
19255 // HasLocalElement. 19255 // HasOwnElement.
19256 ExpectFalse("Object.prototype.hasOwnProperty.call(other, \'0\')"); 19256 ExpectFalse("Object.prototype.hasOwnProperty.call(other, \'0\')");
19257 19257
19258 CHECK_EQ(false, global0->HasRealIndexedProperty(0)); 19258 CHECK_EQ(false, global0->HasRealIndexedProperty(0));
19259 CHECK_EQ(false, global0->HasRealNamedProperty(v8_str("x"))); 19259 CHECK_EQ(false, global0->HasRealNamedProperty(v8_str("x")));
19260 CHECK_EQ(false, global0->HasRealNamedCallbackProperty(v8_str("x"))); 19260 CHECK_EQ(false, global0->HasRealNamedCallbackProperty(v8_str("x")));
19261 19261
19262 // Reset the failed access check callback so it does not influence 19262 // Reset the failed access check callback so it does not influence
19263 // the other tests. 19263 // the other tests.
19264 v8::V8::SetFailedAccessCheckCallbackFunction(NULL); 19264 v8::V8::SetFailedAccessCheckCallbackFunction(NULL);
19265 } 19265 }
(...skipping 2413 matching lines...) Expand 10 before | Expand all | Expand 10 after
21679 21679
21680 CheckCorrectThrow("other.x"); 21680 CheckCorrectThrow("other.x");
21681 CheckCorrectThrow("other[1]"); 21681 CheckCorrectThrow("other[1]");
21682 CheckCorrectThrow("JSON.stringify(other)"); 21682 CheckCorrectThrow("JSON.stringify(other)");
21683 CheckCorrectThrow("has_own_property(other, 'x')"); 21683 CheckCorrectThrow("has_own_property(other, 'x')");
21684 CheckCorrectThrow("%GetProperty(other, 'x')"); 21684 CheckCorrectThrow("%GetProperty(other, 'x')");
21685 CheckCorrectThrow("%SetProperty(other, 'x', 'foo', 1, 0)"); 21685 CheckCorrectThrow("%SetProperty(other, 'x', 'foo', 1, 0)");
21686 CheckCorrectThrow("%IgnoreAttributesAndSetProperty(other, 'x', 'foo')"); 21686 CheckCorrectThrow("%IgnoreAttributesAndSetProperty(other, 'x', 'foo')");
21687 CheckCorrectThrow("%DeleteProperty(other, 'x', 0)"); 21687 CheckCorrectThrow("%DeleteProperty(other, 'x', 0)");
21688 CheckCorrectThrow("%DeleteProperty(other, '1', 0)"); 21688 CheckCorrectThrow("%DeleteProperty(other, '1', 0)");
21689 CheckCorrectThrow("%HasLocalProperty(other, 'x')"); 21689 CheckCorrectThrow("%HasOwnProperty(other, 'x')");
21690 CheckCorrectThrow("%HasProperty(other, 'x')"); 21690 CheckCorrectThrow("%HasProperty(other, 'x')");
21691 CheckCorrectThrow("%HasElement(other, 1)"); 21691 CheckCorrectThrow("%HasElement(other, 1)");
21692 CheckCorrectThrow("%IsPropertyEnumerable(other, 'x')"); 21692 CheckCorrectThrow("%IsPropertyEnumerable(other, 'x')");
21693 CheckCorrectThrow("%GetPropertyNames(other)"); 21693 CheckCorrectThrow("%GetPropertyNames(other)");
21694 // PROPERTY_ATTRIBUTES_NONE = 0 21694 // PROPERTY_ATTRIBUTES_NONE = 0
21695 CheckCorrectThrow("%GetLocalPropertyNames(other, 0)"); 21695 CheckCorrectThrow("%GetOwnPropertyNames(other, 0)");
21696 CheckCorrectThrow("%DefineOrRedefineAccessorProperty(" 21696 CheckCorrectThrow("%DefineOrRedefineAccessorProperty("
21697 "other, 'x', null, null, 1)"); 21697 "other, 'x', null, null, 1)");
21698 21698
21699 // Reset the failed access check callback so it does not influence 21699 // Reset the failed access check callback so it does not influence
21700 // the other tests. 21700 // the other tests.
21701 v8::V8::SetFailedAccessCheckCallbackFunction(NULL); 21701 v8::V8::SetFailedAccessCheckCallbackFunction(NULL);
21702 } 21702 }
21703 21703
21704 21704
21705 THREADED_TEST(Regress256330) { 21705 THREADED_TEST(Regress256330) {
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after
22607 v8::internal::FLAG_stack_size = 150; 22607 v8::internal::FLAG_stack_size = 150;
22608 LocalContext current; 22608 LocalContext current;
22609 v8::Isolate* isolate = current->GetIsolate(); 22609 v8::Isolate* isolate = current->GetIsolate();
22610 v8::HandleScope scope(isolate); 22610 v8::HandleScope scope(isolate);
22611 V8::SetCaptureStackTraceForUncaughtExceptions( 22611 V8::SetCaptureStackTraceForUncaughtExceptions(
22612 true, 10, v8::StackTrace::kDetailed); 22612 true, 10, v8::StackTrace::kDetailed);
22613 v8::TryCatch try_catch; 22613 v8::TryCatch try_catch;
22614 CompileRun("(function f(x) { f(x+1); })(0)"); 22614 CompileRun("(function f(x) { f(x+1); })(0)");
22615 CHECK(try_catch.HasCaught()); 22615 CHECK(try_catch.HasCaught());
22616 } 22616 }
OLDNEW
« no previous file with comments | « src/v8natives.js ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698