Skip to content

Commit df02011

Browse files
authored
Include the "Shared-Storage-Cross-Origin-Worklet-Allowed" response header check
This is a follow-up patch for #131. For starting a cross-origin worklet, this response header is needed.
1 parent 52b2115 commit df02011

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

spec.bs

+15-1
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,18 @@ Moreover, each {{SharedStorageWorklet}}'s [=global scopes|list of global scopes=
466466

467467
Note: For shared storage, redirects are disallowed for the module script request. With this restriction, it's possible to define and to use the algorithm that gets the |realm|'s [=realm/settings object=]'s [=environment settings object/origin=] (as described in [[#set-up-a-worklet-environment-settings-object-monkey-patch]]) as soon as the {{SharedStorageWorkletGlobalScope}} is created, as the origin won't change. This restriction may be removed in a future iteration of the design. If redirects become allowed, presumably, the algorithm that gets the |realm|'s [=realm/settings object=]'s [=environment settings object/origin=] should be updated to return the final request's [=request/URL=]'s [=url/origin=] after receiving the final request's response, and the user preference checkings shall only be done after that point.
468468

469+
### Monkey Patch for [=HTTP fetch=] ### {#http-fetch-monkey-patch}
470+
The following step will be added to the [=HTTP fetch=] steps, before checking the redirect status (i.e. "If |actualResponse|'s status is a redirect status, ..."):
471+
472+
1. If |request|'s [=request/destination=] is "sharedstorageworklet":
473+
1. [=Assert=]: |request|'s [=request/client=] is not null.
474+
1. If |request|'s [=request/client=]'s [=environment settings object/origin=] and |request|'s [=request/origin=] are not [=same origin=]:
475+
1. Let |list| be |actualResponse|'s [=response/header list=].
476+
1. Let |allowed| be the result of running [=get a structured field value=] algorithm given "Shared-Storage-Cross-Origin-Worklet-Allowed", "item", and |list| as input.
477+
1. If |allowed| is false, then return a [=network error=].
478+
479+
Note: The website that serves the module script must carefully consider the security risks: when the module script's [=/URL=]'s [=url/origin=] and the worklet's creator {{Window}} origin are not [=same origin=], by sending permissive CORS headers and the "Shared-Storage-Cross-Origin-Worklet-Allowed" header on the module script response, the server will be granting the worklet's creation and subsequent operations on the worklet. For example, the worklet's creator {{Window}} could poison and use up the worklet origin's [=remaining navigation budget=] by calling {{SharedStorageWorklet/selectURL()}} or {{SharedStorageWorklet/run()}}, where the worklet origin is the global scope's [=global object/realm=]'s [=realm/settings object=]'s [=environment settings object/origin=].
480+
469481
### Monkey Patch for {{Worklet/addModule()}} ### {#add-module-monkey-patch}
470482

471483
The {{Worklet/addModule()}} method steps for {{Worklet}} will need to include the following step before the step "Let |promise| be a new promise":
@@ -501,7 +513,9 @@ Moreover, each {{SharedStorageWorklet}}'s [=global scopes|list of global scopes=
501513

502514
The {{SharedStorageWorklet}}'s [=worklet destination type=] is "sharedstorageworklet".
503515

504-
Issue(145): Add "sharedstorageworklet" to the possible strings that a request [=request/destination=] can have.
516+
### Monkey Patch for request [=request/destination=] ### {#request-destination-monkey-patch}
517+
518+
The fetch request's [=request/destination=] field should additionally include the "sharedstorageworklet" option.
505519

506520
<xmp class='idl'>
507521
callback RunFunctionForSharedStorageSelectURLOperation = Promise<unsigned long>(sequence<USVString> urls, optional any data);

0 commit comments

Comments
 (0)