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

Unified Diff: extensions/renderer/api_bindings_system_unittest.cc

Issue 2598123002: [Extensions Bindings] Add support for updateArgumentsPreValidate (Closed)
Patch Set: . Created 4 years 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_bindings_system_unittest.cc
diff --git a/extensions/renderer/api_bindings_system_unittest.cc b/extensions/renderer/api_bindings_system_unittest.cc
index 6586038795caf08f9f40dc5835c7c507297f80f8..c29ebe9910824de5876488245b5c6555ec6733b2 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,
@@ -298,25 +299,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;
};

Powered by Google App Engine
This is Rietveld 408576698