OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/declarative_event.h" | 5 #include "extensions/renderer/declarative_event.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 {"events", events_schema.data()}}; | 192 {"events", events_schema.data()}}; |
193 } | 193 } |
194 }; | 194 }; |
195 | 195 |
196 // Test all methods of declarative events. | 196 // Test all methods of declarative events. |
197 TEST_F(DeclarativeEventWithSchemaTest, TestAllMethods) { | 197 TEST_F(DeclarativeEventWithSchemaTest, TestAllMethods) { |
198 v8::HandleScope handle_scope(isolate()); | 198 v8::HandleScope handle_scope(isolate()); |
199 v8::Local<v8::Context> context = MainContext(); | 199 v8::Local<v8::Context> context = MainContext(); |
200 | 200 |
201 v8::Local<v8::Object> api = bindings_system()->CreateAPIInstance( | 201 v8::Local<v8::Object> api = bindings_system()->CreateAPIInstance( |
202 kDeclarativeAPIName, context, isolate(), base::Bind(&AllowAllAPIs), | 202 kDeclarativeAPIName, context, base::Bind(&AllowAllAPIs), nullptr); |
203 nullptr); | |
204 ASSERT_FALSE(api.IsEmpty()); | 203 ASSERT_FALSE(api.IsEmpty()); |
205 | 204 |
206 v8::Local<v8::Value> declarative_event = | 205 v8::Local<v8::Value> declarative_event = |
207 GetPropertyFromObject(api, context, "declarativeEvent"); | 206 GetPropertyFromObject(api, context, "declarativeEvent"); |
208 ASSERT_FALSE(declarative_event.IsEmpty()); | 207 ASSERT_FALSE(declarative_event.IsEmpty()); |
209 ASSERT_TRUE(declarative_event->IsObject()); | 208 ASSERT_TRUE(declarative_event->IsObject()); |
210 v8::Local<v8::Value> add_rules = GetPropertyFromObject( | 209 v8::Local<v8::Value> add_rules = GetPropertyFromObject( |
211 declarative_event.As<v8::Object>(), context, "addRules"); | 210 declarative_event.As<v8::Object>(), context, "addRules"); |
212 ASSERT_FALSE(add_rules.IsEmpty()); | 211 ASSERT_FALSE(add_rules.IsEmpty()); |
213 ASSERT_TRUE(add_rules->IsFunction()); | 212 ASSERT_TRUE(add_rules->IsFunction()); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 "})"; | 253 "})"; |
255 v8::Local<v8::Function> remove_rules = | 254 v8::Local<v8::Function> remove_rules = |
256 FunctionFromString(context, kGetRules); | 255 FunctionFromString(context, kGetRules); |
257 RunFunctionOnGlobal(remove_rules, context, arraysize(args), args); | 256 RunFunctionOnGlobal(remove_rules, context, arraysize(args), args); |
258 ValidateLastRequest("events.getRules", "['alpha.declarativeEvent',0,null]"); | 257 ValidateLastRequest("events.getRules", "['alpha.declarativeEvent',0,null]"); |
259 reset_last_request(); | 258 reset_last_request(); |
260 } | 259 } |
261 } | 260 } |
262 | 261 |
263 } // namespace extensions | 262 } // namespace extensions |
OLD | NEW |