OLD | NEW |
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 "extensions/renderer/bindings/api_bindings_system.h" | 5 #include "extensions/renderer/bindings/api_bindings_system.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 " 'functions': [{" | 87 " 'functions': [{" |
88 " 'name': 'functionWithExternalRef'," | 88 " 'name': 'functionWithExternalRef'," |
89 " 'parameters': [{ 'name': 'someRef', '$ref': 'alpha.objRef' }]" | 89 " 'parameters': [{ 'name': 'someRef', '$ref': 'alpha.objRef' }]" |
90 " }]" | 90 " }]" |
91 "}"; | 91 "}"; |
92 | 92 |
93 bool AllowAllAPIs(v8::Local<v8::Context> context, const std::string& name) { | 93 bool AllowAllAPIs(v8::Local<v8::Context> context, const std::string& name) { |
94 return true; | 94 return true; |
95 } | 95 } |
96 | 96 |
| 97 void DoNothingWithSilentRequest( |
| 98 v8::Local<v8::Context> context, |
| 99 const std::string& call_name, |
| 100 const std::vector<v8::Local<v8::Value>>& arguments) {} |
| 101 |
97 } // namespace | 102 } // namespace |
98 | 103 |
99 APIBindingsSystemTest::APIBindingsSystemTest() {} | 104 APIBindingsSystemTest::APIBindingsSystemTest() {} |
100 APIBindingsSystemTest::~APIBindingsSystemTest() = default; | 105 APIBindingsSystemTest::~APIBindingsSystemTest() = default; |
101 | 106 |
102 void APIBindingsSystemTest::SetUp() { | 107 void APIBindingsSystemTest::SetUp() { |
103 APIBindingTest::SetUp(); | 108 APIBindingTest::SetUp(); |
104 | 109 |
105 // Create the fake API schemas. | 110 // Create the fake API schemas. |
106 for (const auto& api : GetAPIs()) { | 111 for (const auto& api : GetAPIs()) { |
107 std::unique_ptr<base::DictionaryValue> api_schema = | 112 std::unique_ptr<base::DictionaryValue> api_schema = |
108 DictionaryValueFromString(api.spec); | 113 DictionaryValueFromString(api.spec); |
109 ASSERT_TRUE(api_schema); | 114 ASSERT_TRUE(api_schema); |
110 api_schemas_[api.name] = std::move(api_schema); | 115 api_schemas_[api.name] = std::move(api_schema); |
111 } | 116 } |
112 | 117 |
113 bindings_system_ = base::MakeUnique<APIBindingsSystem>( | 118 bindings_system_ = base::MakeUnique<APIBindingsSystem>( |
114 base::Bind(&RunFunctionOnGlobalAndIgnoreResult), | 119 base::Bind(&RunFunctionOnGlobalAndIgnoreResult), |
115 base::Bind(&RunFunctionOnGlobalAndReturnHandle), | 120 base::Bind(&RunFunctionOnGlobalAndReturnHandle), |
116 base::Bind(&APIBindingsSystemTest::GetAPISchema, base::Unretained(this)), | 121 base::Bind(&APIBindingsSystemTest::GetAPISchema, base::Unretained(this)), |
117 base::Bind(&AllowAllAPIs), | 122 base::Bind(&AllowAllAPIs), |
118 base::Bind(&APIBindingsSystemTest::OnAPIRequest, base::Unretained(this)), | 123 base::Bind(&APIBindingsSystemTest::OnAPIRequest, base::Unretained(this)), |
119 base::Bind(&APIBindingsSystemTest::OnEventListenersChanged, | 124 base::Bind(&APIBindingsSystemTest::OnEventListenersChanged, |
120 base::Unretained(this)), | 125 base::Unretained(this)), |
| 126 base::Bind(&DoNothingWithSilentRequest), |
121 APILastError(base::Bind(&APIBindingsSystemTest::GetLastErrorParent, | 127 APILastError(base::Bind(&APIBindingsSystemTest::GetLastErrorParent, |
122 base::Unretained(this)), | 128 base::Unretained(this)), |
123 APILastError::AddConsoleError())); | 129 APILastError::AddConsoleError())); |
124 } | 130 } |
125 | 131 |
126 void APIBindingsSystemTest::TearDown() { | 132 void APIBindingsSystemTest::TearDown() { |
127 // Dispose all contexts now so that we call WillReleaseContext(). | 133 // Dispose all contexts now so that we call WillReleaseContext(). |
128 DisposeAllContexts(); | 134 DisposeAllContexts(); |
129 bindings_system_.reset(); | 135 bindings_system_.reset(); |
130 APIBindingTest::TearDown(); | 136 APIBindingTest::TearDown(); |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 v8::Local<v8::Value> other_event = | 476 v8::Local<v8::Value> other_event = |
471 GetPropertyFromObject(api, context, "alphaOtherEvent"); | 477 GetPropertyFromObject(api, context, "alphaOtherEvent"); |
472 ASSERT_TRUE(other_event->IsObject()); | 478 ASSERT_TRUE(other_event->IsObject()); |
473 EXPECT_EQ("\"alpha.alphaOtherEvent\"", | 479 EXPECT_EQ("\"alpha.alphaOtherEvent\"", |
474 GetStringPropertyFromObject(other_event.As<v8::Object>(), context, | 480 GetStringPropertyFromObject(other_event.As<v8::Object>(), context, |
475 "name")); | 481 "name")); |
476 EXPECT_NE(event, other_event); | 482 EXPECT_NE(event, other_event); |
477 } | 483 } |
478 | 484 |
479 } // namespace extensions | 485 } // namespace extensions |
OLD | NEW |