I'm developing my first Web-App that will be embedded into an Android Web-View. The App is entirely done using standard HTML and JavaScript, with no special requirements nor libraries, only jQuery is used).
The first time the App is opened, the content to be displayed is downloaded using Ajax and saved to LocalStorage, so it can be accessed offline. When the application is uploaded to a web server (ex: myserver.com), LocalStorage works perfectly, this is, that I save a string in one page:
localStorage.setItem("MYVAR", "Hello World!");
and it is accessible from other html pages:
console.log(localStorage.getItem("MYVAR"));
But when the App is opened directly in the browser (local browsing using file://), to emulate the bahaviour of a Web-View, then it seems that the context for LocalStorage is lost, being different on each page, so LocalStorage is not shared and when a variable is created in one page, is not visible in other pages (but when uploaded to a server everything works fine).
For accessing remote files through Ajax and avoid issues in running JS files, I'm using this:
<meta http-equiv="Content-Security-Policy" content="script-src 'strict-dynamic' 'nonce-ABCD0123456'" />
<script nonce="ABCD0123456" src="myscript.js"></script>
I'm not sure whether this is related to Security policies, manifest settings, but I'm pretty sure that I'm missing something.
Any help will be much appreciated.