dark-background-light-text-extension icon indicating copy to clipboard operation
dark-background-light-text-extension copied to clipboard

Firefox webextensions bug: access to cross-origin document.styleSheets[…].cssRules from content scripts should honour "permissions" from manifest.json

Open m-khvoinitsky opened this issue 7 years ago • 0 comments

TODO: HTML 5.2 will treat data:urls as different origin from current page which will break current workaround. #162 Just for tracking https://bugzilla.mozilla.org/show_bug.cgi?id=1393022

Workaround for this bug:

--- a/toolkit/components/extensions/ExtensionContent.jsm        Sun Sep 02 00:56:16 2018 +0300
+++ b/toolkit/components/extensions/ExtensionContent.jsm        Sun Sep 02 21:36:55 2018 +0300
@@ -559,7 +559,9 @@
       });
     } else {
       let principal;
-      if (ssm.isSystemPrincipal(contentPrincipal)) {
+      if (extension.manifest.permissions.includes('<all_urls>')) {
+        principal = ssm.getSystemPrincipal();
+      } else if (ssm.isSystemPrincipal(contentPrincipal)) {
         // Make sure we don't hand out the system principal by accident.
         // Also make sure that the null principal has the right origin attributes.
         principal = ssm.createNullPrincipal(attrs);

m-khvoinitsky avatar Oct 04 '17 19:10 m-khvoinitsky