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.

Firefox error: "Uncaught DOMException: CSSStyleSheet.cssRules getter: Not allowed to access cross-origin stylesheet"

See original GitHub issue

Recreating #278 but with a call stack:

SecurityError: CSSStyleSheet.cssRules getter: Not allowed to access cross-origin stylesheet
  at d/e.handlePrint/M.onload @ https://www.codecademy.com/webpack/252.4033dce2c049256b0fb3.chunk.js:1:4303

252.4033dce2c049256b0fb3.chunk.js.txt

The specific line that’s throwing the error is https://github.com/gregnb/react-to-print/blob/c224cf7f03c7fc44478cafd60fef2a822d97adca/src/index.tsx#L376

Root cause: sheet.cssRules is getting blocked by Firefox: https://discourse.mozilla.org/t/webextensions-porting-access-to-cross-origin-document-stylesheets-cssrules/18359 / https://discourse.mozilla.org/t/accessing-some-fonts-css-style-sheet-via-stylesheet-throws-securityerror/38717.

I don’t know how to work around this 😄 … maybe log a warning and continue without the styles?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
MatthewHerbstcommented, Nov 22, 2021

The fix for this has been published in v2.14.1, please let me know if you run into any other issues. Thanks so much for the debugging help!

2reactions
MatthewHerbstcommented, Nov 12, 2021

Hi @JoshuaKGoldberg thanks so much for the report and big thanks for the links, that explains a lot. I’ve made a comment on https://bugzilla.mozilla.org/show_bug.cgi?id=1393022 so hopefully we can get an answer from the Firefox team soon, but I agree for now it would be nice if react-to-print could do its best to gracefully handle the error. I’ll take a look at pushing a fix for that this weekend!

Read more comments on GitHub >

github_iconTop Results From Across the Web

CSSStyleSheet.cssRules getter: Not allowed to access cross ...
With a chrome driver I get the error error reading property . I am trying to get the document.styleSheets of a page, but...
Read more >
Accessing some font's "CSS" style sheet via styleSheet throws ...
Enter document.styleSheets[1].cssRules . What happens. It throws a security error: SecurityError: The operation is insecure.
Read more >
How to Fix the “Failed to Read the CSSRules Property From ...
If your CSS Stylesheet is from the same domain as the HTML, you will be able to access the document.styleSheets.get(index).cssRules property ...
Read more >
Issue with CSSRule Plugin (DOMException) - GSAP
Firefox Dev Edition: DOMException: "CSSStyleSheet.cssRules getter: Not allowed to access cross-origin stylesheet".
Read more >
Developers - cross-origin stylesheet - - Bountysource
I'm getting this error: Uncaught DOMException: CSSStyleSheet.cssRules getter: Not allowed to access cross-origin stylesheet. See More.
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