disconnectme / port

port.js is an expanded version of Michael Gundlach’s Chrome-(and-Opera!)–to–Safari porting library for extensions <https://adblockforchrome.googlecode.com/svn/trunk/port.js>.
https://github.com/disconnectme/port
GNU General Public License v3.0
57 stars 14 forks source link

Uncaught SecurityError: Access to 'localStorage' is denied for this document. #1

Open jakob-stoeck opened 10 years ago

jakob-stoeck commented 10 years ago

Shows as an error in the web console when “Block third-party cookies and site data” option is activated in Chrome:

This line is the culprit: options = SAFARI ? safari.extension.settings : localStorage;

Access to localStorage is not given for extensions when above-stated option is activated.

I’m not sure how this line is used, though and if try/catch-ing it helps or e.g. switching to the chrome storage API. Any thoughts?

To replicate:

  1. Install disconnect
  2. Activate “Block third-party cookies and site data”
  3. Open an HTML file with HTTP (error does not show up with file:// protocol) with this content: <script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
  4. Web console shows above stated error.
oldestlivingboy commented 10 years ago

Thanks a lot for the report.

Are you certain chrome.storage isn't similarly affected by that setting?

jakob-stoeck commented 10 years ago

After further inspecting, the error does not always show up but just if some scripts are included e.g. this one:

<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script> which is used on websites to Optimize Social Plugin Performance

It seems that this script creates an iframe which then proxy.js chokes on when used with disconnect. proxy.js is parsed twice, once by the original page w/o error and twice b/c of the iframe which then throws the error. I’ll edit the to replicate part above.

Right now I just try/catch’ed it. Not sure whether disconnect is negatively impacted by this, though. try {options = SAFARI ? safari.extension.settings : localStorage; } catch(e) {}

oldestlivingboy commented 10 years ago

Ah, I haven't had a chance to test yet, but I suspect the error is only generated from content/injected scripts. If so, the try ... catch is a reasonable workaround since the (library) user shouldn't be setting options there (although better would be figuring out how to not run the code at all in content/injected scripts).

nmschulte commented 8 years ago

Bump. The plugin for Chrome/Chromium still suffers from this issue. Any chance to get the try/catch fix in?

oldestlivingboy commented 8 years ago

@nmschulte I don’t think this project is maintained any longer, but I maintain a fork that’s used in production. The access error was patched there a while back.

nmschulte commented 8 years ago

The Disconnect plugin/extension (v5.18.23, by disconnect.me, from the store) I use w/ Chromium is using a version of port.js that still suffers from this issue. That's all I was trying to get fixed; perhaps I should poke disconnect.me some other way.

oldestlivingboy commented 8 years ago

@nmschulte Oh, I’m not sure what’s up with the browser extensions (or why I’m still assigned to this issue) – I stopped working on Disconnect a couple years ago.

Scyntrus commented 7 years ago

3 years later and I still get this problem. I hope that pull request fixes it.

serpent7776 commented 5 years ago

Another 1.5 years passed and this is still not fixed and PR that should fix it is open. Is this extension still supported? Is this options even used?