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

Unified Diff: extensions/renderer/api_binding_unittest.cc

Issue 2853023002: [Extensions Bindings] Add native declarativeContent verification (Closed)
Patch Set: lazyboy's Created 3 years, 8 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: 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
« no previous file with comments | « extensions/renderer/api_binding_hooks_test_delegate.cc ('k') | extensions/renderer/declarative_content_hooks_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698