Chromium Code Reviews| Index: remoting/webapp/unittests/chrome_mocks.js |
| diff --git a/remoting/webapp/unittests/chrome_mocks.js b/remoting/webapp/unittests/chrome_mocks.js |
| index 7a21da3c288d2bdf02d3e3056c7d8306a5972913..e7d9f93c3320d9b9bd3ceadb4ccf44e504380406 100644 |
| --- a/remoting/webapp/unittests/chrome_mocks.js |
| +++ b/remoting/webapp/unittests/chrome_mocks.js |
| @@ -28,9 +28,10 @@ chromeMocks.Event.prototype.removeListener = function(callback) { |
| } |
| }; |
| -chromeMocks.Event.prototype.mock$fire = function(data) { |
| +chromeMocks.Event.prototype.mock$fire = function(var_args) { |
| + var params = Array.prototype.slice.call(arguments); |
| this.listeners_.forEach(function(listener){ |
| - listener(data); |
| + listener.apply(null, params); |
| }); |
| }; |
| @@ -47,6 +48,21 @@ chromeMocks.runtime.Port = function() { |
| chromeMocks.runtime.Port.prototype.disconnect = function() {}; |
| chromeMocks.runtime.Port.prototype.postMessage = function() {}; |
| +chromeMocks.runtime.onMessage = new chromeMocks.Event(); |
| +chromeMocks.runtime.sendMessage = function(extensionId, message, |
| + responseCallback) { |
| + if (!extensionId) { |
|
Jamie
2015/01/27 22:52:25
This should not be conditional, I don't think. Whe
kelvinp
2015/01/28 01:31:51
Done.
|
| + extensionId = chromeMocks.runtime.id; |
| + } |
| + |
| + window.requestAnimationFrame(function(){ |
| + chromeMocks.runtime.onMessage.mock$fire(message, {id: extensionId}, |
|
Jamie
2015/01/27 22:52:25
Maybe convert |message| to JSON and back, since th
kelvinp
2015/01/28 01:31:51
Good idea :) Done.
|
| + responseCallback); |
| + }); |
| +}; |
| + |
| +chromeMocks.runtime.id = 'extensionId'; |
| + |
| chromeMocks.storage = {}; |
| // Sample implementation of chrome.StorageArea according to |