Skip to content

Commit

Permalink
Editorial: simplify session history serialized state
Browse files Browse the repository at this point in the history
Previously, it could be either a serialized state or null. But, we treated null the same as the serialized form of null (i.e., StructuredSerializeForStorage(null)), when we deserialized it in "restore the history object state". This simplifies the infrastructure always having it be a serialized state, and never null.

Once this is done, it becomes clear that initializing new history entries with their serialized state set to StructuredSerializeForStorage(null) was pointless, since that is the default value. So, we can remove a couple instances of that.
  • Loading branch information
domenic committed Nov 15, 2022
1 parent 989886e commit c0e853c
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -86412,8 +86412,8 @@ interface <dfn interface>History</dfn> {
methods that are invoked on a timer, or from event listeners that are not triggered in response
to a clear user action, or that are invoked in rapid succession.)</p></li>

<li><p>Let <var>serializedData</var> be ?
<span>StructuredSerializeForStorage</span>(<var>data</var>).</p></li>
<li><p>Let <var>serializedData</var> be
<span>StructuredSerializeForStorage</span>(<var>data</var>). Rethrow any exceptions.</p></li>

<li><p>Let <var>newURL</var> be <var>document</var>'s <span
data-x="concept-document-url">URL</span>.</p></li>
Expand Down Expand Up @@ -88602,7 +88602,7 @@ interface <dfn interface>BeforeUnloadEvent</dfn> : <span>Event</span> {
state</span>.</p></li>

<li><p><dfn data-x="she-serialized-state">serialized state</dfn>, which is <span>serialized
state</span> or null, initially null.</p></li>
state</span>, initially <span>StructuredSerializeForStorage</span>(null).</p></li>

<li><p><dfn data-x="she-scroll-restoration-mode">scroll restoration mode</dfn>, a <span>scroll
restoration mode</span>, initially "<code
Expand Down Expand Up @@ -89999,9 +89999,6 @@ location.href = '#foo';</code></pre>

<dt><span data-x="she-document-state">document state</span></dt>
<dd><var>documentState</var></dd>

<dt><span data-x="she-serialized-state">serialized state</span></dt>
<dd><span>StructuredSerializeForStorage</span>(null)</dd>
</dl>

<p class="note">For the <span data-x="she-url">URL</span>, we do <em>not</em> use
Expand Down Expand Up @@ -90186,9 +90183,6 @@ location.href = '#foo';</code></pre>
<dd><var>navigable</var>'s <span data-x="nav-active-history-entry">active session history
entry</span>'s <span data-x="she-document-state">document state</span></dd>

<dt><span data-x="she-serialized-state">serialized state</span></dt>
<dd><span>StructuredSerializeForStorage</span>(null)</dd>

<dt><span data-x="she-scroll-restoration-mode">scroll restoration mode</span></dt>
<dd><var>navigable</var>'s <span data-x="nav-active-history-entry">active session history
entry</span>'s <span data-x="she-scroll-restoration-mode">scroll restoration mode</span></dd>
Expand Down Expand Up @@ -91537,7 +91531,7 @@ location.href = '#foo';</code></pre>
<li><p><span>Assert</span>: <var>locationURL</var> is a <span>URL</span>.</p></li>

<li><p>Set <var>entry</var>'s <span data-x="she-serialized-state">serialized state</span> to
null.</p></li>
<span>StructuredSerializeForStorage</span>(null).</p></li>

<li><p>Let <var>oldDocState</var> be <var>entry</var>'s <span
data-x="she-document-state">document state</span>.</p></li>
Expand Down Expand Up @@ -92111,7 +92105,7 @@ location.href = '#foo';</code></pre>
<p>If <var>targetEntry</var>'s <span data-x="she-document">document</span>'s <span
data-x="concept-document-origin">origin</span> is not <var>oldOrigin</var>, then set
<var>targetEntry</var>'s <span data-x="she-serialized-state">serialized state</span> to
null.</p>
<span>StructuredSerializeForStorage</span>(null).</p>

<p class="note">This clears history state when the origin changed vs a previous load of
<var>targetEntry</var> without a redirect occuring. This can happen due to a change in CSP
Expand Down Expand Up @@ -92696,12 +92690,9 @@ location.href = '#foo';</code></pre>
<li><p>Let <var>targetRealm</var> be <var>document</var>'s <span
data-x="concept-relevant-realm">relevant realm</span>.</p></li>

<li><p>Let <var>state</var> be null.</p></li>

<li><p>If <var>entry</var>'s <span data-x="she-serialized-state">serialized state</span> is not
null, then set <var>state</var> to <span>StructuredDeserialize</span>(<var>entry</var>'s <span
<li><p>Let <var>state</var> be <span>StructuredDeserialize</span>(<var>entry</var>'s <span
data-x="she-serialized-state">serialized state</span>, <var>targetRealm</var>). If this throws
an exception, catch it and ignore the exception.</p></li>
an exception, catch it and let <var>state</var> be null.</p></li>

<li><p>Set <var>document</var>'s <span data-x="doc-history">history object</span>'s <span
data-x="concept-history-state">state</span> to <var>state</var>.</p></li>
Expand Down

0 comments on commit c0e853c

Please sign in to comment.