I'm encountering a Content Security Policy (CSP) violation error while using `chrome.offscreen()` in my Chrome extension MV3. The issue arises when trying to create a web worker using the new Worker() constructor. Here are the relevant details:
- The error message:
```
Refused to create a worker from 'data:application/javascript;base64,... Owp9KShzZWxmKQ==' because it violates the following Content Security Policy directive: "script-src 'self' 'wasm-unsafe-eval' 'inline-speculation-rules'
http://localhost:\*
http://127.0.0.1:\*". Note that 'worker-src' was not explicitly set, so 'script-src' is used as a fallback.
```
- The HTML code in offscreen.html:
```html
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' 'wasm-unsafe-eval'; worker-src 'self' blob: data:; object-src 'self';">
<title>Extension</title>
<script defer="defer" src="src/offscreen.js"></script>
</head>
</html>
```
- The manifest.json file:
```
{
"manifest_version": 3,
"name": "Extension",
"description": "Extension description",
"version": "1.0.1",
"background": {
"service_worker": "src/backgroundPage.js",
},
"content_scripts": [
{
"matches": ["file://*/*", "http://*/*", "https://*/*"],
"js": ["src/content.js"],
"run_at": "document_start",
"all_frames": true
},
{
"matches": ["file://*/*", "http://*/*", "https://*/*"],
"js": ["src/injected.js"],
"run_at": "document_start",
"all_frames": true,
"world": "MAIN"
}
],
"content_security_policy": {
"extension_pages": "script-src 'self' 'wasm-unsafe-eval'; script-src-elem 'self' data: blob:; worker-src 'self' data: blob:; object-src 'self'"
},
"permissions": [
"scripting",
"clipboardWrite",
"activeTab",
"storage",
"notifications",
"unlimitedStorage",
"offscreen"
],
"host_permissions": ["http://*/", "https://*/", "*://*/*"],
"web_accessible_resources": [
{
"resources": ["src/content.js"],
"matches": ["*://*/*"]
},
{
"resources": ["src/offscreen.js"],
"matches": ["*://*/*"]
}
]
}
```
I have already attempted to resolve the issue by explicitly setting the 'worker-src' directive in the CSP, including the 'data:' scheme, but the error persists. I'm seeking assistance to identify the cause of this error and find a suitable solution.
Any help or insights would be greatly appreciated. Thank you!