Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 3421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3432 CHECK(CompileRun( | 3432 CHECK(CompileRun( |
| 3433 "instance_mirror.property('x').value().isError()")->BooleanValue()); | 3433 "instance_mirror.property('x').value().isError()")->BooleanValue()); |
| 3434 | 3434 |
| 3435 // Check that the message is that passed to the Error constructor. | 3435 // Check that the message is that passed to the Error constructor. |
| 3436 CHECK(CompileRun( | 3436 CHECK(CompileRun( |
| 3437 "instance_mirror.property('x').value().message() == 'Error message'")-> | 3437 "instance_mirror.property('x').value().message() == 'Error message'")-> |
| 3438 BooleanValue()); | 3438 BooleanValue()); |
| 3439 } | 3439 } |
| 3440 | 3440 |
| 3441 | 3441 |
| 3442 // See http://crbug.com/26491 | |
|
Mads Ager (chromium)
2009/11/10 16:04:08
Could you add a one line description before the bu
yurys
2009/11/10 16:09:07
Done.
| |
| 3443 TEST(NoHiddenProperties) { | |
| 3444 // Create a V8 environment with debug access. | |
| 3445 v8::HandleScope scope; | |
| 3446 DebugLocalContext env; | |
| 3447 env.ExposeDebug(); | |
| 3448 | |
| 3449 // Create an object in the global scope. | |
| 3450 const char* source = "var obj = {a: 1};"; | |
| 3451 v8::Script::Compile(v8::String::New(source))->Run(); | |
| 3452 v8::Local<v8::Object> obj = v8::Local<v8::Object>::Cast( | |
| 3453 env->Global()->Get(v8::String::New("obj"))); | |
| 3454 // Set a hidden property on the object. | |
| 3455 obj->SetHiddenValue(v8::String::New("v8::test-debug::a"), | |
| 3456 v8::Int32::New(11)); | |
| 3457 | |
| 3458 // Get mirror for the object with property getter. | |
| 3459 CompileRun("var obj_mirror = debug.MakeMirror(obj);"); | |
| 3460 CHECK(CompileRun( | |
| 3461 "obj_mirror instanceof debug.ObjectMirror")->BooleanValue()); | |
| 3462 CompileRun("var named_names = obj_mirror.propertyNames();"); | |
| 3463 // There should be exactly one property. But there is also an unnamed | |
| 3464 // property whose value is hidden properties dictionary. The latter | |
| 3465 // property should not be in the list of reguar properties. | |
| 3466 CHECK_EQ(1, CompileRun("named_names.length")->Int32Value()); | |
| 3467 CHECK(CompileRun("named_names[0] == 'a'")->BooleanValue()); | |
| 3468 CHECK(CompileRun( | |
| 3469 "obj_mirror.property('a').value().value() == 1")->BooleanValue()); | |
| 3470 | |
| 3471 // Object created by t0 will become hidden prototype of object 'obj'. | |
| 3472 v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(); | |
| 3473 t0->InstanceTemplate()->Set(v8::String::New("b"), v8::Number::New(2)); | |
| 3474 t0->SetHiddenPrototype(true); | |
| 3475 v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(); | |
| 3476 t1->InstanceTemplate()->Set(v8::String::New("c"), v8::Number::New(3)); | |
| 3477 | |
| 3478 // Create proto objects, add hidden properties to them and set them on | |
| 3479 // the global object. | |
| 3480 v8::Handle<v8::Object> protoObj = t0->GetFunction()->NewInstance(); | |
| 3481 protoObj->SetHiddenValue(v8::String::New("v8::test-debug::b"), | |
| 3482 v8::Int32::New(12)); | |
| 3483 env->Global()->Set(v8::String::New("protoObj"), protoObj); | |
| 3484 v8::Handle<v8::Object> grandProtoObj = t1->GetFunction()->NewInstance(); | |
| 3485 grandProtoObj->SetHiddenValue(v8::String::New("v8::test-debug::c"), | |
| 3486 v8::Int32::New(13)); | |
| 3487 env->Global()->Set(v8::String::New("grandProtoObj"), grandProtoObj); | |
| 3488 | |
| 3489 // Setting prototypes: obj->protoObj->grandProtoObj | |
| 3490 protoObj->Set(v8::String::New("__proto__"), grandProtoObj); | |
| 3491 obj->Set(v8::String::New("__proto__"), protoObj); | |
| 3492 | |
| 3493 // Get mirror for the object with property getter. | |
| 3494 CompileRun("var obj_mirror = debug.MakeMirror(obj);"); | |
| 3495 CHECK(CompileRun( | |
| 3496 "obj_mirror instanceof debug.ObjectMirror")->BooleanValue()); | |
| 3497 CompileRun("var named_names = obj_mirror.propertyNames();"); | |
| 3498 // There should be exactly two properties - one from the object itself and | |
| 3499 // another from its hidden prototype. | |
| 3500 CHECK_EQ(2, CompileRun("named_names.length")->Int32Value()); | |
| 3501 CHECK(CompileRun("named_names.sort(); named_names[0] == 'a' &&" | |
| 3502 "named_names[1] == 'b'")->BooleanValue()); | |
| 3503 CHECK(CompileRun( | |
| 3504 "obj_mirror.property('a').value().value() == 1")->BooleanValue()); | |
| 3505 CHECK(CompileRun( | |
| 3506 "obj_mirror.property('b').value().value() == 2")->BooleanValue()); | |
| 3507 } | |
| 3508 | |
| 3442 | 3509 |
| 3443 // Multithreaded tests of JSON debugger protocol | 3510 // Multithreaded tests of JSON debugger protocol |
| 3444 | 3511 |
| 3445 // Support classes | 3512 // Support classes |
| 3446 | 3513 |
| 3447 // Copies a C string to a 16-bit string. Does not check for buffer overflow. | 3514 // Copies a C string to a 16-bit string. Does not check for buffer overflow. |
| 3448 // Does not use the V8 engine to convert strings, so it can be used | 3515 // Does not use the V8 engine to convert strings, so it can be used |
| 3449 // in any thread. Returns the length of the string. | 3516 // in any thread. Returns the length of the string. |
| 3450 int AsciiToUtf16(const char* input_buffer, uint16_t* output_buffer) { | 3517 int AsciiToUtf16(const char* input_buffer, uint16_t* output_buffer) { |
| 3451 int i; | 3518 int i; |
| (...skipping 2032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5484 break_point_hit_count = 0; | 5551 break_point_hit_count = 0; |
| 5485 max_break_point_hit_count = 10000; // 10000 => infinite loop. | 5552 max_break_point_hit_count = 10000; // 10000 => infinite loop. |
| 5486 foo->Call(env->Global(), 0, NULL); | 5553 foo->Call(env->Global(), 0, NULL); |
| 5487 | 5554 |
| 5488 // When keeping the debug break several break will happen. | 5555 // When keeping the debug break several break will happen. |
| 5489 CHECK_EQ(3, break_point_hit_count); | 5556 CHECK_EQ(3, break_point_hit_count); |
| 5490 | 5557 |
| 5491 v8::Debug::SetDebugEventListener(NULL); | 5558 v8::Debug::SetDebugEventListener(NULL); |
| 5492 CheckDebuggerUnloaded(); | 5559 CheckDebuggerUnloaded(); |
| 5493 } | 5560 } |
| OLD | NEW |