Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: chrome/content/tests/filterNotifier.js

Issue 5650509725696000: Issue 261 - FilterNotifier doesn`t support listeners removing themselves when triggered (Closed)
Patch Set: Created April 4, 2014, 12:46 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 (function() 1 (function()
2 { 2 {
3 module("Filter notifier", {setup: prepareFilterComponents, teardown: restoreFi lterComponents}); 3 module("Filter notifier", {setup: prepareFilterComponents, teardown: restoreFi lterComponents});
4 4
5 let triggeredListeners = []; 5 let triggeredListeners = [];
6 let listeners = [ 6 let listeners = [
7 function(action, item) triggeredListeners.push(["listener1", action, item]), 7 function(action, item) triggeredListeners.push(["listener1", action, item]),
8 function(action, item) triggeredListeners.push(["listener2", action, item]), 8 function(action, item) triggeredListeners.push(["listener2", action, item]),
9 function(action, item) triggeredListeners.push(["listener3", action, item]) 9 function(action, item) triggeredListeners.push(["listener3", action, item])
10 ]; 10 ];
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 FilterNotifier.removeListener(listener3); 51 FilterNotifier.removeListener(listener3);
52 compareListeners("removeListener(listener3)", [listener2, listener1]); 52 compareListeners("removeListener(listener3)", [listener2, listener1]);
53 53
54 FilterNotifier.removeListener(listener1); 54 FilterNotifier.removeListener(listener1);
55 compareListeners("removeListener(listener1)", [listener2]); 55 compareListeners("removeListener(listener1)", [listener2]);
56 56
57 FilterNotifier.removeListener(listener2); 57 FilterNotifier.removeListener(listener2);
58 compareListeners("removeListener(listener2)", []); 58 compareListeners("removeListener(listener2)", []);
59 }); 59 });
60
61 test("Removing listeners while being called", function()
62 {
63 let listener1 = function(){
Thomas Greiner 2014/04/07 08:30:49 Nit: Move bracket to new line
64 listeners[0].apply(this, arguments);
65 FilterNotifier.removeListener(listener1);
66 };
67 let listener2 = listeners[1];
68 FilterNotifier.addListener(listener1);
69 FilterNotifier.addListener(listener2);
70
71 compareListeners("Initial call", [listener1, listener2]);
72 compareListeners("Subsequent calls", [listener2]);
73 })
Thomas Greiner 2014/04/07 08:30:49 Nit: Missing semicolon
60 })(); 74 })();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld