Skip to content
This repository has been archived by the owner on Nov 15, 2017. It is now read-only.

Inline javascript might be executed first time page is loaded #35

Closed
gorhill opened this issue Oct 27, 2013 · 7 comments
Closed

Inline javascript might be executed first time page is loaded #35

gorhill opened this issue Oct 27, 2013 · 7 comments
Labels

Comments

@gorhill
Copy link
Owner

gorhill commented Oct 27, 2013

Test case:
http://acid3.acidtests.org/

This is probably due to the fact that chrome.contentSettings.javascript.set() is asynchronous, which means the preventing of inline javascript is not guaranteed to take effect before the page is processed/executed by the browser.

Until there is a fix (chromium developers might need to come up with something):

[Edit 2014-05-26: Some people are still using this entry as a reference. Since issue #35 has been fixed, the "workaround" below is no longer needed, it is has been rendered irrelevant with the fix.]

Workaround:

- Go to chrome/chromium "Settings".
- You might need to click "Show advanced settings".
- In "Privacy" section, click "Content settings..." button.
- In the "Javascript" section, click "Do not allow any site to run JavaScript".

HTTP Switchboard will continue to take care to enable javascript for whitelisted site.

@gorhill
Copy link
Owner Author

gorhill commented Oct 27, 2013

No, this needs to be studied more. Above workaround is best solution for now.

@gorhill gorhill reopened this Oct 27, 2013
@gorhill
Copy link
Owner Author

gorhill commented Nov 5, 2013

There is an unfortunate side-effect of using "Do not allow any site to run JavaScript": When a main_frame is blocked (this happens for blacklisted hostnames), the page won't reload when unblocking it, this happens because the embedded replacement main_frame (encoded as a data URI) uses javascript to reload the page which has been unblocked. So far, it appears it is not possible to allow javascript for data URI... Sigh...

EDIT 2013-11-09: This one particular issue was resolved in v0.5.0 (using a different way to reload formerly blacklisted page)

@gorhill
Copy link
Owner Author

gorhill commented Nov 9, 2013

A side effect of the workaround, and for the same reason that contentSettings.javascript.set() is asynchronous, a web page might have its inline script blocked the first time the page is loaded. A refresh of the page allows the script to be properly executed.

@gorhill
Copy link
Owner Author

gorhill commented Nov 16, 2013

A bug has been formally submitted in chromium bug db: https://code.google.com/p/chromium/issues/detail?id=320300

@gorhill
Copy link
Owner Author

gorhill commented Nov 17, 2013

If javascript is disabled by default, one solution could be to generate the exceptions for all whitelist rules with an explicit hostname when the extension is first executed -- there can't be that many hostname/script or hostname/* for one user I suppose... Still feel a hack, but in the meantime (if even chromium address the issue), that would be better than nothing.

@hrj
Copy link

hrj commented Dec 1, 2013

👍 Nice to see your detailed analysis. Hoping for an update from Chromium devs.

@gorhill
Copy link
Owner Author

gorhill commented Dec 5, 2013

Found a fix, so far it's working well. Will test more. Side-effect of the fix: blocked javascript won't be shown as blocked by chromium/chrome in the omnibar... Is it a big deal?

@gorhill gorhill closed this as completed in 32af1f6 Dec 5, 2013
gorhill added a commit that referenced this issue Dec 5, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants