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

Unified Diff: remoting/webapp/base/js/ipc_unittest.js

Issue 2671103002: Implement host settings migration. (Closed)
Patch Set: Created 3 years, 10 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/base/js/ipc.js ('k') | remoting/webapp/crd/js/background.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/base/js/ipc_unittest.js
diff --git a/remoting/webapp/base/js/ipc_unittest.js b/remoting/webapp/base/js/ipc_unittest.js
index ebddb37cd737fb6b96334dc576ea87718fc05e7e..00ed66ff2b0cfb65d62a887d1892e7618a4a8239 100644
--- a/remoting/webapp/base/js/ipc_unittest.js
+++ b/remoting/webapp/base/js/ipc_unittest.js
@@ -81,12 +81,25 @@ QUnit.test(
var promise = base.Ipc.invoke('foo', 'hello', 'world').then(function() {
assert.ok(false, 'Requests from another extension should fail.');
}).catch(function(error) {
- assert.equal(error, base.Ipc.Error.INVALID_REQUEST_ORIGIN);
+ assert.equal(error, base.Ipc.Error.UNAUTHORIZED_REQUEST_ORIGIN);
});
chrome.runtime.id = oldId;
return promise;
});
+QUnit.test(
+ 'send() should not raise exceptions for externally-accessible methods',
+ function(assert) {
+ var handler = function(request) { return request; };
+ var oldId = chrome.runtime.id;
+ ipc_.register('foo', handler, true);
+ chrome.runtime.id = 'foreign-extension';
+ var promise = base.Ipc.invoke('foo', 'payload').then(function(response) {
+ assert.equal(response, 'payload');
+ });
+ chrome.runtime.id = oldId;
+ return promise;
+});
QUnit.test(
'send() should pass exceptions raised by the handler to the caller',
@@ -128,4 +141,29 @@ QUnit.test(
});
});
+QUnit.test(
+ 'send() supports asynchronous handlers',
+ function(assert) {
+ var success = function() {
+ return new Promise(function(resolve) { resolve('result'); });
+ };
+ var failure = function() {
+ return new Promise(function() {
+ throw new Error('Whatever can go wrong, will go wrong.');
+ });
+ };
+ ipc_.register('foo', success);
+ ipc_.register('bar', failure);
+ var testCases = [];
+ testCases.push(base.Ipc.invoke('foo').then(function(response) {
+ assert.equal(response, 'result');
+ }));
+ testCases.push(base.Ipc.invoke('bar').then(function() {
+ assert.ok(false, 'bar method expected to fail.');
+ }).catch(function(error) {
+ assert.equal(error, 'Whatever can go wrong, will go wrong.');
+ }))
+ return Promise.all(testCases);
+});
+
})();
« no previous file with comments | « remoting/webapp/base/js/ipc.js ('k') | remoting/webapp/crd/js/background.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698