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

Brave overwrites document.adoptedStyleSheets #14333

Closed
Artur- opened this issue Feb 24, 2021 · 6 comments · Fixed by brave/brave-core#8081
Closed

Brave overwrites document.adoptedStyleSheets #14333

Artur- opened this issue Feb 24, 2021 · 6 comments · Fixed by brave/brave-core#8081

Comments

@Artur-
Copy link

Artur- commented Feb 24, 2021

Description

When you load a document that adds something to document.adoptedStyleSheets, Brave will remove that and replace it with Brave's own content_cosmetic.cosmeticStyleSheet

Steps to Reproduce

<html>
<head>
<script> 
const sheet = new CSSStyleSheet();
sheet.replaceSync(`
span { color: blue }
`);

document.adoptedStyleSheets = [sheet, ...document.adoptedStyleSheets];

</script>          
<body>              
<span>I should be blue</span>
</body

Live version at https://artur.app.fi/brave-styles.html

Actual result:

Text is black

Expected result:

Text is blue

Reproduces how often:

Always

Desktop Brave version:

1.20.103 Chromium: 88.0.4324.152 (Official Build) (x86_64)

Version/Channel Information:

  • Can you reproduce this issue with the current release? Yes

Other Additional Information:

  • Does the issue resolve itself when disabling Brave Shields? Yes
  • Does the issue resolve itself when disabling Brave Rewards? No
  • Is the issue reproducible on the latest version of Chrome? No

Miscellaneous Information:

Caused by overwriting document.adoptedStyleSheets instead of appending

@Artur- Artur- added OS/Android Fixes related to Android browser functionality OS/Desktop labels Feb 24, 2021
Artur- added a commit to Artur-/brave-core that referenced this issue Feb 24, 2021
@Haprog
Copy link

Haprog commented Feb 24, 2021

Issue happens only with Brave Shields tracker & ad blocking. When disabling shields or selecting "Allow all trackers & ands" (keeping other shields at defaults) it works correctly.

@diracdeltas
Copy link
Member

^ cc @pes10k @SergeyZhukovsky

thanks for opening a PR

@SergeyZhukovsky
Copy link
Member

as @diracdeltas mentioned, thanks for the PR @Artur- , however I created a new one as wanted to include couple small check fixes as well. And our CI doesn't run on PRs from forks and I see some lint failures in long strings in your version. But thank you for doing it anyways, I'm going to close your PR in favour of this one brave/brave-core#8081

@LaurenWags
Copy link
Member

Labelling as QA/Blocked until uplift is completed.

@kjozwiak
Copy link
Member

kjozwiak commented Mar 1, 2021

Uplifted both brave/brave-core#8089 & brave/brave-core#8090. Should be in the next 1.21.x RC 👍

@srirambv
Copy link
Contributor

srirambv commented Mar 2, 2021

Verification passed on the following devices running 1.21.71 x64 build

  • Verified steps from issue description
OnePlus 6T (Android 10) Samsung Tab A (Android 10)

Verification passed on

Brave | 1.21.71 Chromium: 89.0.4389.72 (Official Build) (64-bit)
-- | --
Revision | 3f345f156bfd157bd1bea06310e55f3fb2490359-refs/branch-heads/4389@{#1393}
OS | Windows 10 OS Version 2004 (Build 19041.804)

1.20.110 1.21.71
image image

Verification passed on

Brave 1.21.71 Chromium: 89.0.4389.72 (Official Build) (64-bit)
Revision 3f345f156bfd157bd1bea06310e55f3fb2490359-refs/branch-heads/4389@{#1393}
OS Ubuntu 18.04 LTS

Verified test plan from the description

image


Verification passed on

Brave | 1.21.71 Chromium: 89.0.4389.72 (Official Build) (x86_64)
-- | --
Revision | 3f345f156bfd157bd1bea06310e55f3fb2490359-refs/branch-heads/4389@{#1393}
OS | macOS Version 10.15.7 (Build 19H512)
1.20.110 1.21.71
1 20 110 1 21 71

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