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

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

Issue 386007: Push bleeding_edge revision 3265 and 3266 to trunk to hide the hidden... (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 11 years, 1 month 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/version.cc ('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 2007-2008 the V8 project authors. All rights reserved. 1 // Copyright 2007-2008 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 3407 matching lines...) Expand 10 before | Expand all | Expand 10 after
3418 CHECK(CompileRun( 3418 CHECK(CompileRun(
3419 "instance_mirror.property('x').value().isError()")->BooleanValue()); 3419 "instance_mirror.property('x').value().isError()")->BooleanValue());
3420 3420
3421 // Check that the message is that passed to the Error constructor. 3421 // Check that the message is that passed to the Error constructor.
3422 CHECK(CompileRun( 3422 CHECK(CompileRun(
3423 "instance_mirror.property('x').value().message() == 'Error message'")-> 3423 "instance_mirror.property('x').value().message() == 'Error message'")->
3424 BooleanValue()); 3424 BooleanValue());
3425 } 3425 }
3426 3426
3427 3427
3428 // Test that hidden properties object is not returned as an unnamed property
3429 // among regular properties.
3430 // See http://crbug.com/26491
3431 TEST(NoHiddenProperties) {
3432 // Create a V8 environment with debug access.
3433 v8::HandleScope scope;
3434 DebugLocalContext env;
3435 env.ExposeDebug();
3436
3437 // Create an object in the global scope.
3438 const char* source = "var obj = {a: 1};";
3439 v8::Script::Compile(v8::String::New(source))->Run();
3440 v8::Local<v8::Object> obj = v8::Local<v8::Object>::Cast(
3441 env->Global()->Get(v8::String::New("obj")));
3442 // Set a hidden property on the object.
3443 obj->SetHiddenValue(v8::String::New("v8::test-debug::a"),
3444 v8::Int32::New(11));
3445
3446 // Get mirror for the object with property getter.
3447 CompileRun("var obj_mirror = debug.MakeMirror(obj);");
3448 CHECK(CompileRun(
3449 "obj_mirror instanceof debug.ObjectMirror")->BooleanValue());
3450 CompileRun("var named_names = obj_mirror.propertyNames();");
3451 // There should be exactly one property. But there is also an unnamed
3452 // property whose value is hidden properties dictionary. The latter
3453 // property should not be in the list of reguar properties.
3454 CHECK_EQ(1, CompileRun("named_names.length")->Int32Value());
3455 CHECK(CompileRun("named_names[0] == 'a'")->BooleanValue());
3456 CHECK(CompileRun(
3457 "obj_mirror.property('a').value().value() == 1")->BooleanValue());
3458
3459 // Object created by t0 will become hidden prototype of object 'obj'.
3460 v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New();
3461 t0->InstanceTemplate()->Set(v8::String::New("b"), v8::Number::New(2));
3462 t0->SetHiddenPrototype(true);
3463 v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New();
3464 t1->InstanceTemplate()->Set(v8::String::New("c"), v8::Number::New(3));
3465
3466 // Create proto objects, add hidden properties to them and set them on
3467 // the global object.
3468 v8::Handle<v8::Object> protoObj = t0->GetFunction()->NewInstance();
3469 protoObj->SetHiddenValue(v8::String::New("v8::test-debug::b"),
3470 v8::Int32::New(12));
3471 env->Global()->Set(v8::String::New("protoObj"), protoObj);
3472 v8::Handle<v8::Object> grandProtoObj = t1->GetFunction()->NewInstance();
3473 grandProtoObj->SetHiddenValue(v8::String::New("v8::test-debug::c"),
3474 v8::Int32::New(13));
3475 env->Global()->Set(v8::String::New("grandProtoObj"), grandProtoObj);
3476
3477 // Setting prototypes: obj->protoObj->grandProtoObj
3478 protoObj->Set(v8::String::New("__proto__"), grandProtoObj);
3479 obj->Set(v8::String::New("__proto__"), protoObj);
3480
3481 // Get mirror for the object with property getter.
3482 CompileRun("var obj_mirror = debug.MakeMirror(obj);");
3483 CHECK(CompileRun(
3484 "obj_mirror instanceof debug.ObjectMirror")->BooleanValue());
3485 CompileRun("var named_names = obj_mirror.propertyNames();");
3486 // There should be exactly two properties - one from the object itself and
3487 // another from its hidden prototype.
3488 CHECK_EQ(2, CompileRun("named_names.length")->Int32Value());
3489 CHECK(CompileRun("named_names.sort(); named_names[0] == 'a' &&"
3490 "named_names[1] == 'b'")->BooleanValue());
3491 CHECK(CompileRun(
3492 "obj_mirror.property('a').value().value() == 1")->BooleanValue());
3493 CHECK(CompileRun(
3494 "obj_mirror.property('b').value().value() == 2")->BooleanValue());
3495 }
3496
3428 3497
3429 // Multithreaded tests of JSON debugger protocol 3498 // Multithreaded tests of JSON debugger protocol
3430 3499
3431 // Support classes 3500 // Support classes
3432 3501
3433 // Copies a C string to a 16-bit string. Does not check for buffer overflow. 3502 // Copies a C string to a 16-bit string. Does not check for buffer overflow.
3434 // Does not use the V8 engine to convert strings, so it can be used 3503 // Does not use the V8 engine to convert strings, so it can be used
3435 // in any thread. Returns the length of the string. 3504 // in any thread. Returns the length of the string.
3436 int AsciiToUtf16(const char* input_buffer, uint16_t* output_buffer) { 3505 int AsciiToUtf16(const char* input_buffer, uint16_t* output_buffer) {
3437 int i; 3506 int i;
(...skipping 1999 matching lines...) Expand 10 before | Expand all | Expand 10 after
5437 v8::Script::New( 5506 v8::Script::New(
5438 v8::String::New( 5507 v8::String::New(
5439 "function runTest(mirror) {" 5508 "function runTest(mirror) {"
5440 " return mirror.isString() && (mirror.length() == 5);" 5509 " return mirror.isString() && (mirror.length() == 5);"
5441 "}" 5510 "}"
5442 "" 5511 ""
5443 "runTest;"))->Run()); 5512 "runTest;"))->Run());
5444 v8::Handle<v8::Value> result = run_test->Call(env->Global(), 1, &obj); 5513 v8::Handle<v8::Value> result = run_test->Call(env->Global(), 1, &obj);
5445 CHECK(result->IsTrue()); 5514 CHECK(result->IsTrue());
5446 } 5515 }
OLDNEW
« no previous file with comments | « src/version.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698