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

Unified Diff: extensions/renderer/api_bindings_system_unittest.cc

Issue 2598123002: [Extensions Bindings] Add support for updateArgumentsPreValidate (Closed)
Patch Set: rebase Created 3 years, 11 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 | « extensions/renderer/api_bindings_system.cc ('k') | extensions/renderer/api_signature.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/api_bindings_system_unittest.cc
diff --git a/extensions/renderer/api_bindings_system_unittest.cc b/extensions/renderer/api_bindings_system_unittest.cc
index 214f2f66a08e733063b422d4799475081d062e35..23906077abc11196bd5003127b9e95e529114ed2 100644
--- a/extensions/renderer/api_bindings_system_unittest.cc
+++ b/extensions/renderer/api_bindings_system_unittest.cc
@@ -98,6 +98,7 @@ class APIBindingsSystemTestBase : public APIBindingTest {
APIBindingTest::SetUp();
bindings_system_ = base::MakeUnique<APIBindingsSystem>(
base::Bind(&RunFunctionOnGlobalAndIgnoreResult),
+ base::Bind(&RunFunctionOnGlobalAndReturnHandle),
base::Bind(&APIBindingsSystemTestBase::GetAPISchema,
base::Unretained(this)),
base::Bind(&APIBindingsSystemTestBase::OnAPIRequest,
@@ -294,25 +295,26 @@ TEST_F(APIBindingsSystemTest, TestCustomHooks) {
v8::Local<v8::Context> context = ContextLocal();
bool did_call = false;
- auto hook = [](bool* did_call, const APISignature* signature,
- gin::Arguments* arguments,
+ auto hook = [](bool* did_call,
+ const APISignature* signature, v8::Local<v8::Context> context,
+ std::vector<v8::Local<v8::Value>>* arguments,
const ArgumentSpec::RefMap& type_refs) {
*did_call = true;
+ if (arguments->size() != 2) { // ASSERT* messes with the return type.
+ EXPECT_EQ(2u, arguments->size());
+ return APIBindingHooks::RequestResult::HANDLED;
+ }
std::string argument;
- EXPECT_EQ(2, arguments->Length());
- EXPECT_TRUE(arguments->GetNext(&argument));
- EXPECT_EQ("foo", argument);
- v8::Local<v8::Function> function;
- EXPECT_TRUE(arguments->GetNext(&function));
- // The above EXPECT_TRUE should really be an ASSERT, but that messes with
- // the return type.
- if (function.IsEmpty())
+ EXPECT_EQ("foo", gin::V8ToString(arguments->at(0)));
+ if (!arguments->at(1)->IsFunction()) {
+ EXPECT_TRUE(arguments->at(1)->IsFunction());
return APIBindingHooks::RequestResult::HANDLED;
+ }
v8::Local<v8::String> response =
- gin::StringToV8(arguments->isolate(), "bar");
+ gin::StringToV8(context->GetIsolate(), "bar");
v8::Local<v8::Value> response_args[] = {response};
- RunFunctionOnGlobal(function, arguments->isolate()->GetCurrentContext(),
- 1, response_args);
+ RunFunctionOnGlobal(arguments->at(1).As<v8::Function>(),
+ context, 1, response_args);
return APIBindingHooks::RequestResult::HANDLED;
};
« no previous file with comments | « extensions/renderer/api_bindings_system.cc ('k') | extensions/renderer/api_signature.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698