OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 /** | 5 /** |
6 * @typedef {{ | 6 * @typedef {{ |
7 * fulfill: function(PiexLoaderResponse):undefined, | 7 * fulfill: function(PiexLoaderResponse):undefined, |
8 * reject: function(string):undefined} | 8 * reject: function(string):undefined} |
9 * }} | 9 * }} |
10 */ | 10 */ |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 var listenerContainer = document.createElement('div'); | 187 var listenerContainer = document.createElement('div'); |
188 listenerContainer.appendChild(this.naclModule_); | 188 listenerContainer.appendChild(this.naclModule_); |
189 listenerContainer.addEventListener('load', this.onNaclLoadBound_, true); | 189 listenerContainer.addEventListener('load', this.onNaclLoadBound_, true); |
190 listenerContainer.addEventListener( | 190 listenerContainer.addEventListener( |
191 'message', this.onNaclMessageBound_, true); | 191 'message', this.onNaclMessageBound_, true); |
192 listenerContainer.addEventListener('error', this.onNaclErrorBound_, true); | 192 listenerContainer.addEventListener('error', this.onNaclErrorBound_, true); |
193 listenerContainer.addEventListener('crash', this.onNaclCrashBound_, true); | 193 listenerContainer.addEventListener('crash', this.onNaclCrashBound_, true); |
194 listenerContainer.style.height = '0px'; | 194 listenerContainer.style.height = '0px'; |
195 this.containerElement_ = listenerContainer; | 195 this.containerElement_ = listenerContainer; |
196 document.body.appendChild(listenerContainer); | 196 document.body.appendChild(listenerContainer); |
| 197 |
| 198 // Force a relayout. Workaround for load event not being called on <embed> |
| 199 // for a NaCl module. crbug.com/699930 |
| 200 /** @suppress {suspiciousCode} */ this.naclModule_.offsetTop; |
197 }.bind(this)); | 201 }.bind(this)); |
198 }.bind(this)).catch(function (error) { | 202 }.bind(this)).catch(function (error) { |
199 console.error(error); | 203 console.error(error); |
200 return false; | 204 return false; |
201 }); | 205 }); |
202 | 206 |
203 return this.naclPromise_; | 207 return this.naclPromise_; |
204 }; | 208 }; |
205 | 209 |
206 /** | 210 /** |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 delete this.requests_[requestId]; | 333 delete this.requests_[requestId]; |
330 this.requests_[message.id] = {fulfill: fulfill, reject: reject}; | 334 this.requests_[message.id] = {fulfill: fulfill, reject: reject}; |
331 }.bind(this)) | 335 }.bind(this)) |
332 .catch(function(error) { | 336 .catch(function(error) { |
333 delete this.requests_[requestId]; | 337 delete this.requests_[requestId]; |
334 console.error('PiexLoaderError: ', error); | 338 console.error('PiexLoaderError: ', error); |
335 return Promise.reject(error); | 339 return Promise.reject(error); |
336 }); | 340 }); |
337 }.bind(this)); | 341 }.bind(this)); |
338 }; | 342 }; |
OLD | NEW |