-
Notifications
You must be signed in to change notification settings - Fork 900
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
add google analytics polyfill, fixes brave/brave-browser#4402 #2488
Conversation
@@ -417,6 +417,7 @@ By installing this extension, you are agreeing to the Google Widevine Terms of U | |||
</message> | |||
</messages> | |||
<includes> | |||
<include name="IDR_BRAVE_GOOGLE_ANALYTICS_POLYFILL" file="resources/js/google_analytics_polyfill.js" type="BINDATA" /> |
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.
@bbondy do you think it's ok to put it in this directory or should we create a new one for things that aren't copied from chrome?
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 it's fine
28fc895
to
4c689be
Compare
4c689be
to
221012a
Compare
221012a
to
54ae442
Compare
std::string GetGoogleTagManagerPolyfillJS() { | ||
static std::string base64_output; | ||
if (base64_output.length() != 0) { | ||
return base64_output; | ||
} | ||
std::string str = ui::ResourceBundle::GetSharedInstance().GetRawDataResource( | ||
IDR_BRAVE_TAG_MANAGER_POLYFILL).as_string(); | ||
base64_output.reserve(180); |
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.
these were added as an optimization so the buffer doesn't need to reallocate itself multiple times btw. But it's a micro-optimization so it's ok to get rid of it.
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.
as long as this passes CI this is good to merge. Please do uplift PRs as well after it lands on Nightly.
// Shields up, allow ads, tag manager should NOT get polyfill | ||
ASSERT_FALSE(GetPolyfillForAdBlock(true, true, tab_origin, tag_manager_url, &out_url_spec)); | ||
// Shields up, allow ads, tag services should NOT get polyfill | ||
ASSERT_FALSE(GetPolyfillForAdBlock(true, true, tab_origin, tag_services_url, &out_url_spec)); | ||
// Shields up, allow ads, normal URL should NOT get polyfill | ||
ASSERT_FALSE(GetPolyfillForAdBlock(true, true, tab_origin, normal_url, &out_url_spec)); | ||
|
||
// Shields down, allow ads, google analytics should get polyfill | ||
ASSERT_FALSE(GetPolyfillForAdBlock(false, true, tab_origin, google_analytics_url, &out_url_spec)); |
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.
is this correct? shields down... we still want to polyfill? (or typo in comment)
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.
ah, yuck, typo. Repushed and edd940b fixes
54ae442
to
edd940b
Compare
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.
Approving - fix was made to issue I saw (and it was already approved) 😄
Pending CI passing; please uplift, per @bbondy comment 😄
edd940b
to
5dfea22
Compare
From Slack conversation with @bsclifton, going to merge this in, since the issue seems to be in CI, not in the code (after several reviews). Merging and uplifting |
Reproduced the original issue by loading both
You can definitely see a difference with the fix. Both websites mentioned above load a lot faster compared to builds without the fix. |
Fixes: brave/brave-browser#4402
Submitter Checklist:
npm test brave_unit_tests && npm test brave_browser_tests && npm run test-security
) onnpm run lint
)git rebase master
(if needed).git rebase -i
to squash commits (if needed).Test Plan:
Reviewer Checklist:
After-merge Checklist:
changes has landed on.