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

Side by Side Diff: extensions/renderer/api_binding_unittest.cc

Issue 2853023002: [Extensions Bindings] Add native declarativeContent verification (Closed)
Patch Set: +test Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/memory/ptr_util.h" 6 #include "base/memory/ptr_util.h"
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "extensions/renderer/api_binding.h" 10 #include "extensions/renderer/api_binding.h"
(...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 } 1246 }
1247 }; 1247 };
1248 1248
1249 check_supports_filters("unfilteredOne", false); 1249 check_supports_filters("unfilteredOne", false);
1250 check_supports_filters("unfilteredTwo", false); 1250 check_supports_filters("unfilteredTwo", false);
1251 check_supports_filters("unfilteredThree", false); 1251 check_supports_filters("unfilteredThree", false);
1252 check_supports_filters("filteredOne", true); 1252 check_supports_filters("filteredOne", true);
1253 check_supports_filters("filteredTwo", true); 1253 check_supports_filters("filteredTwo", true);
1254 } 1254 }
1255 1255
1256 TEST_F(APIBindingUnittest, HooksTemplateInitializer) {
1257 SetFunctions(kFunctions);
1258
1259 // Register a hook for the test.oneString method.
1260 auto hooks = base::MakeUnique<APIBindingHooksTestDelegate>();
1261 auto hook = [](v8::Isolate* isolate,
1262 v8::Local<v8::ObjectTemplate> object_template,
1263 const APITypeReferenceMap& type_refs) {
1264 object_template->Set(gin::StringToSymbol(isolate, "hookedProperty"),
1265 gin::ConvertToV8(isolate, 42));
1266 };
1267 hooks->SetTemplateInitializer(base::Bind(hook));
1268 SetHooksDelegate(std::move(hooks));
1269
1270 InitializeBinding();
1271
1272 v8::HandleScope handle_scope(isolate());
1273 v8::Local<v8::Context> context = MainContext();
1274
1275 v8::Local<v8::Object> binding_object =
1276 binding()->CreateInstance(context, base::Bind(&AllowAllAPIs));
1277
1278 // The extra property should be present on the binding object.
1279 EXPECT_EQ("42", GetStringPropertyFromObject(binding_object, context,
1280 "hookedProperty"));
1281 // Sanity check: other values should still be there.
1282 EXPECT_EQ("function",
1283 GetStringPropertyFromObject(binding_object, context, "oneString"));
1284 }
1285
1256 } // namespace extensions 1286 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698