mirror of
https://github.com/servo/servo.git
synced 2025-08-24 14:48:21 +01:00
Implement AbortSignal static abort(reason) (#38746)
Implement AbortSignal static abort(reason) part of #36936 --------- Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
This commit is contained in:
parent
25fea1e086
commit
c4d2b63ef1
6 changed files with 32 additions and 35 deletions
|
@ -178,6 +178,31 @@ impl AbortSignalMethods<crate::DomTypeHolder> for AbortSignal {
|
|||
self.aborted()
|
||||
}
|
||||
|
||||
/// <https://dom.spec.whatwg.org/#dom-abortsignal-abort>
|
||||
fn Abort(
|
||||
cx: SafeJSContext,
|
||||
global: &GlobalScope,
|
||||
reason: HandleValue,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<AbortSignal> {
|
||||
// Let signal be a new AbortSignal object.
|
||||
let signal = AbortSignal::new_with_proto(global, None, can_gc);
|
||||
|
||||
let abort_reason = reason.get();
|
||||
// Set signal’s abort reason to reason if it is given;
|
||||
if !abort_reason.is_undefined() {
|
||||
signal.abort_reason.set(abort_reason);
|
||||
} else {
|
||||
// otherwise to a new "AbortError" DOMException.
|
||||
rooted!(in(*cx) let mut rooted_error = UndefinedValue());
|
||||
Error::Abort.to_jsval(cx, global, rooted_error.handle_mut(), can_gc);
|
||||
signal.abort_reason.set(rooted_error.get())
|
||||
}
|
||||
|
||||
// Return signal.
|
||||
signal
|
||||
}
|
||||
|
||||
/// <https://dom.spec.whatwg.org/#dom-abortsignal-reason>
|
||||
fn Reason(&self, _cx: SafeJSContext, mut rval: MutableHandleValue) {
|
||||
// The reason getter steps are to return this’s abort reason.
|
||||
|
|
|
@ -19,6 +19,10 @@ DOMInterfaces = {
|
|||
'inRealms': ['Abort'],
|
||||
},
|
||||
|
||||
'AbortSignal': {
|
||||
'canGc':['Abort'],
|
||||
},
|
||||
|
||||
'AbstractRange': {
|
||||
'weakReferenceable': True,
|
||||
},
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
[Exposed=*, Pref="dom_abort_controller_enabled"]
|
||||
interface AbortSignal : EventTarget {
|
||||
[NewObject] static AbortSignal abort(optional any reason);
|
||||
readonly attribute boolean aborted;
|
||||
readonly attribute any reason;
|
||||
undefined throwIfAborted();
|
||||
|
|
14
tests/wpt/meta/dom/abort/AbortSignal.any.js.ini
vendored
14
tests/wpt/meta/dom/abort/AbortSignal.any.js.ini
vendored
|
@ -1,10 +1,4 @@
|
|||
[AbortSignal.any.html]
|
||||
[the AbortSignal.abort() static returns an already aborted signal]
|
||||
expected: FAIL
|
||||
|
||||
[signal returned by AbortSignal.abort() should not fire abort event]
|
||||
expected: FAIL
|
||||
|
||||
[AbortSignal.timeout() returns a non-aborted signal]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -16,12 +10,6 @@
|
|||
|
||||
|
||||
[AbortSignal.any.worker.html]
|
||||
[the AbortSignal.abort() static returns an already aborted signal]
|
||||
expected: FAIL
|
||||
|
||||
[signal returned by AbortSignal.abort() should not fire abort event]
|
||||
expected: FAIL
|
||||
|
||||
[AbortSignal.timeout() returns a non-aborted signal]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -42,7 +30,7 @@
|
|||
expected: ERROR
|
||||
|
||||
[AbortSignal.https.any.shadowrealm-in-audioworklet.html]
|
||||
expected: ERROR
|
||||
expected: TIMEOUT
|
||||
|
||||
[AbortSignal.any.shadowrealm-in-dedicatedworker.html]
|
||||
expected: ERROR
|
||||
|
|
20
tests/wpt/meta/dom/abort/event.any.js.ini
vendored
20
tests/wpt/meta/dom/abort/event.any.js.ini
vendored
|
@ -1,36 +1,18 @@
|
|||
[event.any.html]
|
||||
[static aborting signal should have right properties]
|
||||
expected: FAIL
|
||||
|
||||
[static aborting signal with reason should set signal.reason]
|
||||
expected: FAIL
|
||||
|
||||
[throwIfAborted() should throw abort.reason if signal aborted]
|
||||
expected: FAIL
|
||||
|
||||
[throwIfAborted() should throw primitive abort.reason if signal aborted]
|
||||
expected: FAIL
|
||||
|
||||
[AbortSignal.reason returns the same DOMException]
|
||||
expected: FAIL
|
||||
|
||||
|
||||
[event.any.worker.html]
|
||||
[static aborting signal should have right properties]
|
||||
expected: FAIL
|
||||
|
||||
[static aborting signal with reason should set signal.reason]
|
||||
expected: FAIL
|
||||
|
||||
[throwIfAborted() should throw abort.reason if signal aborted]
|
||||
expected: FAIL
|
||||
|
||||
[throwIfAborted() should throw primitive abort.reason if signal aborted]
|
||||
expected: FAIL
|
||||
|
||||
[AbortSignal.reason returns the same DOMException]
|
||||
expected: FAIL
|
||||
|
||||
|
||||
[event.any.shadowrealm.html]
|
||||
expected: TIMEOUT
|
||||
|
@ -42,7 +24,7 @@
|
|||
expected: ERROR
|
||||
|
||||
[event.https.any.shadowrealm-in-audioworklet.html]
|
||||
expected: ERROR
|
||||
expected: TIMEOUT
|
||||
|
||||
[event.https.any.shadowrealm-in-serviceworker.html]
|
||||
expected: ERROR
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
[reason-constructor.html]
|
||||
[AbortSignal.reason.constructor should be from iframe]
|
||||
expected: FAIL
|
Loading…
Add table
Add a link
Reference in a new issue