|
1 | 1 | /** |
2 | 2 | * cross-storage - Cross domain local storage |
3 | 3 | * |
4 | | - * @version 0.7.0 |
| 4 | + * @version 0.8.0 |
5 | 5 | * @link https://github.com/zendesk/cross-storage |
6 | 6 | * @author Daniel St. Jules <danielst.jules@gmail.com> |
7 | 7 | * @copyright Zendesk |
|
14 | 14 | * an iframe is created within the document body that points to the url. It |
15 | 15 | * also accepts an options object, which may include a timeout, frameId, and |
16 | 16 | * promise. The timeout, in milliseconds, is applied to each request and |
17 | | - * defaults to 3000ms. The options object may also include a frameId, |
| 17 | + * defaults to 5000ms. The options object may also include a frameId, |
18 | 18 | * identifying an existing frame on which to install its listeners. If the |
19 | 19 | * promise key is supplied the constructor for a Promise, that Promise library |
20 | 20 | * will be used instead of the default window.Promise. |
|
56 | 56 | this._connected = false; |
57 | 57 | this._closed = false; |
58 | 58 | this._count = 0; |
59 | | - this._timeout = opts.timeout || 3000; |
| 59 | + this._timeout = opts.timeout || 5000; |
60 | 60 | this._listener = null; |
61 | 61 |
|
62 | 62 | this._installListener(); |
|
276 | 276 | this._listener = function(message) { |
277 | 277 | var i, error, response; |
278 | 278 |
|
279 | | - if (client._closed) return; |
280 | | - |
281 | | - // Ignore messages not from our hub |
282 | | - if (message.origin !== client._origin) return; |
| 279 | + // Ignore invalid messages, those not from the correct hub, or when |
| 280 | + // the client has closed |
| 281 | + if (client._closed || !message.data || typeof message.data !== 'string' || |
| 282 | + message.origin !== client._origin) { |
| 283 | + return; |
| 284 | + } |
283 | 285 |
|
284 | 286 | // LocalStorage isn't available in the hub |
285 | 287 | if (message.data === 'cross-storage:unavailable') { |
|
0 commit comments