Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content Security Policy error in Firefox extension #37

Closed
geeknees opened this issue Apr 28, 2021 · 6 comments · Fixed by #39
Closed

Content Security Policy error in Firefox extension #37

geeknees opened this issue Apr 28, 2021 · 6 comments · Fixed by #39
Labels
Type: Bug Bug or Bug fixes

Comments

@geeknees
Copy link

Thank you for developing such a great extension.
I'm using Firefox and it seems to be stuck on the Content Security Policy issue and the worker doesn't work properly.

In the console of Service Workers, I am getting the following error.

Content Security Policy: ページの設定により次のリソースの読み込みをブロックしました: blob:moz-extension://131dce08-cad1-0f4e-a2d1-bbaa135d5fd6/dbb9e923-6275-c845-9fb4-5b9956a48008 (“script-src”)

Is there any way to solve this problem?

I know that there is a workaround to turn off the CSP for your entire browser in Firefox by disabling security.csp.enable in the about:config menu.

@azu azu added the Type: Bug Bug or Bug fixes label Apr 28, 2021
@azu

This comment has been minimized.

@azu
Copy link
Member

azu commented Apr 28, 2021

Ah, I missed.

This error is caused by WebWorker in background.

export const createTextlintWorker = (script: Script) => {
const blob = new Blob([script.code], { type: "application/javascript" });
const workerUrl = URL.createObjectURL(blob);
const textlintrc = JSON.parse(script.textlintrc) as TextlintRcConfig;
const defaultWorker = new Worker(workerUrl);
const workerRef = createWorkerRef(defaultWorker);

Probably, We can resolve this issue by moving textlint script worker to CotentScript.
#33 is related.

@geeknees
Copy link
Author

Thanks for the quick confirmation.
I'm glad that there seems to be a solution somehow.

I'm not familiar with extention and WebWorker, so I don't know if I can help, but I'll take a look at it myself.

@azu
Copy link
Member

azu commented Apr 28, 2021

I've moved WebWorker to ContentScript from BackgroundScript and I've met another problem.
Some website like GitHub use CSP that block ContentScript's web worker...

image

Work on no-CSP website

image

I'll investigate content_security_policy.
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/content_security_policy

@azu
Copy link
Member

azu commented Apr 28, 2021

Probably, #39 will fix CSP error.

@geeknees
Copy link
Author

Thank you for the quick response. I was able to confirm the fix in my environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Bug or Bug fixes
Projects
None yet
2 participants