Branden Ham
Branden Ham

Reputation: 92

Error: Content Security Policy: The page’s settings blocked the loading of a resource

I've been trying to move a simple program I made in jQuery/HTML to a Firefox WebExtension for easy deployment. The error I am getting is:

Content Security Policy: The page’s settings blocked the loading of a resource at https://code.jquery.com/jquery-1.12.4.js (“script-src moz-extension://ef8f1295-1912-4912-ab2e-121053b6781a”).

I'm sure I'm just not doing the manifest.json file right, but for the life of me I don't know where:

{
  "description": "Makes tasks from different underwriters uniform",
  "manifest_version": 2,
  "name": "Task Creator",
  "version": ".5",
  "permissions": [
    "http://*/*", "tabs", "https://*/*"
  ],

  "icons": {
    "48": "icons/page-48.png"
  },
  "web_accessible_resources": [
    "style/popUpStyle.css",
    "script/popUpTask.js",
    "script/logicTaskFiller.js",
    "js/autosize.js",
    "style/https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css",
    "js/https://code.jquery.com/jquery-1.12.4.js",
    "js/https://code.jquery.com/ui/1.12.1/jquery-ui.js"
  ],

  "background": {
    "scripts": ["background.js"]
  },

  "browser_action": {
    "default_icon": "icons/page-32.png"
  }
}

Upvotes: 5

Views: 11759

Answers (1)

user149341
user149341

Reputation:

By default, extensions cannot load scripts, or other object resources, from the Internet. All CSS and JavaScript content used by your extension should be part of the extension package.

(This documentation is from Chrome, but the exact same policies apply to Firefox WebExtensions.)

It's possible to relax these restrictions somewhat, but this should generally be avoided -- loading resources from a remote server will make your extension fail to work properly if the user does not have Internet access, or if they are behind a restrictive firewall. Additionally, addons.mozilla.org will not accept addons which execute remotely hosted Javascript.

Upvotes: 5

Related Questions