| 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 // Test that the rules schema behaves properly. This is designed to be more of | 113 // Test that the rules schema behaves properly. This is designed to be more of |
| 114 // a sanity check than a comprehensive test, since it mostly delegates the logic | 114 // a sanity check than a comprehensive test, since it mostly delegates the logic |
| 115 // out to ArgumentSpec. | 115 // out to ArgumentSpec. |
| 116 TEST_F(DeclarativeEventTest, TestRulesSchema) { | 116 TEST_F(DeclarativeEventTest, TestRulesSchema) { |
| 117 v8::HandleScope handle_scope(isolate()); | 117 v8::HandleScope handle_scope(isolate()); |
| 118 v8::Local<v8::Context> context = MainContext(); | 118 v8::Local<v8::Context> context = MainContext(); |
| 119 | 119 |
| 120 gin::Handle<DeclarativeEvent> emitter = gin::CreateHandle( | 120 gin::Handle<DeclarativeEvent> emitter = gin::CreateHandle( |
| 121 context->GetIsolate(), | 121 context->GetIsolate(), |
| 122 new DeclarativeEvent("declEvent", type_refs(), request_handler(), | 122 new DeclarativeEvent("declEvent", type_refs(), request_handler(), |
| 123 {"action1", "action2"}, {"condition"})); | 123 {"action1", "action2"}, {"condition"}, 0)); |
| 124 | 124 |
| 125 v8::Local<v8::Value> emitter_value = emitter.ToV8(); | 125 v8::Local<v8::Value> emitter_value = emitter.ToV8(); |
| 126 | 126 |
| 127 const char kAddRules[] = | 127 const char kAddRules[] = |
| 128 "(function(event) {\n" | 128 "(function(event) {\n" |
| 129 " var rules = %s;\n" | 129 " var rules = %s;\n" |
| 130 " event.addRules(rules);\n" | 130 " event.addRules(rules);\n" |
| 131 "})"; | 131 "})"; |
| 132 | 132 |
| 133 { | 133 { |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 "})"; | 249 "})"; |
| 250 v8::Local<v8::Function> remove_rules = | 250 v8::Local<v8::Function> remove_rules = |
| 251 FunctionFromString(context, kGetRules); | 251 FunctionFromString(context, kGetRules); |
| 252 RunFunctionOnGlobal(remove_rules, context, arraysize(args), args); | 252 RunFunctionOnGlobal(remove_rules, context, arraysize(args), args); |
| 253 ValidateLastRequest("events.getRules", "['alpha.declarativeEvent',0,null]"); | 253 ValidateLastRequest("events.getRules", "['alpha.declarativeEvent',0,null]"); |
| 254 reset_last_request(); | 254 reset_last_request(); |
| 255 } | 255 } |
| 256 } | 256 } |
| 257 | 257 |
| 258 } // namespace extensions | 258 } // namespace extensions |
| OLD | NEW |