| 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 (function() { | 5 (function() { |
| 6 | 6 |
| 7 'use strict'; | 7 'use strict'; |
| 8 | 8 |
| 9 /** @type {base.Ipc} */ |
| 9 var ipc_; | 10 var ipc_; |
| 10 | 11 |
| 11 function pass() { | 12 function pass() { |
| 12 ok(true); | 13 ok(true); |
| 13 QUnit.start(); | 14 QUnit.start(); |
| 14 } | 15 } |
| 15 | 16 |
| 16 function fail() { | 17 function fail() { |
| 17 ok(false); | 18 ok(false); |
| 18 QUnit.start(); | 19 QUnit.start(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 sinon.assert.calledWith(handler, 1, false, 'string', argArray, argDict); | 56 sinon.assert.calledWith(handler, 1, false, 'string', argArray, argDict); |
| 56 pass(); | 57 pass(); |
| 57 }, fail); | 58 }, fail); |
| 58 }); | 59 }); |
| 59 | 60 |
| 60 QUnit.asyncTest( | 61 QUnit.asyncTest( |
| 61 'send() should not invoke a handler that is unregistered', | 62 'send() should not invoke a handler that is unregistered', |
| 62 function() { | 63 function() { |
| 63 var handler = sinon.spy(); | 64 var handler = sinon.spy(); |
| 64 ipc_.register('foo', handler); | 65 ipc_.register('foo', handler); |
| 65 ipc_.unregister('foo', handler); | 66 ipc_.unregister('foo'); |
| 66 base.Ipc.invoke('foo', 'hello', 'world').then(fail, function(error) { | 67 base.Ipc.invoke('foo', 'hello', 'world').then(fail, function(error) { |
| 67 sinon.assert.notCalled(handler); | 68 sinon.assert.notCalled(handler); |
| 68 QUnit.equal(error, base.Ipc.Error.UNSUPPORTED_REQUEST_TYPE); | 69 QUnit.equal(error, base.Ipc.Error.UNSUPPORTED_REQUEST_TYPE); |
| 69 pass(); | 70 pass(); |
| 70 }); | 71 }); |
| 71 }); | 72 }); |
| 72 | 73 |
| 73 QUnit.asyncTest( | 74 QUnit.asyncTest( |
| 74 'send() should raise exceptions on unknown request types', | 75 'send() should raise exceptions on unknown request types', |
| 75 function() { | 76 function() { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 QUnit.equal(results[0], false); | 131 QUnit.equal(results[0], false); |
| 131 QUnit.equal(results[1], 12); | 132 QUnit.equal(results[1], 12); |
| 132 QUnit.equal(results[2], 'string'); | 133 QUnit.equal(results[2], 'string'); |
| 133 QUnit.deepEqual(results[3], [1,2]); | 134 QUnit.deepEqual(results[3], [1,2]); |
| 134 QUnit.deepEqual(results[4], {key1: 'value1', key2: 'value2'}); | 135 QUnit.deepEqual(results[4], {key1: 'value1', key2: 'value2'}); |
| 135 pass(); | 136 pass(); |
| 136 }, fail); | 137 }, fail); |
| 137 }); | 138 }); |
| 138 | 139 |
| 139 })(); | 140 })(); |
| OLD | NEW |