| Index: extensions/renderer/api_binding_unittest.cc
|
| diff --git a/extensions/renderer/api_binding_unittest.cc b/extensions/renderer/api_binding_unittest.cc
|
| index 682c0ed6939fc8d379506c2457fce5519b31659a..c3514c384ab79d49beb4b9ec6d782f5150ef0f49 100644
|
| --- a/extensions/renderer/api_binding_unittest.cc
|
| +++ b/extensions/renderer/api_binding_unittest.cc
|
| @@ -1151,4 +1151,34 @@ TEST_F(APIBindingUnittest, FilteredEvents) {
|
| check_supports_filters("filteredTwo", true);
|
| }
|
|
|
| +TEST_F(APIBindingUnittest, HooksTemplateInitializer) {
|
| + SetFunctions(kFunctions);
|
| +
|
| + // Register a hook for the test.oneString method.
|
| + auto hooks = base::MakeUnique<APIBindingHooksTestDelegate>();
|
| + auto hook = [](v8::Isolate* isolate,
|
| + v8::Local<v8::ObjectTemplate> object_template,
|
| + const APITypeReferenceMap& type_refs) {
|
| + object_template->Set(gin::StringToSymbol(isolate, "hookedProperty"),
|
| + gin::ConvertToV8(isolate, 42));
|
| + };
|
| + hooks->SetTemplateInitializer(base::Bind(hook));
|
| + SetHooksDelegate(std::move(hooks));
|
| +
|
| + InitializeBinding();
|
| +
|
| + v8::HandleScope handle_scope(isolate());
|
| + v8::Local<v8::Context> context = MainContext();
|
| +
|
| + v8::Local<v8::Object> binding_object =
|
| + binding()->CreateInstance(context, base::Bind(&AllowAllAPIs));
|
| +
|
| + // The extra property should be present on the binding object.
|
| + EXPECT_EQ("42", GetStringPropertyFromObject(binding_object, context,
|
| + "hookedProperty"));
|
| + // Sanity check: other values should still be there.
|
| + EXPECT_EQ("function",
|
| + GetStringPropertyFromObject(binding_object, context, "oneString"));
|
| +}
|
| +
|
| } // namespace extensions
|
|
|