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

Unified Diff: test/cctest/test-api-interceptors.cc

Issue 1428793002: Reland v8::Private and related APIs (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: test/cctest/test-api-interceptors.cc
diff --git a/test/cctest/test-api-interceptors.cc b/test/cctest/test-api-interceptors.cc
index 61f88601926e55bd5a7bfb9a52bf46b6ab9feb49..3327d782f7cff1e4fec748be5718a2f588766789 100644
--- a/test/cctest/test-api-interceptors.cc
+++ b/test/cctest/test-api-interceptors.cc
@@ -109,7 +109,11 @@ void StringInterceptorGetter(
if (name_str[i] != prefix[i]) return;
}
Handle<Object> self = Handle<Object>::Cast(info.This());
- info.GetReturnValue().Set(self->GetHiddenValue(v8_str(name_str + i)));
+ info.GetReturnValue().Set(
+ self->GetPrivate(
+ info.GetIsolate()->GetCurrentContext(),
+ v8::Private::ForApi(info.GetIsolate(), v8_str(name_str + i)))
+ .ToLocalChecked());
}
@@ -128,7 +132,9 @@ void StringInterceptorSetter(Local<String> name, Local<Value> value,
if (value->IsInt32() && value->Int32Value() < 10000) {
Handle<Object> self = Handle<Object>::Cast(info.This());
- self->SetHiddenValue(name, value);
+ Handle<Context> context = info.GetIsolate()->GetCurrentContext();
+ Handle<v8::Private> symbol = v8::Private::ForApi(info.GetIsolate(), name);
+ self->SetPrivate(context, symbol, value).FromJust();
info.GetReturnValue().Set(value);
}
}
@@ -1314,7 +1320,8 @@ THREADED_TEST(HiddenPropertiesWithInterceptors) {
interceptor_for_hidden_properties_called = false;
- v8::Local<v8::String> key = v8_str("api-test::hidden-key");
+ v8::Local<v8::Private> key =
+ v8::Private::New(isolate, v8_str("api-test::hidden-key"));
// Associate an interceptor with an object and start setting hidden values.
Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(isolate);
@@ -1323,8 +1330,11 @@ THREADED_TEST(HiddenPropertiesWithInterceptors) {
v8::NamedPropertyHandlerConfiguration(InterceptorForHiddenProperties));
Local<v8::Function> function = fun_templ->GetFunction();
Local<v8::Object> obj = function->NewInstance();
- CHECK(obj->SetHiddenValue(key, v8::Integer::New(isolate, 2302)));
- CHECK_EQ(2302, obj->GetHiddenValue(key)->Int32Value());
+ CHECK(obj->SetPrivate(context.local(), key, v8::Integer::New(isolate, 2302))
+ .FromJust());
+ CHECK_EQ(
+ 2302,
+ obj->GetPrivate(context.local(), key).ToLocalChecked()->Int32Value());
CHECK(!interceptor_for_hidden_properties_called);
}
« include/v8.h ('K') | « test/cctest/test-api.cc ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698