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

Unified Diff: extensions/renderer/api_binding_unittest.cc

Issue 2438623002: [Extensions Bindings] Add APIBindingsSystem (Closed)
Patch Set: rebase Created 4 years, 2 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 dcab7de1707c02cbe819586ef5e179a8e7923b98..23e72b8905a9406f6f27f0088f75c09df6b41dd9 100644
--- a/extensions/renderer/api_binding_unittest.cc
+++ b/extensions/renderer/api_binding_unittest.cc
@@ -340,60 +340,4 @@ TEST_F(APIBindingTest, TypeRefsTest) {
ExpectFailure(binding_object, "obj.takesRefEnum('gamma')", kError);
}
-// TODO(devlin): Once we have an object that encompasses all these pieces (the
-// APIBinding, ArgumentSpec::RefMap, and APIRequestHandler), we should move this
-// test.
-TEST_F(APIBindingTest, Callbacks) {
- const char kTestCall[] =
- "obj.functionWithCallback('foo', function() {\n"
- " this.callbackArguments = Array.from(arguments);\n"
- "});";
-
- const char kFunctionSpec[] =
- "[{"
- " 'name': 'functionWithCallback',"
- " 'parameters': [{"
- " 'name': 'str',"
- " 'type': 'string'"
- " }, {"
- " 'name': 'callback',"
- " 'type': 'function'"
- " }]"
- "}]";
-
- std::unique_ptr<base::ListValue> functions =
- ListValueFromString(kFunctionSpec);
- ASSERT_TRUE(functions);
- ArgumentSpec::RefMap refs;
- APIBinding binding(
- "test", *functions, base::ListValue(),
- base::Bind(&APIBindingTest::OnFunctionCall, base::Unretained(this)),
- &refs);
-
- v8::Isolate* isolate = instance_->isolate();
-
- v8::HandleScope handle_scope(isolate);
- v8::Local<v8::Context> context =
- v8::Local<v8::Context>::New(isolate, context_);
-
- v8::Local<v8::Object> binding_object =
- binding.CreateInstance(context, isolate);
-
- ExpectPass(binding_object, kTestCall, "['foo']");
- ASSERT_FALSE(last_request_id().empty());
- const char kResponseArgsJson[] = "['response',1,{'key':42}]";
- std::unique_ptr<base::ListValue> expected_args =
- ListValueFromString(kResponseArgsJson);
- request_handler()->CompleteRequest(last_request_id(), *expected_args);
-
- v8::Local<v8::Value> res;
- ASSERT_TRUE(context->Global()
- ->Get(context, gin::StringToV8(isolate, "callbackArguments"))
- .ToLocal(&res));
-
- std::unique_ptr<base::Value> out_val = V8ToBaseValue(res, context);
- ASSERT_TRUE(out_val);
- EXPECT_EQ(ReplaceSingleQuotes(kResponseArgsJson), ValueToString(*out_val));
-}
-
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698