wpt
wpt copied to clipboard
Policy container inheritance for service workers
Project: https://docs.google.com/document/d/1mAuxWRLcmhghtCoapc30nLo0H12XTMZUJWqw079XOR8/edit?hl=en&forcehl=1
This is the part about service worker.
Attach a PolicyContainerHost to ServiceWorkerVersion. This PolicyContainerHost is obtained:
- for local schemes by cloning the creator’s PolicyContainerHost (the creator is the RenderFrameHost identified by requesting_frame_id_) in ServiceWorkerRegisterJob::StartWorkerForUpdate
- for network schemes by parsing the policies from the response headers inside ServiceWorkerNewScriptLoader::OnReceiveResponse (new script) or ServiceWorkerSingleScriptUpdateChecker::OnReceiveResponse (updated script).
- for previously loaded script which is stored in the database, we write the policy container policies to db just like the existing service worker data, hence the changes around service worker database and protocol buffer.
- The sandbox flags is represented as a int32 instead of a enum because protocol buffer enums can't be or'ed like a flag.
- CSP is skipped in this CL because the type is quite complicated and require a lot more work. We don't seem to use the policy container CSP in the renderer anyway.
- I added a test to make sure that the encoding and decoding works
The policy container is then passed down to renderer and set as the execution context's policy container.
This CL also fixes external/wpt/html/cross-origin-embedder-policy/reflection-credentialless.tentative.https.any.serviceworker.html and external/wpt/html/cross-origin-embedder-policy/reflection-require-corp.tentative.https.any.serviceworker.html because the passed down policy container contains the correct COEP.
Follow-ups: merge CSPs into our policy container.
Bug: 1177199 Change-Id: Ie90c02b8dd3e295c5456e7e2ff03685339277d6a Reviewed-on: https://chromium-review.googlesource.com/3766681 WPT-Export-Revision: ba4376ba3a9ce4c609e50ba20b9ec7de17d756de