meteor/meteor — pull request #1291 by mizzao (2014-06-02 22:17:12+00:00)
Title: localStorage does not work in some configurations of IE

Hi guys,

I recently started noticing that IE was not working at all on the `devel` branch. I thought it would get fixed, but the problem has persisted for a while. The errors are different on local development and meteor hosting, but both result in a blank page.

For example, on http://crowdmapper.meteor.com which is on `0.6.5-rc12`:

```
SCRIPT5: Access is denied.

91404edf5fdd1cb531c72e6ca922a8d703eafd3b.js, line 10 character 3646
SEC7118: XMLHttpRequest for https://ddp--2731-crowdmapper.meteor.com/sockjs/info?cb=ftn6uad6w3&t=1375913299050 required Cross Origin Resource Sharing (CORS).
crowdmapper.meteor.com
```

On local hosting:
```
SCRIPT5: Access is denied.

localstorage.js, line 35 character 1
SCRIPT5007: Unable to get property 'getItem' of undefined or null reference
accounts-base.js, line 470 character 3
SCRIPT5007: Unable to get property 'Accounts' of undefined or null reference
accounts-ui-unstyled.js, line 24 character 1
SCRIPT5007: Unable to get property 'Accounts' of undefined or null reference
accounts-ui.js, line 22 character 1
SCRIPT5007: Unable to get property 'Accounts' of undefined or null reference
user-status.js, line 22 character 1
SCRIPT5007: Unable to get property 'Accounts' of undefined or null reference
accounts-testing.js, line 22 character 1
SCRIPT5007: Unable to get property 'Accounts' of undefined or null reference
waiting-lobby.js, line 25 character 1
SCRIPT5007: Unable to get property 'Accounts' of undefined or null reference
turkserver.js, line 25 character 1
SCRIPT5007: Unable to get property 'Accounts' of undefined or null reference
... a billion more errors
```

It seems like this is caused by the following line of (https://github.com/meteor/meteor/blob/devel/packages/localstorage/localstorage.js : 3) of which kills the rest of the app:

```js
if (window.localStorage) {
Meteor._localStorage = {
...
}
}
```

According to [this issue](http://answers.microsoft.com/en-us/ie/forum/ie10-windows_8/get-the-internet-explorer-script-error-which-says/be14db88-0ace-4771-a5d0-7754be69a98e?msgId=2561b6be-86c2-4b3f-8790-66dbd9cea4c9) the error will go away if running as admin or disabling protected mode.

The machine I'm using has IE10 on Windows 8.

My app indeed worked when I unchecked the following. However, it is unreasonable to expect users to do this and I wonder if there is a way to make Meteor fail more gracefully (such as reverting to the in-memory storage.) Maybe try wrapping the `window.localStorage` call in a `try` block?

![image](https://f.cloud.github.com/assets/2080084/928221/a2880e3c-ffb0-11e2-85f4-528598a8ba69.png)

Other references (seems like the default IE security config is just a big fail, sorry):
- http://community.spiceworks.com/topic/357825-ie10-script5-access-is-denied
- https://drupal.org/node/1849764