Skip to content

Add ad-block browsertest for when site_for_cookies is empty #2378

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

Closed
bbondy opened this issue Dec 5, 2018 · 3 comments · Fixed by brave/brave-core#1060
Closed

Add ad-block browsertest for when site_for_cookies is empty #2378

bbondy opened this issue Dec 5, 2018 · 3 comments · Fixed by brave/brave-core#1060

Comments

@bbondy
Copy link
Member

bbondy commented Dec 5, 2018

I think this case:
https://github.com/brave/brave-core/pull/942/files#diff-88c7c5c4d9e052b70374fe67c125d985R39

Happens when there's an iframe and inside that iframe there's a 302 redirect that happens.

There's a bug we had before brave/brave-core#942 landed where if you load this URL:
https://www.reddit.com/r/videos/comments/a2t52m/nickelodeon_just_uploaded_a_high_quality_version/

It would 302 a call to doubleclick.net and which would lead to 200 success codes for URLs which should be blocked:
https://static.doubleclick.net/instream/ad_status.js
https://googleads.g.doubleclick.net/pagead/id?slf_rd=1

This issue is posted to add an ad-block test that will cover this case.
Revert the PR mentioned to reproduce the issue.

@bbondy
Copy link
Member Author

bbondy commented Dec 5, 2018

Doing this will reproduce:

diff --git a/browser/net/url_context.cc b/browser/net/url_context.cc
index 38f9a692..79e5d790 100644
--- a/browser/net/url_context.cc
+++ b/browser/net/url_context.cc
@@ -33,8 +33,9 @@ void BraveRequestInfo::FillCTXFromRequest(const net::URLRequest* request,
                                     &ctx->render_frame_id,
                                     &ctx->render_process_id,
                                     &ctx->frame_tree_node_id);
-  if (!request->site_for_cookies().is_empty()) {
+  //if (!request->site_for_cookies().is_empty()) {
     ctx->tab_url = request->site_for_cookies();
+    /*
   } else {
     // We can not always use site_for_cookies since it can be empty in certain
     // cases. See the comments in url_request.h
@@ -43,6 +44,7 @@ void BraveRequestInfo::FillCTXFromRequest(const net::URLRequest* request,
                                      ctx->render_frame_id,
                                      ctx->frame_tree_node_id).GetOrigin();
   }
+  */
   ctx->tab_origin = ctx->tab_url.GetOrigin();
   ctx->allow_brave_shields = brave_shields::IsAllowContentSettingFromIO(
       request, ctx->tab_origin, ctx->tab_origin, CONTENT_SETTINGS_TYPE_PLUGINS,

@bsclifton bsclifton added the tests label Dec 5, 2018
@bbondy
Copy link
Member Author

bbondy commented Dec 5, 2018

Test should fail with above patch applied and pass when it isn't applied pls.

Test can go in this file with other adblock tests:
components/brave_shields/browser/ad_block_service_browsertest.cc

@bbondy bbondy added this to the 1.x Backlog milestone Dec 5, 2018
@bbondy
Copy link
Member Author

bbondy commented Dec 12, 2018

cc @iefremov
Turns out only an iframe needed to do an XHR to reproduce it having a blank site_for_cookies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants