Safari 11 gets SecurityError (DOM exception 18) when accessing localStorage

I just upgraded to Safari 11. I've been debugging my WebApp by opening the html file directly with Safari. After the upgrade it gets "SecurityError (DOM Exception 18) The operation is insecure when the app accesses localStorage.

Here's my security policy tag;

<meta http-equiv="Content-Security-Policy"
  content="default-src 'self' file:// *;
  style-src * 'self' 'unsafe-inline' 'unsafe-eval';
  script-src * 'self' 'unsafe-inline' 'unsafe-eval';"

This worked fine on previous versions of Safari and on Chrome, FIreFox etc.

Any thoughts?


Sorry, not an answer, just tuning in to your problem.

I get the same error when checking if a certain key in localStorage is undefined or not

if ( == undefined){
    var book = [];     

To clarify my original post: I get the security exception for localStorage when I open the html file directly with Safari 11 on macOS. Going through a local web server works fine, but this adds time to the debug cycle. Cookie storage seems to work, but my app has too much data to store to use that.

BTW I'm not sure why it makes sense to allow cookie storage and not allow localStorage...

I found the answer! Set "Disable local file restrictions" in the Develop menu.

This is a good workaround. It won't help my customers, though, as they open my web app from a file on their local drive. It worked fine until Safari 11 and still works on Chrome, Firefox, and Opera. I still need a fix, either through a security policy or a new version of Safari.