Firefox error: "Uncaught DOMException: CSSStyleSheet.cssRules getter: Not allowed to access cross-origin stylesheet"
See original GitHub issueRecreating #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:
- Created 2 years ago
- Comments:8 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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!
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!