|
Rank: Advanced Member Groups: Member
Joined: 8/29/2016 Posts: 64
|
Hello, I am getting an error when trying to redefine window.localStorage. If found that I need to disable "Block third-party cookies and site data" option. https://www.chromium.org/for-testers/bug-reporting-guidelines/uncaught-securityerror-failed-to-read-the-localstorage-property-from-window-access-is-denied-for-this-documentHow to do it in EO.Browser? I used next Chromium switches, but it won't help me: --disable-web-security --allow-file-access-from-files --reduce-security-for-testing --noerrdialogs --allow-cross-origin-auth-prompt
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,221
|
Hi, You do not need to do anything particular to enable localStorage. So it should just work and it is not necessary for you to pass any command line arguments. For example, you can try to use our TabbedBrowser sample application to browse this Url: https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_win_localstorageAnd it should work the same way as Google Chrome. If you continue to have problem, please try to isolate the problem into a test page and send the test page to us: https://www.essentialobjects.com/forum/test_project.aspxOnce we have that we will be happy to investigate further. Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 8/29/2016 Posts: 64
|
Hi, Thank you for the answer! localStorage works fine, but I want to see all changes in localStorage, so I did:
Code: C#
webView.JSInitCode = GetLocalStorageCode();
And GetLocalStorageCode has the function that redefines the localStorage:
Code: JavaScript
Object.defineProperty(window, 'localStorage', {
configurable: true,
enumerable: true,
value: {
getItem: function (sKey) {
return "Hello";
},
setItem: function (sKey, sValue) {
console.log('localStorage changed');
}
}
});
or simple way:
Code: JavaScript
window.localStorage = function () {};
Any changes on localStorage are blocked. I found on Chromium project that block can be disabled in Chrome, but I didn't find how to enable changes on localStorage using EO.Browser: https://www.chromium.org/for-testers/bug-reporting-guidelines/uncaught-securityerror-failed-to-read-the-localstorage-property-from-window-access-is-denied-for-this-documentI've tried different ExtraCommandLineArgs, like --disable-web-security, --allow-file-access-from-files, --reduce-security-for-testing. It won't help, I still can't change the localStorage. Hope you can give any ideas that may help.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,221
|
I do not believe you can do this with Chrome either. You can try your code with Google Chrome and it won't work. It may not give you an error message, but window.localStorage is not replaced either.
The link you provided has nothing to do with modifying window.localStorage object. It has to do with modifying contents in the local storage.
|
|
Rank: Advanced Member Groups: Member
Joined: 8/29/2016 Posts: 64
|
Thank you for the answer! I have tested it on my Chrome and it works perfectly. You can check it with your Chrome as well. I created the script here https://codepen.io/anon/pen/ELRWXxScreenshot of my results: http://prntscr.com/jh8bxu
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,221
|
Which version do you use? We tested your code with the latest build and it seems to work fine (showing "Any key will return the same value").
|
|
Rank: Advanced Member Groups: Member
Joined: 8/29/2016 Posts: 64
|
Thank you for the fast answer!
I use 16.2.93. It looks like the issue that I have the old version. Is it possible to redefine localStorage with my version?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,221
|
Chromium is a huge project and we can not confirm or investigate about whether each version supports a specific feature. Since our product is directly built from Chromium's source code, usually if it doesn't work, it means your version does not support it.
|
|