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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 chromeMocks.runtime.connectNative = function(application) { | 106 chromeMocks.runtime.connectNative = function(application) { |
107 var port = nativePorts[application]; | 107 var port = nativePorts[application]; |
108 if (port === undefined) { | 108 if (port === undefined) { |
109 port = new chromeMocks.runtime.Port(); | 109 port = new chromeMocks.runtime.Port(); |
110 port.name = application; | 110 port.name = application; |
111 nativePorts[application] = port; | 111 nativePorts[application] = port; |
112 } | 112 } |
113 return port; | 113 return port; |
114 }; | 114 }; |
115 | 115 |
116 /** @const {Object<!chromeMocks.runtime.Port>} */ | 116 /** @type {Object<!chromeMocks.runtime.Port>} */ |
117 var nativePorts = null; | 117 var nativePorts = null; |
118 | 118 |
119 /** @type {string} */ | 119 /** @type {string} */ |
120 chromeMocks.runtime.id = 'extensionId'; | 120 chromeMocks.runtime.id = 'extensionId'; |
121 | 121 |
122 /** @type {Object} */ | 122 /** @type {Object} */ |
123 chromeMocks.runtime.lastError = { | 123 chromeMocks.runtime.lastError = { |
124 /** @type {string|undefined} */ | 124 /** @type {string|undefined} */ |
125 message: undefined | 125 message: undefined |
126 }; | 126 }; |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 throw new Error('You must call activate() before restore().'); | 314 throw new Error('You must call activate() before restore().'); |
315 } | 315 } |
316 for (var components in originals_) { | 316 for (var components in originals_) { |
317 chrome[components] = originals_[components]; | 317 chrome[components] = originals_[components]; |
318 } | 318 } |
319 originals_ = null; | 319 originals_ = null; |
320 nativePorts = null; | 320 nativePorts = null; |
321 }; | 321 }; |
322 | 322 |
323 })(); | 323 })(); |
OLD | NEW |