Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Issue with loading files whitelisted in web_accessible_resources with Manifest v3. #544

Closed
andrewplummer opened this issue Mar 22, 2021 · 2 comments
Labels
bug Something on the site is broken!

Comments

@andrewplummer
Copy link

With Chrome 89.0.4389.90
Using manifest v3:

{
  "manifest_version": 3,
  "name": "Positionable!",
  "version": "2.1.0",
  "short_name": "Positionable",
  "description": "An extension for visually manipulating elements in the browser.",
  "offline_enabled": true,
  "icons": {
    "16": "images/app/16.png",
    "32": "images/app/32.png",
    "48": "images/app/48.png",
    "128": "images/app/128.png"
  },
  "permissions": [
    "activeTab",
    "scripting",
    "storage"
  ],
  "background": {
    "service_worker": "worker.js"
  },
  "action": {
    "default_icon": "images/app/16.png",
    "default_title": "Positionable!"
  },
  "web_accessible_resources": [
    {
      "resources": [
        "*.html",
        "*.css",
        "images/app/128.png"
      ],
      "matches": [],
      "extension_ids": []
    }
  ]
}

attempting to load files with fetch:

fetch(chrome.runtime.getURL('element.html'));

throws an error:

Denying load of chrome-extension://hjaobakeiobofnogiplphaggdbfibbfm/element.html. Resources must be listed in the web_accessible_resources manifest key in order to be loaded by pages outside the extension.

This was working fine in v2. I've tried every variation I could to whitelist the files but nothing seems to work.

@andrewplummer andrewplummer added the bug Something on the site is broken! label Mar 22, 2021
@dotproto
Copy link
Contributor

dotproto commented Mar 25, 2021

Please note that this repository is for issues related to developer.chrome.com. In the future, if you have general questions about writing extensions please post to the chromium-extensions Google Group or on Stack Overflow.

PR #539 aims to update our outdated web accessible resources documentation to reflect the changes in Manifest V3.

The code you provided appears to be working as expected. Your manifest explicitly sets empty matches and extension_ids arrays, so you're effectively telling Chrome not to match anything.

If you want to expose these resources to all pages you can modify your web accessible resources declaration as follows:

  "web_accessible_resources": [
    {
      "resources": [
        "*.html",
        "*.css",
        "images/app/128.png"
      ],
      "matches": [
        "<all_urls>"
      ]
    }
  ]

@andrewplummer
Copy link
Author

Thank you, the docs were quite unclear on this one... it seems to have worked.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something on the site is broken!
Projects
None yet
Development

No branches or pull requests

2 participants