| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2014 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 /* globals chrometest, ASSERT_NE, ASSERT_FALSE */ |
| 8 |
| 7 'use strict'; | 9 'use strict'; |
| 8 | 10 |
| 9 /** | 11 /** |
| 10 * Wait until a certain number of NaCl modules start/stop. | 12 * Wait until a certain number of NaCl modules start/stop. |
| 11 * Waits until the number of extra modules vs a snapshot equals a certain | 13 * Waits until the number of extra modules vs a snapshot equals a certain |
| 12 * number. Also, waits until the debug port is known. | 14 * number. Also, waits until the debug port is known. |
| 13 * @param {integer} count Number of modules in addition to the snapshot to | 15 * @param {integer} count Number of modules in addition to the snapshot to |
| 14 * wait for. | 16 * wait for. |
| 15 * @param {Object.<integer, ProcessInfo>} snapshot A snapshot of the the | 17 * @param {Object.<integer, ProcessInfo>} snapshot A snapshot of the the |
| 16 * process set from getAllProcesses. | 18 * process set from getAllProcesses. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 function moduleMessageWaiter(module) { | 72 function moduleMessageWaiter(module) { |
| 71 var waiter; | 73 var waiter; |
| 72 function handleMessage(msg) { | 74 function handleMessage(msg) { |
| 73 waiter.enqueue(Promise.resolve(msg)); | 75 waiter.enqueue(Promise.resolve(msg)); |
| 74 } | 76 } |
| 75 waiter = new chrometest.PortlikeWaiter(function() { | 77 waiter = new chrometest.PortlikeWaiter(function() { |
| 76 module.removeEventListener(handleMessage); | 78 module.removeEventListener(handleMessage); |
| 77 }, module); | 79 }, module); |
| 78 module.addEventListener('message', handleMessage, true); | 80 module.addEventListener('message', handleMessage, true); |
| 79 return waiter; | 81 return waiter; |
| 80 }; | 82 } |
| 81 | 83 |
| 82 | 84 |
| 83 /** | 85 /** |
| 84 * Wait for a message other the name 'message' (from terminal). | 86 * Wait for a message other the name 'message' (from terminal). |
| 85 * @param {Port} portLike a port like waiter object to wait on. | 87 * @param {Port} portLike a port like waiter object to wait on. |
| 86 * @return {Promise} Promise to wait for a message. | 88 * @return {Promise} Promise to wait for a message. |
| 87 */ | 89 */ |
| 88 function waitIgnoringTerminal(portLike) { | 90 function waitIgnoringTerminal(portLike) { |
| 89 function waitForReply(msg) { | 91 function waitForReply(msg) { |
| 90 // Ignore terminal messages. | 92 // Ignore terminal messages. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 // jsonify the DOM element. | 126 // jsonify the DOM element. |
| 125 ASSERT_FALSE(null === self.rawObject, 'there must be a DOM element'); | 127 ASSERT_FALSE(null === self.rawObject, 'there must be a DOM element'); |
| 126 }); | 128 }); |
| 127 }; | 129 }; |
| 128 | 130 |
| 129 TestModuleTest.prototype.tearDown = function() { | 131 TestModuleTest.prototype.tearDown = function() { |
| 130 var self = this; | 132 var self = this; |
| 131 // Wait for the test module to exit. | 133 // Wait for the test module to exit. |
| 132 return waitForExtraModuleCount(0, self.initialProcesses).then(function() { | 134 return waitForExtraModuleCount(0, self.initialProcesses).then(function() { |
| 133 // Remove node. | 135 // Remove node. |
| 134 if (self.object != null) { | 136 if (self.object !== null) { |
| 135 var object = self.object.detach(); | 137 var object = self.object.detach(); |
| 136 self.object = null; | 138 self.object = null; |
| 137 self.rawObject = null; | 139 self.rawObject = null; |
| 138 var p = object.parentNode; | 140 var p = object.parentNode; |
| 139 p.removeChild(object); | 141 p.removeChild(object); |
| 140 } | 142 } |
| 141 return chrometest.Test.prototype.tearDown.call(self); | 143 return chrometest.Test.prototype.tearDown.call(self); |
| 142 }); | 144 }); |
| 143 }; | 145 }; |
| OLD | NEW |