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

Unified Diff: src/d8.cc

Issue 2746053006: NOT FOR COMMIT: test that interceptors work with the inspector.
Patch Set: Created 3 years, 9 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
« no previous file with comments | « no previous file | test.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/d8.cc
diff --git a/src/d8.cc b/src/d8.cc
index 4ab7af6d2c7fedd22e61b098b0d2038285d0f3d2..183a6e70eeea5d2a30c6d989e1fc328b8bed6281 100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -1437,6 +1437,33 @@ Local<String> Shell::Stringify(Isolate* isolate, Local<Value> value) {
return result.ToLocalChecked().As<String>();
}
+void NamedGetter(Local<String> property,
+ const PropertyCallbackInfo<Value>& info) {
+ Isolate* isolate = Isolate::GetCurrent();
+ EscapableHandleScope scope(isolate);
+ Local<Object> selfObj = info.Holder();
+ info.GetReturnValue().Set(
+ scope.Escape(String::NewFromUtf8(isolate, "value")));
+}
+
+void NamedSetter(Local<String> property, Local<Value> value,
+ const PropertyCallbackInfo<Value>& info) {
+ Isolate* isolate = Isolate::GetCurrent();
+ EscapableHandleScope scope(isolate);
+ Local<Object> selfObj = info.Holder();
+}
+
+void NamedEnumerator(const PropertyCallbackInfo<Array>& info) {
+ Isolate* isolate = Isolate::GetCurrent();
+ EscapableHandleScope scope(isolate);
+ Local<Object> selfObj = info.Holder();
+ Handle<Array> array = Array::New(isolate);
+ array->Set(0, String::NewFromUtf8(isolate, "one"));
+ array->Set(1, String::NewFromUtf8(isolate, "two"));
+ array->Set(2, String::NewFromUtf8(isolate, "three"));
+ array->Set(3, String::NewFromUtf8(isolate, "four"));
+ info.GetReturnValue().Set(scope.Escape(array));
+}
Local<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) {
Local<ObjectTemplate> global_template = ObjectTemplate::New(isolate);
@@ -1580,6 +1607,14 @@ Local<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) {
.ToLocalChecked(),
os_templ);
+ Local<FunctionTemplate> funTem = FunctionTemplate::New(isolate);
+ Local<ObjectTemplate> inst = funTem->InstanceTemplate();
+ inst->SetNamedPropertyHandler(NamedGetter, NamedSetter, 0, 0,
+ NamedEnumerator);
+
+ global_template->Set(String::NewFromUtf8(isolate, "NamedObject"), funTem,
+ v8::PropertyAttribute(v8::DontDelete | v8::ReadOnly));
+
return global_template;
}
« no previous file with comments | « no previous file | test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698