* Sends a method invocation request to the worker and returns a Promise. * @param {string} method * @param {!Array} args * @param {Window=} opt_localWin * @return {!Promise} * @private * @restricted
(method, args, opt_localWin)
| 178 | * @restricted |
| 179 | */ |
| 180 | sendMessage_(method, args, opt_localWin) { |
| 181 | return this.fetchPromise_.then(() => { |
| 182 | return new Promise((resolve, reject) => { |
| 183 | const id = this.counter_++; |
| 184 | this.messages_[id] = {method, resolve, reject}; |
| 185 | |
| 186 | const scope = this.idForWindow_(opt_localWin || this.win_); |
| 187 | |
| 188 | const message = /** @type {ToWorkerMessageDef} */ ({ |
| 189 | method, |
| 190 | args, |
| 191 | scope, |
| 192 | id, |
| 193 | }); |
| 194 | this.worker_./*OK*/ postMessage(message); |
| 195 | }); |
| 196 | }); |
| 197 | } |
| 198 | |
| 199 | /** |
| 200 | * Receives the result of a method invocation from the worker and resolves |
no test coverage detected