| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // This file contains various mock objects for the chrome platform to make | 5 // This file contains various mock objects for the chrome platform to make |
| 6 // unit testing easier. | 6 // unit testing easier. |
| 7 | 7 |
| 8 var chromeMocks = {}; | 8 var chromeMocks = {}; |
| 9 | 9 |
| 10 (function(){ | 10 (function(){ |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 if (this.listeners_[i] === callback) { | 30 if (this.listeners_[i] === callback) { |
| 31 this.listeners_.splice(i, 1); | 31 this.listeners_.splice(i, 1); |
| 32 break; | 32 break; |
| 33 } | 33 } |
| 34 } | 34 } |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 /** | 37 /** |
| 38 * @param {...*} var_args | 38 * @param {...*} var_args |
| 39 * @return {void} | 39 * @return {void} |
| 40 * @suppress {reportUnknownTypes} |
| 40 */ | 41 */ |
| 41 chromeMocks.Event.prototype.mock$fire = function(var_args) { | 42 chromeMocks.Event.prototype.mock$fire = function(var_args) { |
| 42 var params = Array.prototype.slice.call(arguments); | 43 var params = Array.prototype.slice.call(arguments); |
| 43 this.listeners_.forEach( | 44 this.listeners_.forEach( |
| 44 /** @param {Function} listener */ | 45 /** @param {Function} listener */ |
| 45 function(listener){ | 46 function(listener){ |
| 46 listener.apply(null, params); | 47 listener.apply(null, params); |
| 47 }); | 48 }); |
| 48 }; | 49 }; |
| 49 | 50 |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 throw new Error('You must call activate() before restore().'); | 292 throw new Error('You must call activate() before restore().'); |
| 292 } | 293 } |
| 293 for (var components in originals_) { | 294 for (var components in originals_) { |
| 294 chrome[components] = originals_[components]; | 295 chrome[components] = originals_[components]; |
| 295 } | 296 } |
| 296 originals_ = null; | 297 originals_ = null; |
| 297 nativePorts = null; | 298 nativePorts = null; |
| 298 }; | 299 }; |
| 299 | 300 |
| 300 })(); | 301 })(); |
| OLD | NEW |