Skip to content

Commit c1bfdf1

Browse files
committed
Serialize state before performing checks in navigate()/reload()
Closes #212.
1 parent 8365d94 commit c1bfdf1

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

spec.bs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -779,14 +779,16 @@ An <dfn>navigation API method navigation</dfn> is a [=struct=] with the followin
779779

780780
1. <a spec="HTML" lt="parse a URL">Parse</a> |url| relative to [=this=]'s [=relevant settings object=]. If that returns failure, then return [=an early error result=] for a "{{SyntaxError}}" {{DOMException}}. Otherwise, let |urlRecord| be the <a spec="HTML">resulting URL record</a>.
781781

782-
1. If [=this=]'s [=relevant global object=]'s [=associated Document=] is not [=Document/fully active=], then return [=an early error result=] for an "{{InvalidStateError}}" {{DOMException}}.
783-
784-
1. If [=this=]'s [=relevant global object=]'s [=associated Document=]'s <a spec="HTML">unload counter</a> is greater than 0, then return [=an early error result=] for an "{{InvalidStateError}}" {{DOMException}}.
785-
786782
1. Let |serializedState| be null.
787783

788784
1. If |options|["{{NavigationNavigateOptions/state}}"] [=map/exists=], then set |serializedState| to [$StructuredSerializeForStorage$](|options|["{{NavigationNavigateOptions/state}}"]). If this throws an exception, then return [=an early error result=] for that exception.
789785

786+
<p class="note">It is important to perform this step early, since serialization can invoke web developer code, which in turn might change the state checked in later steps.</p>
787+
788+
1. If [=this=]'s [=relevant global object=]'s [=associated Document=] is not [=Document/fully active=], then return [=an early error result=] for an "{{InvalidStateError}}" {{DOMException}}.
789+
790+
1. If [=this=]'s [=relevant global object=]'s [=associated Document=]'s <a spec="HTML">unload counter</a> is greater than 0, then return [=an early error result=] for an "{{InvalidStateError}}" {{DOMException}}.
791+
790792
1. Let |info| be |options|["{{NavigationOptions/info}}"] if it exists; otherwise, undefined.
791793

792794
1. Let |historyHandling| be "<a for="history handling behavior">`replace`</a>" if |options|["{{NavigationNavigateOptions/replace}}"] is true; otherwise, "<a for="history handling behavior">`default`</a>".
@@ -797,22 +799,24 @@ An <dfn>navigation API method navigation</dfn> is a [=struct=] with the followin
797799
<div algorithm>
798800
The <dfn method for="Navigation">reload(|options|)</dfn> method steps are:
799801

800-
1. If [=this=]'s [=relevant global object=]'s [=associated Document=] is not [=Document/fully active=], then return [=an early error result=] for an "{{InvalidStateError}}" {{DOMException}}.
801-
802-
1. If [=this=]'s [=relevant global object=]'s [=associated Document=]'s <a spec="HTML">unload counter</a> is greater than 0, then return [=an early error result=] for an "{{InvalidStateError}}" {{DOMException}}.
803-
804802
1. Let |urlRecord| be [=this=]'s [=relevant global object=]'s [=active document=]'s [=Document/URL=].
805803

806804
1. Let |serializedState| be null.
807805

808806
1. If |options|["{{NavigationReloadOptions/state}}"] [=map/exists=], then set |serializedState| to [$StructuredSerializeForStorage$](|options|["{{NavigationReloadOptions/state}}"]). If this throws an exception, then return [=an early error result=] for that exception.
809807

808+
<p class="note">It is important to perform this step early, since serialization can invoke web developer code, which in turn might change the state checked in later steps.</p>
809+
810810
1. Otherwise,
811811

812812
1. Let |current| be the [=Navigation/current entry=] of [=this=].
813813

814814
1. If |current| is not null, then set |serializedState| to |current|'s [=session history entry/navigation API state=].
815815

816+
1. If [=this=]'s [=relevant global object=]'s [=associated Document=] is not [=Document/fully active=], then return [=an early error result=] for an "{{InvalidStateError}}" {{DOMException}}.
817+
818+
1. If [=this=]'s [=relevant global object=]'s [=associated Document=]'s <a spec="HTML">unload counter</a> is greater than 0, then return [=an early error result=] for an "{{InvalidStateError}}" {{DOMException}}.
819+
816820
1. Let |info| be |options|["{{NavigationOptions/info}}"] if it exists; otherwise, undefined.
817821

818822
1. Return the result of [=performing a non-traverse navigation API navigation=] given [=this=], |urlRecord|, |serializedState|, |info|, and "<a for="history handling behavior">`reload`</a>".

0 commit comments

Comments
 (0)