-1

eval('window.localStorage') is throwing the SCRIPT16389: Unspecified error. In Chrome works as expected - the same result as console.log(window.localStorage). Is there any reason why Microsoft EDGE browser is suppressing this?

EDIT:

Why eval?

It's used in the application as an "export" feature. Current state among with source code is zipped and base64 encoded. This zip is attached to HTML, this HTML file includes all resources so the app can be "reconstructed" offline. During the reconstruction process I'm calling the eval on unzipped, base64 decoded sources.

Same behavior occurred in Safari, here is a screenshot from IE Edge https://i.stack.imgur.com/jrnAx.png

noticed on Microsoft Edge 41.16299.248.0

vt.
  • 1,398
  • 7
  • 15
  • 1
    Works fine for me on `example.com`, no error. Maybe you are trying this on a site where CSP or similar prevent this …? – CBroe Mar 12 '18 at 14:15
  • 1
    https://stackoverflow.com/questions/31512040/eval-function-execution-leads-to-internal-error – guijob Mar 12 '18 at 14:23
  • The example given is obviously a contrived example for the sake of asking a question; you haven't given any details on what you're using `eval` for. But I'll be very impressed if you can come up with a convincing argument why you actually need it. – Simba Mar 12 '18 at 14:43

1 Answers1

1

window.localStorage combined with file:// protocol is the problem, not the eval itself

workaround:

if (typeof window.localStorage !== 'undefined')` {
    // ...
}

more info: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8816771/

vt.
  • 1,398
  • 7
  • 15