Skip to content

Commit 6c43079

Browse files
committed
Add hooks for HTML
"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.
1 parent 3656181 commit 6c43079

File tree

1 file changed

+58
-17
lines changed

1 file changed

+58
-17
lines changed

storage.bs

Lines changed: 58 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,30 @@ anticipated that some APIs will be applicable to both <a>storage types</a> going
185185
<!-- If that does not happen by 2024 we probably ought to admit defeat and simplify this a bit. -->
186186

187187

188-
<h3 id=storage-sheds>Storage sheds</h3>
188+
<h3 id=storage-keys>Storage keys</h3>
189189

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

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

195+
<p>To <dfn export>obtain a storage key</dfn>, given an <a>environment settings object</a>
196+
<var>environment</var>, run these steps:
197+
198+
<ol>
199+
<li><p>Let <var>key</var> be <var>environment</var>'s
200+
<a for="environment settings object">origin</a>.
201+
202+
<li><p>If <var>key</var> is an <a>opaque origin</a>, then return failure.
203+
204+
<li><p>If the user has disabled storage, then return failure.
205+
206+
<li><p>Return <var>key</var>.
207+
</ol>
208+
209+
210+
<h3 id=storage-sheds>Storage sheds</h3>
211+
195212
<p>A <dfn>storage shed</dfn> is a <a for=/>map</a> of <a>storage keys</a> to <a>storage shelves</a>.
196213
It is initially empty.
197214

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

231+
<p>To <dfn export>legacy-clone a browsing session storage shed</dfn>, given a browsing session
232+
<var>A</var> and a browsing session <var>B</var>, run these steps:
233+
234+
<ol>
235+
<li>
236+
<p><a for=map>For each</a> <var>key</var><var>shelf</var> of <var>A</var>'s
237+
<a for="browsing session">storage shed</a>:
238+
239+
<ol>
240+
<li><p>Let <var>newShelf</var> be the result of running <a>create a storage shelf</a> with
241+
"<code>session</code>".
242+
243+
<li><p>Set <var>newShelf</var>'s <a>bucket map</a>["<code>default</code>"]'s
244+
<a>bottle map</a>["<code>sessionStorage</code>"]'s <a for="storage bottle">map</a> to a
245+
<a for=map>clone</a> of <var>shelf</var>'s <a>bucket map</a>["<code>default</code>"]'s
246+
<a>bottle map</a>["<code>sessionStorage</code>"]'s <a for="storage bottle">map</a>.
247+
248+
<li><p>Set <var>B</var>'s <a for="browsing session">storage shed</a>[<var>key</var>] to
249+
<var>newShelf</var>.
250+
</ol>
251+
</ol>
252+
214253

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

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

230269
<ol>
231-
<li><p>Let <var>key</var> be <var>environment</var>'s
232-
<a for="environment settings object">origin</a>.
270+
<li><p>Let <var>key</var> be the result of running <a>obtain a storage key</a> with
271+
<var>environment</var>.
233272

234-
<li><p>If <var>key</var> is an <a>opaque origin</a>, then return failure.
273+
<li><p>If <var>key</var> is failure, then return failure.
235274

236-
<li><p>If the user has disabled storage, then return failure.
237-
238-
<li>
239-
<p>If <var>shed</var>[<var>key</var>] does not <a for=map>exist</a>, then:
240-
241-
<ol>
242-
<li><p>Let <var>shelf</var> be a new <a>storage shelf</a>.
243-
244-
<li><p>Set <var>shelf</var>'s <a>bucket map</a>["<code>default</code>"] to the result of
245-
<a>create a storage bucket</a> with <var>type</var>.
246-
247-
<li><p>Set <var>shed</var>[<var>key</var>] to <var>shelf</var>.
248-
</ol>
275+
<li><p>If <var>shed</var>[<var>key</var>] does not <a for=map>exist</a>, then set
276+
<var>shed</var>[<var>key</var>] to the result of running <a>create a storage shelf</a> with
277+
<var>type</var>.
249278

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

286+
<p>To <dfn>create a storage shelf</dfn>, given a <a>storage type</a> <var>type</var>, run these
287+
steps:
288+
289+
<ol>
290+
<li><p>Let <var>shelf</var> be a new <a>storage shelf</a>.
291+
292+
<li><p>Set <var>shelf</var>'s <a>bucket map</a>["<code>default</code>"] to the result of running
293+
<a>create a storage bucket</a> with <var>type</var>.
294+
295+
<li><p>Return <var>shelf</var>.
296+
</ol>
297+
257298

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

0 commit comments

Comments
 (0)