Chromium Code Reviews| Index: chrome/test/data/webui/fake_chrome_event.js |
| diff --git a/chrome/test/data/webui/fake_chrome_event.js b/chrome/test/data/webui/fake_chrome_event.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e1b73e2bbb1632a61c4ccb00abf9311b13f63212 |
| --- /dev/null |
| +++ b/chrome/test/data/webui/fake_chrome_event.js |
| @@ -0,0 +1,37 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +/** |
| + * @fileoverview Fake implementations of ChromeEvent. |
| + */ |
| + |
| +/** |
| + * @constructor |
| + * @extends {ChromeEvent} |
| + */ |
| +function FakeChromeEvent() { |
| + /** @type {!Set<!Function>} */ |
| + this.listeners_ = new Set(); |
| +} |
| + |
| +FakeChromeEvent.prototype = { |
| + /** @param {Function} listener */ |
| + addListener: function(listener) { |
| + assertFalse(this.listeners_.has(listener)); |
| + this.listeners_.add(listener); |
| + }, |
| + |
| + /** @param {Function} listener */ |
| + removeListener: function(listener) { |
| + assertTrue(this.listeners_.has(listener)); |
| + this.listeners_.delete(listener); |
| + }, |
| + |
| + /** @param {...} args */ |
| + callListeners: function(...args) { |
|
michaelpg
2015/12/17 23:26:20
var_args
stevenjb
2015/12/18 01:34:46
Done.
|
| + this.listeners_.forEach(function(l) { |
| + l.apply(null, args); |
| + }); |
| + } |
| +}; |