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

Add "get unpartitioned cookie enabled state" algo #1

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions storage-access.bs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ partial interface Document {
};
</pre>

Let |get unpartitioned cookie enabled state| be an algorithm that, given {{Document}} |doc| and [=cookie store=], runs the following steps:
shuranhuang marked this conversation as resolved.
Show resolved Hide resolved
1. Let |global| be |doc|'s [=relevant global object=].
1. Let |cookie enabled state| be the result of [=queuing a global task=] on the [=cookie store=] with |global|'s [=environment/has storage access=].

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't queue a task on the cookie store, only on a task source, see https://html.spec.whatwg.org/multipage/webappapis.html#task-source for some info (but yes it's complicated, the important bit here is that you need a task source to queue tasks, which is what you do when you want to manipulate renderer state after stepping into the browser process using "in parallel").

However, it's not entirely clear to me what this step does and why it's needed. I suppose this is still WIP and you would list out steps to get unpartitioned cookie state here?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I am trying to translate what Chrome code is currently doing into text: https://source.chromium.org/chromium/chromium/src/+/refs/heads/main:third_party/blink/renderer/core/dom/document.cc;l=5890-5897;drc=b8a0323a84f483b25e94b3a24d80fda16c5dd1ae.

It's currently making a sync function call to the CookieStore to get whether unpartitioned cookies are available.
Like you said in another comment, the cookie store concept is only loosely translated, and IIUC we want to make the spec queuing tasks to get info from other sources, this is the closest text I could come up with for now...

Copy link
Owner Author

@shuranhuang shuranhuang Jun 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PTAL the latest draft PR, in which I did the following:

  1. Made the get unpartitioned cookie enabled state algorithm incorporate more checks from hSA, and synchronous by checking Navigator.cookieEnabled; I am not sure what other spec source could be linked here, because AFAIK there is nothing to hold on to regarding the cookie part. This is also the current Chrome implementation.
  2. In hSA, added back the step that queues a task to permissions task source; I am not sure if this step should be removed; if we don't, then hSA is technically a sync method which reopens the issues hasStorageAccess() always queues a task to resolve with the environment's boolean? privacycg/storage-access#164 and Synchronous hasStorageAccess? privacycg/storage-access#146.
  3. In rSA, moved up the step that calls get unpartitioned cookie enabled state so that it does not run in parallel (because the algorithm is sync now).

1. Return |cookie enabled state|


When invoked on {{Document}} |doc|, the <dfn export method for=Document><code>hasStorageAccess()</code></dfn> method must run these steps:

<!-- https://developer.mozilla.org/en-US/docs/Web/API/Document/hasStorageAccess -->
Expand All @@ -162,7 +168,7 @@ When invoked on {{Document}} |doc|, the <dfn export method for=Document><code>ha

ISSUE: "same authority" here is a placeholder for a future concept that allows user agents to perform [=same site=] checks while adhering to additional security aspects such as the presence of a cross-site parent document, see [whatwg/storage#142](https://github.com/whatwg/storage/issues/142#issuecomment-1122147159). In practice, this might involve comparing the [=site for cookies=] or performing a [=same site=] check with the top-level document.

1. [=Queue a global task=] on the [=permissions task source=] given |global| to [=/resolve=] |p| with |global|'s [=environment/has storage access=].
1. If the result of |get unpartitioned cookie enabled state| is true, [=/resolve=] |p| with true and return |p|.
1. Return |p|.

When invoked on {{Document}} |doc|, the <dfn export method for=Document><code>requestStorageAccess()</code></dfn> method must run these steps:
Expand All @@ -185,9 +191,10 @@ When invoked on {{Document}} |doc|, the <dfn export method for=Document><code>re
NOTE: This check is [=same site=] on purpose, to allow embedded sites to use `requestStorageAccess()` to opt into storage access without involvement from the end user in scenarios where storage access is restricted for security and not privacy purposes.

1. If |doc|'s [=active sandboxing flag set=] has its [=sandbox storage access by user activation flag=] set, [=/reject=] |p| with a "{{NotAllowedError}}" {{DOMException}} and return |p|.
1. If |global|'s [=environment/has storage access=] is true, [=/resolve=] |p| with {{undefined}} and return.
1. If |global|'s [=environment/has storage access=] is true, [=/resolve=] and return |p|.
1. Let |has transient activation| be whether |doc|'s {{Window}} object has [=transient activation=].
1. Run the following steps [=in parallel=]:
1. If the result of |get unpartitioned cookie enabled state| is true, [=/resolve=] and return |p|.
1. Let |process permission state| be an algorithm that, given a [=permission state=] |state|, runs the following steps:
1. [=Queue a global task=] on the [=permission task source=] given |global| to:
1. If |state| is [=permission/granted=]:
Expand Down