-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add worker script explanation to COOP-COEP article #8206
Conversation
|
Hello! This is an automated review by our custom reviewbot. It updates automatically when code or GitHub comments in this pull request are created or updated. Requested changesIf there are any common problems with the content files you created or modified, they will be listed here.
|
✅ Deploy Preview for web-dev-staging ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
ArthurSonzogni
left a comment
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
Here are some comments below:
src/site/content/en/secure/cross-origin-isolation-guide/index.md
Outdated
Show resolved
Hide resolved
src/site/content/en/secure/cross-origin-isolation-guide/index.md
Outdated
Show resolved
Hide resolved
|
@ArthurSonzogni Please approve if the current changes look good |
alexandrascript
left a comment
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM % small updates
src/site/content/en/secure/cross-origin-isolation-guide/index.md
Outdated
Show resolved
Hide resolved
ArthurSonzogni
left a comment
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! LGTM % removing the sentence about CORP and workers.
| * For iframes, use CORP and COEP headers as follows: | ||
| `Cross-Origin-Resource-Policy: same-origin` (or `same-site`, `cross-origin` | ||
| depending on the context) and `Cross-Origin-Embedder-Policy: require-corp`. | ||
| * For iframes and worker scripts, set the `Cross-Origin-Resource-Policy: |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting CORP is needed only for cross-origin iframe. Not really useful for workers. They are always same-origin.
So, I would remove the "and worker scripts".
COEP on the other site is needed or useful for every environments created by the document. You moved the section later. This is discussed separately, which works.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can only spawn a same-origin worker at the first level, but can load a cross-origin script via that worker if you use importScripts. In that case, you have to use CORP: cross-origin header. You can see it working at https://cross-origin-isolation.glitch.me/?coep=require-corp&
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this contradicts 🤔
https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers#spawning_subworkers
Workers may spawn more workers if they wish. So-called sub-workers must be hosted within the same origin as the parent page.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understood "worker script" as the "worker's main response".
This is right worker can then use fetch/importScript to load any resources and those resources are subject to CORP checks. Yes, you can nested DedicatedWorker.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, how about phrasing the line like this:
For iframes and cross-origin worker scripts loaded via `importScripts`, set the `Cross-Origin-Resource-Policy:
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels weird, because it would mean this applies exclusively to those two resources, which is wrong; it applies to every resources.
Also, I feel weird putting on the same level the main resources (the iframe's response) and a subresource (an external script loaded from the worker).
Maybe you can discuss about all subresources, indepedently of the context (window or worker), and give some examples of subresources?
- From a
COEP:require-corpdocument or aCOEP:require-corpworker, cross-origin subresources loaded without CORS must setCross-Origin-Resource-Policy: cross-originheader to opt-in being embedded. For instance, this applies to:<script>,importScript,<link>,<video>,<iframe>, etc...
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a great idea. I'll create a pull request so we can continue the discussion there.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pull request updates https://web.dev/cross-origin-isolation-guide/ and https://web.dev/coop-coep/ to better explain how to opt-in to cross-origin isolation when worker scripts are used.
cc: @ArthurSonzogni