Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(401)

Unified Diff: remoting/webapp/unittests/chrome_mocks.js

Issue 877993002: Implement base.IPC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address reviewer's feedback Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/webapp/js_proto/chrome_proto.js ('k') | remoting/webapp/unittests/ipc_unittest.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..9b617843e2ef8e56c24e8644ac232f0cff90f2d4 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,22 @@ 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) {
+ base.debug.assert(
+ extensionId === null,
+ 'The mock only supports sending messages to the same extension.');
+ extensionId = chrome.runtime.id;
+ window.requestAnimationFrame(function() {
+ var message_copy = deepCopy(message);
Jamie 2015/01/28 18:57:47 Where is deepCopy defined? I don't see it in trunk
+ chromeMocks.runtime.onMessage.mock$fire(
+ message_copy, {id: extensionId}, responseCallback);
+ });
+};
+
+chromeMocks.runtime.id = 'extensionId';
+
chromeMocks.storage = {};
// Sample implementation of chrome.StorageArea according to
« no previous file with comments | « remoting/webapp/js_proto/chrome_proto.js ('k') | remoting/webapp/unittests/ipc_unittest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698