-
Notifications
You must be signed in to change notification settings - Fork 903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement per-origin noscript #97
Conversation
eee42b2
to
300dda7
Compare
Built on Mac, will make sure other platforms built before merging. |
Please leave this PR for me to merge since I would like to include extension DEPS update commit in this PR when everything is reviewed and ready to merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can ship initially with the UI as is but ideally we'll one day modify this:
Please try to customize the "JavaScript was blocked on this page" message. To indicate they should check the Brave shields panel. But since this string is in chrome/app/generated_resources.grd
and we don't override it yet, we should override that as a separate PR and do that at that point. Posting a task for this would be fine for now.
While testing I somehow had an extension show up, which makes me think we blocked some extension we shouldn't have. I don't have any extra extensions installed, but it looks like it's from chrome/browser/resources/media_router
.
@@ -25,14 +26,55 @@ BraveContentSettingsObserver::BraveContentSettingsObserver( | |||
BraveContentSettingsObserver::~BraveContentSettingsObserver() { | |||
} | |||
|
|||
void BraveContentSettingsObserver::DidFinishLoad() { | |||
temporarily_allowed_scripts_.clear(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doing this clear here will cause a bad experience for NoScript users because a lot of resource loads for an origin happen after the onload. On browser-laptop in frame.js
we clear it when the component is unmounted (tab is closed) or when the user navigates to a different origin.
I think we could instead clear it when there's a different origin than was set in allow once in WillCommitProvisionalLoad
or something like that.
You can try it out on my website to see how it doesn't really work well. It probably works for some test sites just fine though.
We don't have to be consistent completely with how browser-laptop works but just more usable.
temporarily_allowed_scripts_.clear(); | ||
} | ||
|
||
bool BraveContentSettingsObserver::OnMessageReceived(const IPC::Message& message) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noting an alternate way to do this might be to create temporary content settings that we later clear. But I'm ok with the current method you used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that actually doesn't work because it will affect other loads that might be happening in the background
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
even this had to be tweaked slightly from the original to avoid any race conditoins
test/data/load_js_from_origins.html
Outdated
<html><head><title>load js from origins</title></head> | ||
<body> | ||
<script src="/cross-site/a.com/create_iframe.js"></script> | ||
<script src="/cross-site/b.com/create_iframe.js"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these paths are wrong which I think would make the tests fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed, comments about how this works are added into html file.
|
||
// Send IPC msg to update the list in this tab's content settings observers | ||
contents->SendToAllFrames( | ||
new BraveFrameMsg_AllowScriptsOnce(MSG_ROUTING_NONE, params->origins)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted there is an issue here that frames which might be created after this will not get this list.
Probably could be solved by saving the list (which is specific to one webcontent) in the browser process (maybe in BraveWebContentsObserver or BraveTabSpecificContentSetting) and send the list in RenderFrameCreated to those subsequent frames that are created later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed by 00cfdb3
|
||
void BraveContentSettingsObserver::OnAllowScriptsOnce( | ||
const std::vector<std::string>& origins) { | ||
temporarily_allowed_scripts_.clear(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need an extra setting here or can we just set the existing cached_script_permissions_
? cached_script_permissions_
gets cleared on navigation
6284061
to
9283244
Compare
@bbondy, @bridiver PR is updated, please take a look again when you're available, thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Autocontribute monthly values other than defaults are now added
Fix brave/brave-browser#6
Support per-tab per-origin noScript settings which will be cleared when navigating away.
See also: brave/brave-extension/pull/21
Submitter Checklist:
git rebase -i
to squash commits (if needed).Test Plan:
An automated browser test is added for this feature.
Reviewer Checklist: