Skip to content

Commit

Permalink
Add hooks for HTML
Browse files Browse the repository at this point in the history
"legacy-clone a browsing session storage shed" can be used by HTML to define creation of auxiliary browsing contexts, as part of whatwg/html#5560.

"obtain a storage key" can be used by APIs that share keying logic with storage, such as BroadcastChannel and shared workers. See whatwg/html#3054. It's potentially also useful for Indexed DB as discussed in w3c/IndexedDB#334.

Closes #92.
  • Loading branch information
annevk committed May 20, 2020
1 parent 3656181 commit 6c43079
Showing 1 changed file with 58 additions and 17 deletions.
75 changes: 58 additions & 17 deletions storage.bs
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,30 @@ anticipated that some APIs will be applicable to both <a>storage types</a> going
<!-- If that does not happen by 2024 we probably ought to admit defeat and simplify this a bit. -->


<h3 id=storage-sheds>Storage sheds</h3>
<h3 id=storage-keys>Storage keys</h3>

<p>A <dfn>storage key</dfn> is an <a for=/>origin</a>. [[HTML]]

<p class=XXX>This is expected to change, see
<a href="https://privacycg.github.io/storage-partitioning/">Client-Side Storage Partitioning</a>.

<p>To <dfn export>obtain a storage key</dfn>, given an <a>environment settings object</a>
<var>environment</var>, run these steps:

<ol>
<li><p>Let <var>key</var> be <var>environment</var>'s
<a for="environment settings object">origin</a>.

<li><p>If <var>key</var> is an <a>opaque origin</a>, then return failure.

<li><p>If the user has disabled storage, then return failure.

<li><p>Return <var>key</var>.
</ol>


<h3 id=storage-sheds>Storage sheds</h3>

<p>A <dfn>storage shed</dfn> is a <a for=/>map</a> of <a>storage keys</a> to <a>storage shelves</a>.
It is initially empty.

Expand All @@ -211,6 +228,28 @@ It is initially empty.
browsing session. It is roughly analogous to <a>top-level browsing context</a> except that it cannot
be replaced due to <code>Cross-Origin-Opener-Policy</code> or navigation.

<p>To <dfn export>legacy-clone a browsing session storage shed</dfn>, given a browsing session
<var>A</var> and a browsing session <var>B</var>, run these steps:

<ol>
<li>
<p><a for=map>For each</a> <var>key</var><var>shelf</var> of <var>A</var>'s
<a for="browsing session">storage shed</a>:

<ol>
<li><p>Let <var>newShelf</var> be the result of running <a>create a storage shelf</a> with
"<code>session</code>".

<li><p>Set <var>newShelf</var>'s <a>bucket map</a>["<code>default</code>"]'s
<a>bottle map</a>["<code>sessionStorage</code>"]'s <a for="storage bottle">map</a> to a
<a for=map>clone</a> of <var>shelf</var>'s <a>bucket map</a>["<code>default</code>"]'s
<a>bottle map</a>["<code>sessionStorage</code>"]'s <a for="storage bottle">map</a>.

<li><p>Set <var>B</var>'s <a for="browsing session">storage shed</a>[<var>key</var>] to
<var>newShelf</var>.
</ol>
</ol>


<h3 id=storage-shelves>Storage shelves</h3>

Expand All @@ -228,24 +267,14 @@ given a <a for=map>value</a> when a <a>storage shelf</a> is
<var>type</var>, run these steps:

<ol>
<li><p>Let <var>key</var> be <var>environment</var>'s
<a for="environment settings object">origin</a>.
<li><p>Let <var>key</var> be the result of running <a>obtain a storage key</a> with
<var>environment</var>.

<li><p>If <var>key</var> is an <a>opaque origin</a>, then return failure.
<li><p>If <var>key</var> is failure, then return failure.

<li><p>If the user has disabled storage, then return failure.

<li>
<p>If <var>shed</var>[<var>key</var>] does not <a for=map>exist</a>, then:

<ol>
<li><p>Let <var>shelf</var> be a new <a>storage shelf</a>.

<li><p>Set <var>shelf</var>'s <a>bucket map</a>["<code>default</code>"] to the result of
<a>create a storage bucket</a> with <var>type</var>.

<li><p>Set <var>shed</var>[<var>key</var>] to <var>shelf</var>.
</ol>
<li><p>If <var>shed</var>[<var>key</var>] does not <a for=map>exist</a>, then set
<var>shed</var>[<var>key</var>] to the result of running <a>create a storage shelf</a> with
<var>type</var>.

<li><p>Return <var>shed</var>[<var>key</var>].
</ol>
Expand All @@ -254,6 +283,18 @@ given a <a for=map>value</a> when a <a>storage shelf</a> is
<var>environment</var>, return the result of running <a>obtain a storage shelf</a> with the user
agent's <a for="user agent">storage shed</a>, <var>environment</var>, and "<code>local</code>".

<p>To <dfn>create a storage shelf</dfn>, given a <a>storage type</a> <var>type</var>, run these
steps:

<ol>
<li><p>Let <var>shelf</var> be a new <a>storage shelf</a>.

<li><p>Set <var>shelf</var>'s <a>bucket map</a>["<code>default</code>"] to the result of running
<a>create a storage bucket</a> with <var>type</var>.

<li><p>Return <var>shelf</var>.
</ol>


<h3 id=buckets oldids=boxes>Storage buckets</h3>

Expand Down

0 comments on commit 6c43079

Please sign in to comment.