question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Brave overwrites document.adoptedStyleSheets

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
diracdeltascommented, Feb 25, 2021

^ cc @pes10k @SergeyZhukovsky

thanks for opening a PR

0reactions
srirambvcommented, 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
Read more comments on GitHub >

github_iconTop Results From Across the Web

Support cosmetic filtering `!important` display overrides in ...
It is still not yet supported in Standard shields mode due to the use of document.adoptedStyleSheets . The addRule and removeRule APIs it ......
Read more >
Document.adoptedStyleSheets - Web APIs | MDN
The adoptedStyleSheets property of the Document interface is used for setting an array of constructed stylesheets to be used by the document.
Read more >
Constructable Stylesheets - web.dev
Constructable Stylesheets provide a seamless way to create and distribute styles to documents or shadow roots without worrying about FOUC.
Read more >
Where can I change default css styles for Brave browser?
I am using personalized high contrast visuals in my Windows 10 OS but this overrides browser rendering for all webpages.
Read more >
A Quick Look at Constructable Stylesheets
We use created stylesheets by using the adoptedStyleSheets property which Documents and Shadow DOMs possess. This property lets us explicitly ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found