Skip to content
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 check if javascript was disallowed. #9984

Merged
merged 1 commit into from
Sep 8, 2021
Merged

Add check if javascript was disallowed. #9984

merged 1 commit into from
Sep 8, 2021

Conversation

aseren
Copy link
Collaborator

@aseren aseren commented Sep 6, 2021

Calling ResolveJavascriptCallback when OnJavascriptDisallowed was called leads to CHECK. So during async callback run we need to check if javascript is still allowed.

To fix this following was done:

  • Invalidate weak pointers in OnJavascriptDisallowed.
  • Check if javascript was disallowed .

Resolves brave/brave-browser#17864

Submitter Checklist:

  • I confirm that no security/privacy review is needed, or that I have requested one
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally: npm run test -- brave_browser_tests, npm run test -- brave_unit_tests, npm run lint, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

Check that Ads are displayed within Brave News

Copy link
Collaborator

@tmancey tmancey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@aseren aseren merged commit 61446e1 into master Sep 8, 2021
@aseren aseren deleted the issues/17864 branch September 8, 2021 11:47
brave-builds pushed a commit that referenced this pull request Sep 8, 2021
brave-builds pushed a commit that referenced this pull request Sep 8, 2021
@tmancey tmancey added this to the 1.31.x - Nightly milestone Sep 8, 2021
@stephendonner
Copy link
Contributor

Verified PASSED using

Brave 1.31.28 Chromium: 93.0.4577.63 (Official Build) nightly (x86_64)
Revision ff5c0da2ec0adeaed5550e6c7e98417dac77d98a-refs/branch-heads/4577@{#1135}
OS macOS Version 11.5.2 (Build 20G95)

Steps:

  1. new profile
  2. launched Brave using --enable-logging=stderr --vmodule="*/variations/*"=6,"*/bat-native-ledger/*"=6,"*/brave_rewards/*"=6,"*/bat-native-ads/*"=6,"*/bat-native-confirmations/*"=6,"*/brave_ads/*"=9,"*/brave_user_model/*"=6 --brave-ads-staging --brave-ads-debug --rewards=staging=true,reconcile-interval=3
  3. opened a new-tab page
  4. clicked on Start using Rewards
  5. scrolled down
  6. clicked on Show Brave News
  7. scrolled down more
  8. viewed and clicked on the Makita Powertools Saw content ad (https://www.powertools2u.co.uk/makita-lf1000-flip-over-sawo)
  • Confirmed from view to click to redemption:
[63985:259:0908/160539.002911:VERBOSE6:inline_content_ad_event_viewed.cc(32)] Successfully logged inline content ad viewed event
[63985:259:0908/160539.295692:VERBOSE1:confirmations.cc(251)] Successfully redeemed unblinded token with confirmation id 462927ee-5ed2-419a-902b-f028b4876273, creative instance id 033a95ca-963b-460c-b203-8181346bd41c and view
[63985:259:0908/160539.296548:VERBOSE1:confirmations.cc(274)] Added 1 unblinded payment token with an estimated redemption value of 0.01 BAT, you now have 5 unblinded payment tokens
[63985:259:0908/160542.508434:VERBOSE3:inline_content_ad_event_clicked.cc(23)] Clicked inline content ad with uuid 35afc9e9-0399-4f7d-992d-aeb4ec484075 and creative instance id 033a95ca-963b-460c-b203-8181346bd41c
[63985:259:0908/160542.520755:VERBOSE1:confirmations.cc(91)] Confirming click ad for creative instance id 033a95ca-963b-460c-b203-8181346bd41c
[63985:259:0908/160542.540086:VERBOSE1:redeem_unblinded_token.cc(53)] Redeem unblinded token
[63985:259:0908/160542.903337:VERBOSE1:confirmations.cc(251)] Successfully redeemed unblinded token with confirmation id bb6acb09-49ef-4645-88aa-1b8ffb676acd, creative instance id 033a95ca-963b-460c-b203-8181346bd41c and click
[63985:259:0908/160542.903599:VERBOSE1:confirmations.cc(274)] Added 1 unblinded payment token with an estimated redemption value of 0 BAT, you now have 6 unblinded payment tokens
  • Confirmed both promoted content and inline-content ads show up/get counted:
example example example
Screen Shot 2021-09-08 at 4 13 18 PM Screen Shot 2021-09-08 at 4 13 42 PM Screen Shot 2021-09-08 at 9 03 49 AM
  • Confirmed I haven't experienced any crashers.

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

Successfully merging this pull request may close these issues.

Crash in brave_ads::AdsServiceImpl::OnGetInlineContentAd
4 participants