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

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

Issue 760883002: Add interceptor support for symbols (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix test Created 6 years 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
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/cctest/test-decls.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 4332 matching lines...) Expand 10 before | Expand all | Expand 10 after
4343 4343
4344 static void IndexedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) { 4344 static void IndexedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) {
4345 v8::Isolate* isolate = info.GetIsolate(); 4345 v8::Isolate* isolate = info.GetIsolate();
4346 v8::Handle<v8::Array> result = v8::Array::New(isolate, 2); 4346 v8::Handle<v8::Array> result = v8::Array::New(isolate, 2);
4347 result->Set(v8::Integer::New(isolate, 0), v8::Number::New(isolate, 1)); 4347 result->Set(v8::Integer::New(isolate, 0), v8::Number::New(isolate, 1));
4348 result->Set(v8::Integer::New(isolate, 1), v8::Number::New(isolate, 10)); 4348 result->Set(v8::Integer::New(isolate, 1), v8::Number::New(isolate, 10));
4349 info.GetReturnValue().Set(result); 4349 info.GetReturnValue().Set(result);
4350 } 4350 }
4351 4351
4352 4352
4353 static void NamedGetter(v8::Local<v8::String> name, 4353 static void NamedGetter(v8::Local<v8::Name> name,
4354 const v8::PropertyCallbackInfo<v8::Value>& info) { 4354 const v8::PropertyCallbackInfo<v8::Value>& info) {
4355 v8::String::Utf8Value n(name); 4355 if (name->IsSymbol()) return;
4356 v8::String::Utf8Value n(v8::Local<v8::String>::Cast(name));
4356 if (strcmp(*n, "a") == 0) { 4357 if (strcmp(*n, "a") == 0) {
4357 info.GetReturnValue().Set(v8::String::NewFromUtf8(info.GetIsolate(), "AA")); 4358 info.GetReturnValue().Set(v8::String::NewFromUtf8(info.GetIsolate(), "AA"));
4358 return; 4359 return;
4359 } else if (strcmp(*n, "b") == 0) { 4360 } else if (strcmp(*n, "b") == 0) {
4360 info.GetReturnValue().Set(v8::String::NewFromUtf8(info.GetIsolate(), "BB")); 4361 info.GetReturnValue().Set(v8::String::NewFromUtf8(info.GetIsolate(), "BB"));
4361 return; 4362 return;
4362 } else if (strcmp(*n, "c") == 0) { 4363 } else if (strcmp(*n, "c") == 0) {
4363 info.GetReturnValue().Set(v8::String::NewFromUtf8(info.GetIsolate(), "CC")); 4364 info.GetReturnValue().Set(v8::String::NewFromUtf8(info.GetIsolate(), "CC"));
4364 return; 4365 return;
4365 } else { 4366 } else {
(...skipping 12 matching lines...) Expand all
4378 4379
4379 TEST(InterceptorPropertyMirror) { 4380 TEST(InterceptorPropertyMirror) {
4380 // Create a V8 environment with debug access. 4381 // Create a V8 environment with debug access.
4381 DebugLocalContext env; 4382 DebugLocalContext env;
4382 v8::Isolate* isolate = env->GetIsolate(); 4383 v8::Isolate* isolate = env->GetIsolate();
4383 v8::HandleScope scope(isolate); 4384 v8::HandleScope scope(isolate);
4384 env.ExposeDebug(); 4385 env.ExposeDebug();
4385 4386
4386 // Create object with named interceptor. 4387 // Create object with named interceptor.
4387 v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New(isolate); 4388 v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New(isolate);
4388 named->SetNamedPropertyHandler(NamedGetter, NULL, NULL, NULL, NamedEnum); 4389 named->SetHandler(v8::NamedPropertyHandlerConfiguration(
4390 NamedGetter, NULL, NULL, NULL, NamedEnum));
4389 env->Global()->Set( 4391 env->Global()->Set(
4390 v8::String::NewFromUtf8(isolate, "intercepted_named"), 4392 v8::String::NewFromUtf8(isolate, "intercepted_named"),
4391 named->NewInstance()); 4393 named->NewInstance());
4392 4394
4393 // Create object with indexed interceptor. 4395 // Create object with indexed interceptor.
4394 v8::Handle<v8::ObjectTemplate> indexed = v8::ObjectTemplate::New(isolate); 4396 v8::Handle<v8::ObjectTemplate> indexed = v8::ObjectTemplate::New(isolate);
4395 indexed->SetIndexedPropertyHandler(IndexedGetter, 4397 indexed->SetIndexedPropertyHandler(IndexedGetter,
4396 NULL, 4398 NULL,
4397 NULL, 4399 NULL,
4398 NULL, 4400 NULL,
4399 IndexedEnum); 4401 IndexedEnum);
4400 env->Global()->Set( 4402 env->Global()->Set(
4401 v8::String::NewFromUtf8(isolate, "intercepted_indexed"), 4403 v8::String::NewFromUtf8(isolate, "intercepted_indexed"),
4402 indexed->NewInstance()); 4404 indexed->NewInstance());
4403 4405
4404 // Create object with both named and indexed interceptor. 4406 // Create object with both named and indexed interceptor.
4405 v8::Handle<v8::ObjectTemplate> both = v8::ObjectTemplate::New(isolate); 4407 v8::Handle<v8::ObjectTemplate> both = v8::ObjectTemplate::New(isolate);
4406 both->SetNamedPropertyHandler(NamedGetter, NULL, NULL, NULL, NamedEnum); 4408 both->SetHandler(v8::NamedPropertyHandlerConfiguration(
4409 NamedGetter, NULL, NULL, NULL, NamedEnum));
4407 both->SetIndexedPropertyHandler(IndexedGetter, NULL, NULL, NULL, IndexedEnum); 4410 both->SetIndexedPropertyHandler(IndexedGetter, NULL, NULL, NULL, IndexedEnum);
4408 env->Global()->Set( 4411 env->Global()->Set(
4409 v8::String::NewFromUtf8(isolate, "intercepted_both"), 4412 v8::String::NewFromUtf8(isolate, "intercepted_both"),
4410 both->NewInstance()); 4413 both->NewInstance());
4411 4414
4412 // Get mirrors for the three objects with interceptor. 4415 // Get mirrors for the three objects with interceptor.
4413 CompileRun( 4416 CompileRun(
4414 "var named_mirror = debug.MakeMirror(intercepted_named);" 4417 "var named_mirror = debug.MakeMirror(intercepted_named);"
4415 "var indexed_mirror = debug.MakeMirror(intercepted_indexed);" 4418 "var indexed_mirror = debug.MakeMirror(intercepted_indexed);"
4416 "var both_mirror = debug.MakeMirror(intercepted_both)"); 4419 "var both_mirror = debug.MakeMirror(intercepted_both)");
(...skipping 3254 matching lines...) Expand 10 before | Expand all | Expand 10 after
7671 "let y = 2; \n" 7674 "let y = 2; \n"
7672 "debugger; \n" 7675 "debugger; \n"
7673 "x * y", 7676 "x * y",
7674 30); 7677 30);
7675 ExpectInt32( 7678 ExpectInt32(
7676 "x = 1; y = 2; \n" 7679 "x = 1; y = 2; \n"
7677 "debugger;" 7680 "debugger;"
7678 "x * y", 7681 "x * y",
7679 30); 7682 30);
7680 } 7683 }
OLDNEW
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/cctest/test-decls.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698