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

Side by Side Diff: extensions/renderer/bindings/api_event_listeners_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/api_event_listeners.h" 5 #include "extensions/renderer/bindings/api_event_listeners.h"
6 6
7 #include "base/test/mock_callback.h" 7 #include "base/test/mock_callback.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "extensions/common/event_filter.h" 9 #include "extensions/common/event_filter.h"
10 #include "extensions/renderer/bindings/api_binding_test.h" 10 #include "extensions/renderer/bindings/api_binding_test.h"
(...skipping 18 matching lines...) Expand all
29 const char kEvent[] = "event"; 29 const char kEvent[] = "event";
30 30
31 } // namespace 31 } // namespace
32 32
33 // Test unfiltered listeners. 33 // Test unfiltered listeners.
34 TEST_F(APIEventListenersTest, UnfilteredListeners) { 34 TEST_F(APIEventListenersTest, UnfilteredListeners) {
35 v8::HandleScope handle_scope(isolate()); 35 v8::HandleScope handle_scope(isolate());
36 v8::Local<v8::Context> context = MainContext(); 36 v8::Local<v8::Context> context = MainContext();
37 37
38 MockEventChangeHandler handler; 38 MockEventChangeHandler handler;
39 UnfilteredEventListeners listeners(handler.Get(), binding::kNoListenerMax); 39 UnfilteredEventListeners listeners(handler.Get(), binding::kNoListenerMax,
40 true);
40 41
41 // Starting out, there should be no listeners. 42 // Starting out, there should be no listeners.
42 v8::Local<v8::Function> function_a = FunctionFromString(context, kFunction); 43 v8::Local<v8::Function> function_a = FunctionFromString(context, kFunction);
43 EXPECT_EQ(0u, listeners.GetNumListeners()); 44 EXPECT_EQ(0u, listeners.GetNumListeners());
44 EXPECT_FALSE(listeners.HasListener(function_a)); 45 EXPECT_FALSE(listeners.HasListener(function_a));
45 46
46 std::string error; 47 std::string error;
47 v8::Local<v8::Object> filter; 48 v8::Local<v8::Object> filter;
48 49
49 // Adding a new listener should trigger the callback (0 -> 1). 50 // Adding a new listener should trigger the callback (0 -> 1).
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 EXPECT_EQ(0u, listeners.GetNumListeners()); 101 EXPECT_EQ(0u, listeners.GetNumListeners());
101 EXPECT_TRUE(listeners.GetListeners(nullptr, context).empty()); 102 EXPECT_TRUE(listeners.GetListeners(nullptr, context).empty());
102 } 103 }
103 104
104 // Tests the invalidation of unfiltered listeners. 105 // Tests the invalidation of unfiltered listeners.
105 TEST_F(APIEventListenersTest, UnfilteredListenersInvalidation) { 106 TEST_F(APIEventListenersTest, UnfilteredListenersInvalidation) {
106 v8::HandleScope handle_scope(isolate()); 107 v8::HandleScope handle_scope(isolate());
107 v8::Local<v8::Context> context = MainContext(); 108 v8::Local<v8::Context> context = MainContext();
108 109
109 MockEventChangeHandler handler; 110 MockEventChangeHandler handler;
110 UnfilteredEventListeners listeners(handler.Get(), binding::kNoListenerMax); 111 UnfilteredEventListeners listeners(handler.Get(), binding::kNoListenerMax,
112 true);
111 113
112 listeners.Invalidate(context); 114 listeners.Invalidate(context);
113 115
114 v8::Local<v8::Function> function_a = FunctionFromString(context, kFunction); 116 v8::Local<v8::Function> function_a = FunctionFromString(context, kFunction);
115 v8::Local<v8::Function> function_b = FunctionFromString(context, kFunction); 117 v8::Local<v8::Function> function_b = FunctionFromString(context, kFunction);
116 std::string error; 118 std::string error;
117 v8::Local<v8::Object> filter; 119 v8::Local<v8::Object> filter;
118 EXPECT_CALL(handler, Run(binding::EventListenersChanged::HAS_LISTENERS, 120 EXPECT_CALL(handler, Run(binding::EventListenersChanged::HAS_LISTENERS,
119 nullptr, true, context)); 121 nullptr, true, context));
120 EXPECT_TRUE(listeners.AddListener(function_a, filter, context, &error)); 122 EXPECT_TRUE(listeners.AddListener(function_a, filter, context, &error));
121 ::testing::Mock::VerifyAndClearExpectations(&handler); 123 ::testing::Mock::VerifyAndClearExpectations(&handler);
122 EXPECT_TRUE(listeners.AddListener(function_b, filter, context, &error)); 124 EXPECT_TRUE(listeners.AddListener(function_b, filter, context, &error));
123 125
124 EXPECT_CALL(handler, Run(binding::EventListenersChanged::NO_LISTENERS, 126 EXPECT_CALL(handler, Run(binding::EventListenersChanged::NO_LISTENERS,
125 nullptr, false, context)); 127 nullptr, false, context));
126 listeners.Invalidate(context); 128 listeners.Invalidate(context);
127 ::testing::Mock::VerifyAndClearExpectations(&handler); 129 ::testing::Mock::VerifyAndClearExpectations(&handler);
128 130
129 EXPECT_EQ(0u, listeners.GetNumListeners()); 131 EXPECT_EQ(0u, listeners.GetNumListeners());
130 } 132 }
131 133
132 // Tests that unfiltered listeners ignore the filtering info. 134 // Tests that unfiltered listeners ignore the filtering info.
133 TEST_F(APIEventListenersTest, UnfilteredListenersIgnoreFilteringInfo) { 135 TEST_F(APIEventListenersTest, UnfilteredListenersIgnoreFilteringInfo) {
134 v8::HandleScope handle_scope(isolate()); 136 v8::HandleScope handle_scope(isolate());
135 v8::Local<v8::Context> context = MainContext(); 137 v8::Local<v8::Context> context = MainContext();
136 138
137 UnfilteredEventListeners listeners(base::Bind(&DoNothingOnUpdate), 139 UnfilteredEventListeners listeners(base::Bind(&DoNothingOnUpdate),
138 binding::kNoListenerMax); 140 binding::kNoListenerMax, true);
139 v8::Local<v8::Function> function = FunctionFromString(context, kFunction); 141 v8::Local<v8::Function> function = FunctionFromString(context, kFunction);
140 std::string error; 142 std::string error;
141 v8::Local<v8::Object> filter; 143 v8::Local<v8::Object> filter;
142 EXPECT_TRUE(listeners.AddListener(function, filter, context, &error)); 144 EXPECT_TRUE(listeners.AddListener(function, filter, context, &error));
143 EventFilteringInfo filtering_info; 145 EventFilteringInfo filtering_info;
144 filtering_info.url = GURL("http://example.com/foo"); 146 filtering_info.url = GURL("http://example.com/foo");
145 EXPECT_THAT(listeners.GetListeners(&filtering_info, context), 147 EXPECT_THAT(listeners.GetListeners(&filtering_info, context),
146 testing::UnorderedElementsAre(function)); 148 testing::UnorderedElementsAre(function));
147 } 149 }
148 150
149 TEST_F(APIEventListenersTest, UnfilteredListenersMaxListenersTest) { 151 TEST_F(APIEventListenersTest, UnfilteredListenersMaxListenersTest) {
150 v8::HandleScope handle_scope(isolate()); 152 v8::HandleScope handle_scope(isolate());
151 v8::Local<v8::Context> context = MainContext(); 153 v8::Local<v8::Context> context = MainContext();
152 154
153 UnfilteredEventListeners listeners(base::Bind(&DoNothingOnUpdate), 1); 155 UnfilteredEventListeners listeners(base::Bind(&DoNothingOnUpdate), 1, true);
154 156
155 v8::Local<v8::Function> function_a = FunctionFromString(context, kFunction); 157 v8::Local<v8::Function> function_a = FunctionFromString(context, kFunction);
156 EXPECT_EQ(0u, listeners.GetNumListeners()); 158 EXPECT_EQ(0u, listeners.GetNumListeners());
157 159
158 std::string error; 160 std::string error;
159 v8::Local<v8::Object> filter; 161 v8::Local<v8::Object> filter;
160 EXPECT_TRUE(listeners.AddListener(function_a, filter, context, &error)); 162 EXPECT_TRUE(listeners.AddListener(function_a, filter, context, &error));
161 EXPECT_TRUE(listeners.HasListener(function_a)); 163 EXPECT_TRUE(listeners.HasListener(function_a));
162 EXPECT_EQ(1u, listeners.GetNumListeners()); 164 EXPECT_EQ(1u, listeners.GetNumListeners());
163 165
164 v8::Local<v8::Function> function_b = FunctionFromString(context, kFunction); 166 v8::Local<v8::Function> function_b = FunctionFromString(context, kFunction);
165 EXPECT_FALSE(listeners.AddListener(function_b, filter, context, &error)); 167 EXPECT_FALSE(listeners.AddListener(function_b, filter, context, &error));
166 EXPECT_FALSE(error.empty()); 168 EXPECT_FALSE(error.empty());
167 EXPECT_FALSE(listeners.HasListener(function_b)); 169 EXPECT_FALSE(listeners.HasListener(function_b));
168 EXPECT_TRUE(listeners.HasListener(function_a)); 170 EXPECT_TRUE(listeners.HasListener(function_a));
169 EXPECT_EQ(1u, listeners.GetNumListeners()); 171 EXPECT_EQ(1u, listeners.GetNumListeners());
170 } 172 }
171 173
174 TEST_F(APIEventListenersTest, UnfilteredListenersLazyListeners) {
175 v8::HandleScope handle_scope(isolate());
176 v8::Local<v8::Context> context = MainContext();
177
178 MockEventChangeHandler handler;
179 UnfilteredEventListeners listeners(handler.Get(), binding::kNoListenerMax,
180 false);
181
182 v8::Local<v8::Function> listener = FunctionFromString(context, kFunction);
183 std::string error;
184 EXPECT_CALL(handler, Run(binding::EventListenersChanged::HAS_LISTENERS,
185 nullptr, false, context));
186 listeners.AddListener(listener, v8::Local<v8::Object>(), context, &error);
187 ::testing::Mock::VerifyAndClearExpectations(&handler);
188
189 EXPECT_CALL(handler, Run(binding::EventListenersChanged::NO_LISTENERS,
190 nullptr, false, context));
191 listeners.RemoveListener(listener, context);
192 ::testing::Mock::VerifyAndClearExpectations(&handler);
193 }
194
172 // Tests filtered listeners. 195 // Tests filtered listeners.
173 TEST_F(APIEventListenersTest, FilteredListeners) { 196 TEST_F(APIEventListenersTest, FilteredListeners) {
174 v8::HandleScope handle_scope(isolate()); 197 v8::HandleScope handle_scope(isolate());
175 v8::Local<v8::Context> context = MainContext(); 198 v8::Local<v8::Context> context = MainContext();
176 199
177 MockEventChangeHandler handler; 200 MockEventChangeHandler handler;
178 EventFilter event_filter; 201 EventFilter event_filter;
179 FilteredEventListeners listeners(handler.Get(), kEvent, 202 FilteredEventListeners listeners(
180 binding::kNoListenerMax, &event_filter); 203 handler.Get(), kEvent, binding::kNoListenerMax, true, &event_filter);
181 204
182 // Starting out, there should be no listeners registered. 205 // Starting out, there should be no listeners registered.
183 v8::Local<v8::Function> function_a = FunctionFromString(context, kFunction); 206 v8::Local<v8::Function> function_a = FunctionFromString(context, kFunction);
184 EXPECT_EQ(0u, listeners.GetNumListeners()); 207 EXPECT_EQ(0u, listeners.GetNumListeners());
185 EXPECT_EQ(0, event_filter.GetMatcherCountForEventForTesting(kEvent)); 208 EXPECT_EQ(0, event_filter.GetMatcherCountForEventForTesting(kEvent));
186 EXPECT_FALSE(listeners.HasListener(function_a)); 209 EXPECT_FALSE(listeners.HasListener(function_a));
187 210
188 v8::Local<v8::Object> empty_filter; 211 v8::Local<v8::Object> empty_filter;
189 std::string error; 212 std::string error;
190 213
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 320
298 // Tests that adding multiple listeners with the same filter doesn't trigger 321 // Tests that adding multiple listeners with the same filter doesn't trigger
299 // the update callback. 322 // the update callback.
300 TEST_F(APIEventListenersTest, 323 TEST_F(APIEventListenersTest,
301 UnfilteredListenersWithSameFilterDontTriggerUpdate) { 324 UnfilteredListenersWithSameFilterDontTriggerUpdate) {
302 v8::HandleScope handle_scope(isolate()); 325 v8::HandleScope handle_scope(isolate());
303 v8::Local<v8::Context> context = MainContext(); 326 v8::Local<v8::Context> context = MainContext();
304 327
305 MockEventChangeHandler handler; 328 MockEventChangeHandler handler;
306 EventFilter event_filter; 329 EventFilter event_filter;
307 FilteredEventListeners listeners(handler.Get(), kEvent, 330 FilteredEventListeners listeners(
308 binding::kNoListenerMax, &event_filter); 331 handler.Get(), kEvent, binding::kNoListenerMax, true, &event_filter);
309 332
310 auto get_filter = [context]() { 333 auto get_filter = [context]() {
311 return V8ValueFromScriptSource(context, "({url: [{pathContains: 'foo'}]})") 334 return V8ValueFromScriptSource(context, "({url: [{pathContains: 'foo'}]})")
312 .As<v8::Object>(); 335 .As<v8::Object>();
313 }; 336 };
314 337
315 v8::Local<v8::Function> function_a = FunctionFromString(context, kFunction); 338 v8::Local<v8::Function> function_a = FunctionFromString(context, kFunction);
316 339
317 std::string error; 340 std::string error;
318 EXPECT_CALL(handler, Run(binding::EventListenersChanged::HAS_LISTENERS, 341 EXPECT_CALL(handler, Run(binding::EventListenersChanged::HAS_LISTENERS,
(...skipping 25 matching lines...) Expand all
344 EXPECT_EQ(0, event_filter.GetMatcherCountForEventForTesting(kEvent)); 367 EXPECT_EQ(0, event_filter.GetMatcherCountForEventForTesting(kEvent));
345 } 368 }
346 369
347 // Tests that trying to add a listener with an invalid filter fails. 370 // Tests that trying to add a listener with an invalid filter fails.
348 TEST_F(APIEventListenersTest, UnfilteredListenersError) { 371 TEST_F(APIEventListenersTest, UnfilteredListenersError) {
349 v8::HandleScope handle_scope(isolate()); 372 v8::HandleScope handle_scope(isolate());
350 v8::Local<v8::Context> context = MainContext(); 373 v8::Local<v8::Context> context = MainContext();
351 374
352 EventFilter event_filter; 375 EventFilter event_filter;
353 FilteredEventListeners listeners(base::Bind(&DoNothingOnUpdate), kEvent, 376 FilteredEventListeners listeners(base::Bind(&DoNothingOnUpdate), kEvent,
354 binding::kNoListenerMax, &event_filter); 377 binding::kNoListenerMax, true,
378 &event_filter);
355 379
356 v8::Local<v8::Object> invalid_filter = 380 v8::Local<v8::Object> invalid_filter =
357 V8ValueFromScriptSource(context, "({url: 'some string'})") 381 V8ValueFromScriptSource(context, "({url: 'some string'})")
358 .As<v8::Object>(); 382 .As<v8::Object>();
359 v8::Local<v8::Function> function = FunctionFromString(context, kFunction); 383 v8::Local<v8::Function> function = FunctionFromString(context, kFunction);
360 std::string error; 384 std::string error;
361 EXPECT_FALSE( 385 EXPECT_FALSE(
362 listeners.AddListener(function, invalid_filter, context, &error)); 386 listeners.AddListener(function, invalid_filter, context, &error));
363 EXPECT_FALSE(error.empty()); 387 EXPECT_FALSE(error.empty());
364 } 388 }
365 389
366 // Tests that adding listeners for multiple different events is correctly 390 // Tests that adding listeners for multiple different events is correctly
367 // recorded in the EventFilter. 391 // recorded in the EventFilter.
368 TEST_F(APIEventListenersTest, MultipleUnfilteredListenerEvents) { 392 TEST_F(APIEventListenersTest, MultipleUnfilteredListenerEvents) {
369 v8::HandleScope handle_scope(isolate()); 393 v8::HandleScope handle_scope(isolate());
370 v8::Local<v8::Context> context = MainContext(); 394 v8::Local<v8::Context> context = MainContext();
371 395
372 const char kAlpha[] = "alpha"; 396 const char kAlpha[] = "alpha";
373 const char kBeta[] = "beta"; 397 const char kBeta[] = "beta";
374 398
375 EventFilter event_filter; 399 EventFilter event_filter;
376 FilteredEventListeners listeners_a(base::Bind(&DoNothingOnUpdate), kAlpha, 400 FilteredEventListeners listeners_a(base::Bind(&DoNothingOnUpdate), kAlpha,
377 binding::kNoListenerMax, &event_filter); 401 binding::kNoListenerMax, true,
402 &event_filter);
378 FilteredEventListeners listeners_b(base::Bind(&DoNothingOnUpdate), kBeta, 403 FilteredEventListeners listeners_b(base::Bind(&DoNothingOnUpdate), kBeta,
379 binding::kNoListenerMax, &event_filter); 404 binding::kNoListenerMax, true,
405 &event_filter);
380 406
381 EXPECT_EQ(0, event_filter.GetMatcherCountForEventForTesting(kAlpha)); 407 EXPECT_EQ(0, event_filter.GetMatcherCountForEventForTesting(kAlpha));
382 EXPECT_EQ(0, event_filter.GetMatcherCountForEventForTesting(kBeta)); 408 EXPECT_EQ(0, event_filter.GetMatcherCountForEventForTesting(kBeta));
383 409
384 std::string error; 410 std::string error;
385 v8::Local<v8::Object> filter; 411 v8::Local<v8::Object> filter;
386 412
387 v8::Local<v8::Function> function_a = FunctionFromString(context, kFunction); 413 v8::Local<v8::Function> function_a = FunctionFromString(context, kFunction);
388 EXPECT_TRUE(listeners_a.AddListener(function_a, filter, context, &error)); 414 EXPECT_TRUE(listeners_a.AddListener(function_a, filter, context, &error));
389 EXPECT_EQ(1, event_filter.GetMatcherCountForEventForTesting(kAlpha)); 415 EXPECT_EQ(1, event_filter.GetMatcherCountForEventForTesting(kAlpha));
(...skipping 13 matching lines...) Expand all
403 EXPECT_EQ(0, event_filter.GetMatcherCountForEventForTesting(kBeta)); 429 EXPECT_EQ(0, event_filter.GetMatcherCountForEventForTesting(kBeta));
404 } 430 }
405 431
406 // Tests the invalidation of filtered listeners. 432 // Tests the invalidation of filtered listeners.
407 TEST_F(APIEventListenersTest, FilteredListenersInvalidation) { 433 TEST_F(APIEventListenersTest, FilteredListenersInvalidation) {
408 v8::HandleScope handle_scope(isolate()); 434 v8::HandleScope handle_scope(isolate());
409 v8::Local<v8::Context> context = MainContext(); 435 v8::Local<v8::Context> context = MainContext();
410 436
411 MockEventChangeHandler handler; 437 MockEventChangeHandler handler;
412 EventFilter event_filter; 438 EventFilter event_filter;
413 FilteredEventListeners listeners(handler.Get(), kEvent, 439 FilteredEventListeners listeners(
414 binding::kNoListenerMax, &event_filter); 440 handler.Get(), kEvent, binding::kNoListenerMax, true, &event_filter);
415 listeners.Invalidate(context); 441 listeners.Invalidate(context);
416 442
417 v8::Local<v8::Object> empty_filter; 443 v8::Local<v8::Object> empty_filter;
418 v8::Local<v8::Object> filter = 444 v8::Local<v8::Object> filter =
419 V8ValueFromScriptSource(context, "({url: [{pathContains: 'foo'}]})") 445 V8ValueFromScriptSource(context, "({url: [{pathContains: 'foo'}]})")
420 .As<v8::Object>(); 446 .As<v8::Object>();
421 std::string error; 447 std::string error;
422 448
423 v8::Local<v8::Function> function_a = FunctionFromString(context, kFunction); 449 v8::Local<v8::Function> function_a = FunctionFromString(context, kFunction);
424 v8::Local<v8::Function> function_b = FunctionFromString(context, kFunction); 450 v8::Local<v8::Function> function_b = FunctionFromString(context, kFunction);
(...skipping 20 matching lines...) Expand all
445 EXPECT_EQ(0u, listeners.GetNumListeners()); 471 EXPECT_EQ(0u, listeners.GetNumListeners());
446 EXPECT_EQ(0, event_filter.GetMatcherCountForEventForTesting(kEvent)); 472 EXPECT_EQ(0, event_filter.GetMatcherCountForEventForTesting(kEvent));
447 } 473 }
448 474
449 TEST_F(APIEventListenersTest, FilteredListenersMaxListenersTest) { 475 TEST_F(APIEventListenersTest, FilteredListenersMaxListenersTest) {
450 v8::HandleScope handle_scope(isolate()); 476 v8::HandleScope handle_scope(isolate());
451 v8::Local<v8::Context> context = MainContext(); 477 v8::Local<v8::Context> context = MainContext();
452 478
453 EventFilter event_filter; 479 EventFilter event_filter;
454 FilteredEventListeners listeners(base::Bind(&DoNothingOnUpdate), kEvent, 1, 480 FilteredEventListeners listeners(base::Bind(&DoNothingOnUpdate), kEvent, 1,
455 &event_filter); 481 true, &event_filter);
456 482
457 v8::Local<v8::Function> function_a = FunctionFromString(context, kFunction); 483 v8::Local<v8::Function> function_a = FunctionFromString(context, kFunction);
458 EXPECT_EQ(0u, listeners.GetNumListeners()); 484 EXPECT_EQ(0u, listeners.GetNumListeners());
459 485
460 std::string error; 486 std::string error;
461 v8::Local<v8::Object> filter; 487 v8::Local<v8::Object> filter;
462 EXPECT_TRUE(listeners.AddListener(function_a, filter, context, &error)); 488 EXPECT_TRUE(listeners.AddListener(function_a, filter, context, &error));
463 EXPECT_TRUE(listeners.HasListener(function_a)); 489 EXPECT_TRUE(listeners.HasListener(function_a));
464 EXPECT_EQ(1u, listeners.GetNumListeners()); 490 EXPECT_EQ(1u, listeners.GetNumListeners());
465 491
466 v8::Local<v8::Function> function_b = FunctionFromString(context, kFunction); 492 v8::Local<v8::Function> function_b = FunctionFromString(context, kFunction);
467 EXPECT_FALSE(listeners.AddListener(function_b, filter, context, &error)); 493 EXPECT_FALSE(listeners.AddListener(function_b, filter, context, &error));
468 EXPECT_FALSE(error.empty()); 494 EXPECT_FALSE(error.empty());
469 EXPECT_FALSE(listeners.HasListener(function_b)); 495 EXPECT_FALSE(listeners.HasListener(function_b));
470 EXPECT_TRUE(listeners.HasListener(function_a)); 496 EXPECT_TRUE(listeners.HasListener(function_a));
471 EXPECT_EQ(1u, listeners.GetNumListeners()); 497 EXPECT_EQ(1u, listeners.GetNumListeners());
472 } 498 }
473 499
500 TEST_F(APIEventListenersTest, FilteredListenersLazyListeners) {
501 v8::HandleScope handle_scope(isolate());
502 v8::Local<v8::Context> context = MainContext();
503
504 MockEventChangeHandler handler;
505 EventFilter event_filter;
506 FilteredEventListeners listeners(
507 handler.Get(), kEvent, binding::kNoListenerMax, false, &event_filter);
508
509 v8::Local<v8::Function> listener = FunctionFromString(context, kFunction);
510 std::string error;
511 EXPECT_CALL(handler, Run(binding::EventListenersChanged::HAS_LISTENERS,
512 testing::NotNull(), false, context));
513 listeners.AddListener(listener, v8::Local<v8::Object>(), context, &error);
514 ::testing::Mock::VerifyAndClearExpectations(&handler);
515
516 EXPECT_CALL(handler, Run(binding::EventListenersChanged::NO_LISTENERS,
517 testing::NotNull(), false, context));
518 listeners.RemoveListener(listener, context);
519 ::testing::Mock::VerifyAndClearExpectations(&handler);
520 }
521
474 } // namespace extensions 522 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/bindings/api_event_listeners.cc ('k') | extensions/renderer/bindings/event_emitter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698