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

Unified Diff: extensions/renderer/api_binding_unittest.cc

Issue 2853023002: [Extensions Bindings] Add native declarativeContent verification (Closed)
Patch Set: jbroman'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 fc82ff420c127403e9df7defb1012974e0b581c1..8bafdc959f6a3e57e0f09c417be9fc5787e7c244 100644
--- a/extensions/renderer/api_binding_unittest.cc
+++ b/extensions/renderer/api_binding_unittest.cc
@@ -1253,4 +1253,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

Powered by Google App Engine
This is Rietveld 408576698