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

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

Issue 18658: Added handling of hidden prototype objects when collecting local properties f... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 11 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/runtime.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 2731 matching lines...) Expand 10 before | Expand all | Expand 10 after
2742 CHECK(CompileRun(source)->BooleanValue()); 2742 CHECK(CompileRun(source)->BooleanValue());
2743 2743
2744 source = "both_values[3].name() == 1"; 2744 source = "both_values[3].name() == 1";
2745 CHECK(CompileRun(source)->BooleanValue()); 2745 CHECK(CompileRun(source)->BooleanValue());
2746 2746
2747 source = "both_values[4].name() == 10"; 2747 source = "both_values[4].name() == 10";
2748 CHECK(CompileRun(source)->BooleanValue()); 2748 CHECK(CompileRun(source)->BooleanValue());
2749 } 2749 }
2750 2750
2751 2751
2752 TEST(HiddenPrototypePropertyMirror) {
2753 // Create a V8 environment with debug access.
2754 v8::HandleScope scope;
2755 DebugLocalContext env;
2756 env.ExposeDebug();
2757
2758 v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New();
2759 t0->InstanceTemplate()->Set(v8::String::New("x"), v8::Number::New(0));
2760 v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New();
2761 t1->SetHiddenPrototype(true);
2762 t1->InstanceTemplate()->Set(v8::String::New("y"), v8::Number::New(1));
2763 v8::Handle<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New();
2764 t2->SetHiddenPrototype(true);
2765 t2->InstanceTemplate()->Set(v8::String::New("z"), v8::Number::New(2));
2766 v8::Handle<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New();
2767 t3->InstanceTemplate()->Set(v8::String::New("u"), v8::Number::New(3));
2768
2769 // Create object and set them on the global object.
2770 v8::Handle<v8::Object> o0 = t0->GetFunction()->NewInstance();
2771 env->Global()->Set(v8::String::New("o0"), o0);
2772 v8::Handle<v8::Object> o1 = t1->GetFunction()->NewInstance();
2773 env->Global()->Set(v8::String::New("o1"), o1);
2774 v8::Handle<v8::Object> o2 = t2->GetFunction()->NewInstance();
2775 env->Global()->Set(v8::String::New("o2"), o2);
2776 v8::Handle<v8::Object> o3 = t3->GetFunction()->NewInstance();
2777 env->Global()->Set(v8::String::New("o3"), o3);
2778
2779 // Get mirrors for the four objects.
2780 CompileRun(
2781 "o0_mirror = debug.MakeMirror(o0);"
2782 "o1_mirror = debug.MakeMirror(o1);"
2783 "o2_mirror = debug.MakeMirror(o2);"
2784 "o3_mirror = debug.MakeMirror(o3)");
2785 CHECK(CompileRun("o0_mirror instanceof debug.ObjectMirror")->BooleanValue());
2786 CHECK(CompileRun("o1_mirror instanceof debug.ObjectMirror")->BooleanValue());
2787 CHECK(CompileRun("o2_mirror instanceof debug.ObjectMirror")->BooleanValue());
2788 CHECK(CompileRun("o3_mirror instanceof debug.ObjectMirror")->BooleanValue());
2789
2790 // Check that each object has one property.
2791 CHECK_EQ(1, CompileRun(
2792 "o0_mirror.propertyNames().length")->Int32Value());
2793 CHECK_EQ(1, CompileRun(
2794 "o1_mirror.propertyNames().length")->Int32Value());
2795 CHECK_EQ(1, CompileRun(
2796 "o2_mirror.propertyNames().length")->Int32Value());
2797 CHECK_EQ(1, CompileRun(
2798 "o3_mirror.propertyNames().length")->Int32Value());
2799
2800 // Set o1 as prototype for o0. o1 has the hidden prototype flag so all
2801 // properties on o1 should be seen on o0.
2802 o0->Set(v8::String::New("__proto__"), o1);
2803 CHECK_EQ(2, CompileRun(
2804 "o0_mirror.propertyNames().length")->Int32Value());
2805 CHECK_EQ(0, CompileRun(
2806 "o0_mirror.property('x').value().value()")->Int32Value());
2807 CHECK_EQ(1, CompileRun(
2808 "o0_mirror.property('y').value().value()")->Int32Value());
2809
2810 // Set o2 as prototype for o0 (it will end up after o1 as o1 has the hidden
2811 // prototype flag. o2 also has the hidden prototype flag so all properties
2812 // on o2 should be seen on o0 as well as properties on o1.
2813 o0->Set(v8::String::New("__proto__"), o2);
2814 CHECK_EQ(3, CompileRun(
2815 "o0_mirror.propertyNames().length")->Int32Value());
2816 CHECK_EQ(0, CompileRun(
2817 "o0_mirror.property('x').value().value()")->Int32Value());
2818 CHECK_EQ(1, CompileRun(
2819 "o0_mirror.property('y').value().value()")->Int32Value());
2820 CHECK_EQ(2, CompileRun(
2821 "o0_mirror.property('z').value().value()")->Int32Value());
2822
2823 // Set o3 as prototype for o0 (it will end up after o1 and o2 as both o1 and
2824 // o2 has the hidden prototype flag. o3 does not have the hidden prototype
2825 // flag so properties on o3 should not be seen on o0 whereas the properties
2826 // from o1 and o2 should still be seen on o0.
2827 // Final prototype chain: o0 -> o1 -> o2 -> o3
2828 // Hidden prototypes: ^^ ^^
2829 o0->Set(v8::String::New("__proto__"), o3);
2830 CHECK_EQ(3, CompileRun(
2831 "o0_mirror.propertyNames().length")->Int32Value());
2832 CHECK_EQ(1, CompileRun(
2833 "o3_mirror.propertyNames().length")->Int32Value());
2834 CHECK_EQ(0, CompileRun(
2835 "o0_mirror.property('x').value().value()")->Int32Value());
2836 CHECK_EQ(1, CompileRun(
2837 "o0_mirror.property('y').value().value()")->Int32Value());
2838 CHECK_EQ(2, CompileRun(
2839 "o0_mirror.property('z').value().value()")->Int32Value());
2840 CHECK(CompileRun("o0_mirror.property('u').isUndefined()")->BooleanValue());
2841
2842 // The prototype (__proto__) for o0 should be o3 as o1 and o2 are hidden.
2843 CHECK(CompileRun("o0_mirror.protoObject() == o3_mirror")->BooleanValue());
2844 }
2845
2846
2752 // Multithreaded tests of JSON debugger protocol 2847 // Multithreaded tests of JSON debugger protocol
2753 2848
2754 // Support classes 2849 // Support classes
2755 2850
2756 // Copies a C string to a 16-bit string. Does not check for buffer overflow. 2851 // Copies a C string to a 16-bit string. Does not check for buffer overflow.
2757 // Does not use the V8 engine to convert strings, so it can be used 2852 // Does not use the V8 engine to convert strings, so it can be used
2758 // in any thread. Returns the length of the string. 2853 // in any thread. Returns the length of the string.
2759 int AsciiToUtf16(const char* input_buffer, uint16_t* output_buffer) { 2854 int AsciiToUtf16(const char* input_buffer, uint16_t* output_buffer) {
2760 int i; 2855 int i;
2761 for (i = 0; input_buffer[i] != '\0'; ++i) { 2856 for (i = 0; input_buffer[i] != '\0'; ++i) {
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
3404 " CheckSourceLine(2)\n" 3499 " CheckSourceLine(2)\n"
3405 " CheckSourceLine(3)\n" 3500 " CheckSourceLine(3)\n"
3406 "}; f()"))->Run(); 3501 "}; f()"))->Run();
3407 3502
3408 // Test that a parameter can be passed to a function called in the debugger. 3503 // Test that a parameter can be passed to a function called in the debugger.
3409 v8::Script::Compile(v8::String::New("CheckDataParameter()"))->Run(); 3504 v8::Script::Compile(v8::String::New("CheckDataParameter()"))->Run();
3410 3505
3411 // Test that a function with closure can be run in the debugger. 3506 // Test that a function with closure can be run in the debugger.
3412 v8::Script::Compile(v8::String::New("CheckClosure()"))->Run(); 3507 v8::Script::Compile(v8::String::New("CheckClosure()"))->Run();
3413 } 3508 }
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698