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

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

Issue 1060793003: Added unit test for HostDaemonFacade. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mock-xhr
Patch Set: Created 5 years, 9 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
Index: remoting/webapp/js_proto/chrome_mocks.js
diff --git a/remoting/webapp/js_proto/chrome_mocks.js b/remoting/webapp/js_proto/chrome_mocks.js
index e64421db527c5d8ef483d5f633452e66fb928613..8e269426eeb3ff65589faca517778e2cb803d624 100644
--- a/remoting/webapp/js_proto/chrome_mocks.js
+++ b/remoting/webapp/js_proto/chrome_mocks.js
@@ -62,7 +62,10 @@ chromeMocks.runtime = {};
/** @constructor */
chromeMocks.runtime.Port = function() {
+ /** @const */
this.onMessage = new chromeMocks.Event();
+
+ /** @const */
this.onDisconnect = new chromeMocks.Event();
/** @type {string} */
@@ -100,6 +103,24 @@ chromeMocks.runtime.sendMessage = function(extensionId, message,
});
};
+/**
+ * Always returns the same mock port for given application name.
+ * @param {string} application
+ * @return {chromeMocks.runtime.Port}
+ */
+chromeMocks.runtime.connectNative = function(application) {
+ var port = nativePorts[application];
+ if (port == null) {
kelvinp 2015/04/06 17:25:10 use ===
John Williams 2015/04/06 19:14:59 Done.
+ port = new chromeMocks.runtime.Port();
+ port.name = application;
+ nativePorts[application] = port;
+ }
+ return port;
+};
+
+/** @const {Object<string,!chromeMocks.runtime.Port>} */
+var nativePorts = null;
+
/** @type {string} */
chromeMocks.runtime.id = 'extensionId';
@@ -225,6 +246,7 @@ chromeMocks.activate = function(components) {
throw new Error('chromeMocks.activate() can only be called once.');
}
originals_ = {};
+ nativePorts = {};
components.forEach(function(component) {
if (!chromeMocks[component]) {
throw new Error('No mocks defined for chrome.' + component);
@@ -242,6 +264,7 @@ chromeMocks.restore = function() {
chrome[components] = originals_[components];
}
originals_ = null;
+ nativePorts = null;
};
})();

Powered by Google App Engine
This is Rietveld 408576698