[bug 1017850] Check for localstorage

Apologies for the apparent size of this. I fixed the indentation.

r?
This was pretty much the actual change ^