Add spec steps and comments for fetch abort steps (#39283)

While trying to figure out what the status of this implementation was, I
added steps and comments to
see what we are missing. Also updated some links,
since I couldn't find an implementation of
`window.fetch`, since the spec URL was pointing
to the chapter instead of the algorithm.

Part of #34866

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
This commit is contained in:
Tim van der Lippe 2025-09-13 20:34:14 +02:00 committed by GitHub
parent 2f252c9b78
commit 3ef3ba9378
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 78 additions and 41 deletions

View file

@ -18,7 +18,7 @@ use crate::script_runtime::{CanGc, JSContext};
pub(crate) struct AbortController {
reflector_: Reflector,
/// An AbortController object has an associated signal (an AbortSignal object).
/// <https://dom.spec.whatwg.org/#dom-abortcontroller-signal>
signal: Dom<AbortSignal>,
}
@ -27,7 +27,7 @@ impl AbortController {
fn new_inherited(signal: &AbortSignal) -> AbortController {
// Note: continuation of the constructor steps.
// Set thiss signal to signal.
// Step 2. Set thiss signal to signal.
AbortController {
reflector_: Reflector::new(),
signal: Dom::from_ref(signal),
@ -40,9 +40,9 @@ impl AbortController {
proto: Option<HandleObject>,
can_gc: CanGc,
) -> DomRoot<AbortController> {
// The new AbortController() constructor steps are:
// Let signal be a new AbortSignal object.
// Step 1. Let signal be a new AbortSignal object.
let signal = AbortSignal::new_with_proto(global, None, can_gc);
// Step 2. Set thiss signal to signal.
reflect_dom_object_with_proto(
Box::new(AbortController::new_inherited(&signal)),
global,
@ -59,6 +59,7 @@ impl AbortController {
realm: InRealm,
can_gc: CanGc,
) {
// To signal abort on an AbortController controller with an optional reason,
// signal abort on controllers signal with reason if it is given.
self.signal.signal_abort(cx, reason, realm, can_gc);
}