Skip to content

Commit 0357c26

Browse files
committed
Specify event.signal
1 parent e62682f commit 0357c26

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

spec.bs

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ interface AppHistoryNavigateEvent : Event {
470470
readonly attribute boolean canRespond;
471471
readonly attribute boolean userInitiated;
472472
readonly attribute boolean hashChange;
473-
// readonly attribute AbortSignal signal;
473+
readonly attribute AbortSignal signal;
474474
readonly attribute FormData? formData;
475475
readonly attribute any info;
476476

@@ -483,7 +483,7 @@ dictionary AppHistoryNavigateEventInit : EventInit {
483483
boolean canRespond = false;
484484
boolean userInitiated = false;
485485
boolean hashChange = false;
486-
// required AbortSignal signal;
486+
required AbortSignal signal;
487487
FormData? formData = null;
488488
any info = null;
489489
};
@@ -523,14 +523,12 @@ enum AppHistoryNavigationType {
523523
<p>True if this navigation is a <a spec="HTML" lt="navigate to a fragment">fragment navigation</a>; false otherwise.
524524
</dd>
525525

526-
<!--
527526
<dt><code><var ignore>event</var> . {{AppHistoryNavigateEvent/signal}}</code>
528527
<dd>
529528
<p>An {{AbortSignal}} which will become aborted if the navigation gets canceled, e.g. by the user pressing their browser's "Stop" button, or another higher-priority navigation interrupting this one.
530529

531530
<p>The expected pattern is for developers to pass this along to any async operations, such as {{WindowOrWorkerGlobalScope/fetch()}}, which they perform as part of handling this navigation.
532531
</dd>
533-
-->
534532

535533
<dt><code><var ignore>event</var> . {{AppHistoryNavigateEvent/formData}}</code>
536534
<dd>
@@ -552,7 +550,7 @@ enum AppHistoryNavigationType {
552550
</dd>
553551
</dl>
554552

555-
The <dfn attribute for="AppHistoryNavigateEvent">navigationType</dfn>, <dfn attribute for="AppHistoryNavigateEvent">destination</dfn>, <dfn attribute for="AppHistoryNavigateEvent">canRespond</dfn>, <dfn attribute for="AppHistoryNavigateEvent">userInitiated</dfn>, <dfn attribute for="AppHistoryNavigateEvent">hashChange</dfn><!--, <dfn attribute for="AppHistoryNavigateEvent">signal</dfn>-->, <dfn attribute for="AppHistoryNavigateEvent">formData</dfn>, and <dfn attribute for="AppHistoryNavigateEvent">info</dfn> getter steps are to return the value that the corresponding attribute was initialized to.
553+
The <dfn attribute for="AppHistoryNavigateEvent">navigationType</dfn>, <dfn attribute for="AppHistoryNavigateEvent">destination</dfn>, <dfn attribute for="AppHistoryNavigateEvent">canRespond</dfn>, <dfn attribute for="AppHistoryNavigateEvent">userInitiated</dfn>, <dfn attribute for="AppHistoryNavigateEvent">hashChange</dfn>, <dfn attribute for="AppHistoryNavigateEvent">signal</dfn>, <dfn attribute for="AppHistoryNavigateEvent">formData</dfn>, and <dfn attribute for="AppHistoryNavigateEvent">info</dfn> getter steps are to return the value that the corresponding attribute was initialized to.
556554

557555
An {{AppHistoryNavigateEvent}} has the following associated values which are only conditionally used:
558556

@@ -675,7 +673,7 @@ The <dfn attribute for="AppHistoryDestination">sameDocument</dfn> getter steps a
675673
1. Let |result| be the result of [=dispatching=] |event| at |appHistory|.
676674
1. Set |appHistory|'s [=AppHistory/ongoing navigate event=] to null.
677675
1. If |appHistory|'s [=relevant global object=]'s [=active Document=] is not [=Document/fully active=], then:
678-
1. [=Synchronously finalize with an aborted navigation error=] for |appHistory|.
676+
1. [=Synchronously finalize with an aborted navigation error=] given |appHistory| and |event|'s {{AppHistoryNavigateEvent/signal}}.
679677
1. Return false.
680678

681679
<p class="note">This can occur if an event listener disconnected the <{iframe}> corresponding to [=this=]'s [=relevant global object=].</p>
@@ -699,17 +697,19 @@ The <dfn attribute for="AppHistoryDestination">sameDocument</dfn> getter steps a
699697
1. Set |appHistory|'s [=AppHistory/navigate method call serialized state=] to null.
700698

701699
<p class="note">This ensures that any call to {{AppHistory/navigate()|appHistory.navigate()}} which triggered this algorithm does not overwrite the [=session history entry/app history state=] of the [=session history/current entry=] for cross-document navigations.
702-
1. Otherwise, [=synchronously finalize with an aborted navigation error=] for |appHistory|.
700+
1. Otherwise, [=synchronously finalize with an aborted navigation error=] given |appHistory| and |event|'s {{AppHistoryNavigateEvent/signal}}.
703701
1. Return |result|.
704702
</div>
705703

706-
<!-- TODO hook this up to the stop button etc. For now it just centralizes the ways a couple ways a navigate event handler can cause an abort. -->
707704
<div algorithm>
708-
To <dfn>synchronously finalize with an aborted navigation error</dfn> for an {{AppHistory}} |appHistory|:
705+
To <dfn>synchronously finalize with an aborted navigation error</dfn> given an {{AppHistory}} |appHistory| and an {{AbortSignal}} |signal|:
709706

710707
1. Set |appHistory|'s [=AppHistory/navigate method call serialized state=] to null.
711708

712709
<p class="note">This ensures that any call to {{AppHistory/navigate()|appHistory.navigate()}} which triggered this algorithm does not overwrite the [=session history entry/app history state=] of the [=session history/current entry=] for aborted navigations.
710+
1. [=AbortSignal/Signal abort=] on |signal|.
711+
712+
<p class="note">This might do nothing, if |signal| was previously aborted by <a>cancel any ongoing `navigate` event</a>.</p>
713713
1. [=Queue a microtask=] on |appHistory|'s [=relevant agent=]'s [=agent/event loop=] to perform the following steps:
714714
1. Let |error| be a [=new=] "{{AbortError}}" {{DOMException}}, created in |appHistory|'s [=relevant Realm=].
715715
1. [=Fire an event=] named {{AppHistory/navigateerror}} at |appHistory| using {{ErrorEvent}}, with {{ErrorEvent/error}} initialized to |error|, {{ErrorEvent/message}} initialized to the value of |error|'s {{DOMException/message}} property, {{ErrorEvent/filename}} initialized to the empty string, and {{ErrorEvent/lineno}} and {{ErrorEvent/colno}} initialized to 0.
@@ -722,6 +722,9 @@ The <dfn attribute for="AppHistoryDestination">sameDocument</dfn> getter steps a
722722
1. If |appHistory|'s [=AppHistory/ongoing navigate event=] is non-null, then:
723723
1. Set |appHistory|'s [=AppHistory/ongoing navigate event=]'s [=Event/canceled flag=] to true.
724724
1. Set |appHistory|'s [=AppHistory/ongoing navigate event=] to null.
725+
1. [=AbortSignal/Signal abort=] on |appHistory|'s [=AppHistory/ongoing navigate event=]'s {{AppHistoryNavigateEvent/signal}}.
726+
727+
<p class="note">Because this cancels the event, this will eventually lead to the <a>inner `navigate` event firing algorithm</a> calling [=synchronously finalize with an aborted navigation error=] once the event firing process completes. However, we want to [=AbortSignal/signal abort=] on the relevant {{AppHistoryNavigateEvent/signal|event.signal}} right away.
725728
</div>
726729

727730
<!-- Remember to modify pushState()/replaceState() to use this, when we eventually move to the HTML Standard. -->
@@ -1090,3 +1093,15 @@ Potentially update the <a spec="HTML">traverse the history</a> algorithm to cons
10901093
</div>
10911094

10921095
<p class="note">We do not [=AppHistory/update the entries=] when initially <a spec="HTML">creating a new browsing context</a>, as we intentionally don't want to include the initial `about:blank` {{Document}} in any app history entry list.
1096+
1097+
<h2 id="other-patches">Other patches</h2>
1098+
1099+
<h3 id="cancel-navigation">Canceling navigation</h3>
1100+
1101+
The existing HTML specification discusses canceling a navigation in a few places. However, the process is not very well-defined. We may be able to make it more rigorous, after the <a href="https://github.com/whatwg/html/issues/5767">session history rewrite</a> lands.
1102+
1103+
<div algorithm="navigation canceling patch">
1104+
The main addition of app history is that any time navigation of a given [=browsing context=] |bc| is canceled, the user agent must <a>cancel any ongoing `navigate` event</a> for |bc|'s [=browsing context/active window=]'s [=Window/app history=].
1105+
</div>
1106+
1107+
<p class="note">This includes navigation cancelation induced by the <a spec="HTML">stop document loading</a> algorithm, which is invoked by user interface elements such as a stop button and by {{Window/stop()|window.stop()}}.</p>

0 commit comments

Comments
 (0)