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

Side by Side Diff: extensions/renderer/bindings/event_emitter_unittest.cc

Issue 2973903002: [Extensions Bindings] Introduce a supportsLazyListeners property (Closed)
Patch Set: onMessage event fix Created 3 years, 5 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 unified diff | Download patch
OLDNEW
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/bindings/event_emitter.h" 5 #include "extensions/renderer/bindings/event_emitter.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "extensions/renderer/bindings/api_binding_test.h" 10 #include "extensions/renderer/bindings/api_binding_test.h"
(...skipping 12 matching lines...) Expand all
23 23
24 } // namespace 24 } // namespace
25 25
26 using EventEmitterUnittest = APIBindingTest; 26 using EventEmitterUnittest = APIBindingTest;
27 27
28 TEST_F(EventEmitterUnittest, TestDispatchMethod) { 28 TEST_F(EventEmitterUnittest, TestDispatchMethod) {
29 v8::HandleScope handle_scope(isolate()); 29 v8::HandleScope handle_scope(isolate());
30 v8::Local<v8::Context> context = MainContext(); 30 v8::Local<v8::Context> context = MainContext();
31 31
32 auto listeners = base::MakeUnique<UnfilteredEventListeners>( 32 auto listeners = base::MakeUnique<UnfilteredEventListeners>(
33 base::Bind(&DoNothingOnListenerChange), binding::kNoListenerMax); 33 base::Bind(&DoNothingOnListenerChange), binding::kNoListenerMax, true);
34 34
35 // The test util methods enforce that functions always throw or always don't 35 // The test util methods enforce that functions always throw or always don't
36 // throw, but we test listeners that do both. Provide implementations for 36 // throw, but we test listeners that do both. Provide implementations for
37 // running functions that don't enforce throw behavior. 37 // running functions that don't enforce throw behavior.
38 auto run_js_sync = [](v8::Local<v8::Function> function, 38 auto run_js_sync = [](v8::Local<v8::Function> function,
39 v8::Local<v8::Context> context, int argc, 39 v8::Local<v8::Context> context, int argc,
40 v8::Local<v8::Value> argv[]) { 40 v8::Local<v8::Value> argv[]) {
41 v8::Global<v8::Value> global_result; 41 v8::Global<v8::Value> global_result;
42 v8::Local<v8::Value> result; 42 v8::Local<v8::Value> result;
43 if (function->Call(context, context->Global(), argc, argv).ToLocal(&result)) 43 if (function->Call(context, context->Global(), argc, argv).ToLocal(&result))
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 context->Global(), context, property)); 123 context->Global(), context, property));
124 } 124 }
125 EXPECT_EQ("{\"results\":[\"listener1\",{\"listener\":\"listener2\"}]}", 125 EXPECT_EQ("{\"results\":[\"listener1\",{\"listener\":\"listener2\"}]}",
126 V8ToString(dispatch_result, context)); 126 V8ToString(dispatch_result, context));
127 127
128 ASSERT_EQ(1u, logged_errors.size()); 128 ASSERT_EQ(1u, logged_errors.size());
129 EXPECT_EQ("Error in event handler: Uncaught Error: hahaha", logged_errors[0]); 129 EXPECT_EQ("Error in event handler: Uncaught Error: hahaha", logged_errors[0]);
130 } 130 }
131 131
132 } // namespace extensions 132 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/bindings/api_event_listeners_unittest.cc ('k') | extensions/renderer/chrome_setting.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698