mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
script: stub AbortSignal
(#37033)
This is a stub for `AbortSignal`, which we would like to merge first in order to work in parallel on https://github.com/servo/servo/issues/34866, and perhaps also https://github.com/servo/servo/issues/36936 --------- Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com> Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com> Co-authored-by: Taym Haddadi <haddadi.taym@gmail.com>
This commit is contained in:
parent
270dcf879d
commit
324196351e
6 changed files with 330 additions and 0 deletions
71
components/script/dom/abortsignal.rs
Normal file
71
components/script/dom/abortsignal.rs
Normal file
|
@ -0,0 +1,71 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom_struct::dom_struct;
|
||||
use js::jsapi::Heap;
|
||||
use js::jsval::JSVal;
|
||||
use js::rust::{HandleObject, MutableHandleValue};
|
||||
|
||||
use crate::dom::bindings::codegen::Bindings::AbortSignalBinding::AbortSignalMethods;
|
||||
use crate::dom::bindings::reflector::reflect_dom_object_with_proto;
|
||||
use crate::dom::bindings::root::DomRoot;
|
||||
use crate::dom::eventtarget::EventTarget;
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
use crate::script_runtime::{CanGc, JSContext};
|
||||
|
||||
/// <https://dom.spec.whatwg.org/#abortsignal>
|
||||
#[dom_struct]
|
||||
pub(crate) struct AbortSignal {
|
||||
eventtarget: EventTarget,
|
||||
|
||||
/// <https://dom.spec.whatwg.org/#abortsignal-abort-reason>
|
||||
#[ignore_malloc_size_of = "mozjs"]
|
||||
abort_reason: Heap<JSVal>,
|
||||
}
|
||||
|
||||
impl AbortSignal {
|
||||
#[allow(dead_code)]
|
||||
fn new_inherited() -> AbortSignal {
|
||||
AbortSignal {
|
||||
eventtarget: EventTarget::new_inherited(),
|
||||
abort_reason: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn new_with_proto(
|
||||
global: &GlobalScope,
|
||||
proto: Option<HandleObject>,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<AbortSignal> {
|
||||
reflect_dom_object_with_proto(
|
||||
Box::new(AbortSignal::new_inherited()),
|
||||
global,
|
||||
proto,
|
||||
can_gc,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl AbortSignalMethods<crate::DomTypeHolder> for AbortSignal {
|
||||
/// <https://dom.spec.whatwg.org/#dom-abortsignal-aborted>
|
||||
fn Aborted(&self) -> bool {
|
||||
// TODO
|
||||
false
|
||||
}
|
||||
|
||||
/// <https://dom.spec.whatwg.org/#dom-abortsignal-reason>
|
||||
fn Reason(&self, _: JSContext, _rval: MutableHandleValue) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
/// <https://dom.spec.whatwg.org/#dom-abortsignal-throwifaborted>
|
||||
#[allow(unsafe_code)]
|
||||
fn ThrowIfAborted(&self) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
// <https://dom.spec.whatwg.org/#dom-abortsignal-onabort>
|
||||
event_handler!(abort, GetOnabort, SetOnabort);
|
||||
}
|
|
@ -211,6 +211,7 @@ pub(crate) mod types {
|
|||
}
|
||||
|
||||
pub(crate) mod abortcontroller;
|
||||
pub(crate) mod abortsignal;
|
||||
#[allow(dead_code)]
|
||||
pub(crate) mod abstractrange;
|
||||
pub(crate) mod abstractworker;
|
||||
|
|
14
components/script_bindings/webidls/AbortSignal.webidl
Normal file
14
components/script_bindings/webidls/AbortSignal.webidl
Normal file
|
@ -0,0 +1,14 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// https://dom.spec.whatwg.org/#abortsignal
|
||||
|
||||
[Exposed=*, Pref="dom_abort_controller_enabled"]
|
||||
interface AbortSignal : EventTarget {
|
||||
readonly attribute boolean aborted;
|
||||
readonly attribute any reason;
|
||||
undefined throwIfAborted();
|
||||
|
||||
attribute EventHandler onabort;
|
||||
};
|
|
@ -1,5 +1,10 @@
|
|||
[abort-signal-any.any.worker.html]
|
||||
expected: ERROR
|
||||
[AbortSignal.any() works with an empty array of signals]
|
||||
expected: FAIL
|
||||
|
||||
|
||||
[abort-signal-any.any.html]
|
||||
expected: ERROR
|
||||
[AbortSignal.any() works with an empty array of signals]
|
||||
expected: FAIL
|
||||
|
|
198
tests/wpt/meta/streams/piping/abort.any.js.ini
vendored
198
tests/wpt/meta/streams/piping/abort.any.js.ini
vendored
|
@ -6,6 +6,105 @@
|
|||
|
||||
[abort.any.html]
|
||||
expected: ERROR
|
||||
[a signal argument 'null' should cause pipeTo() to reject]
|
||||
expected: FAIL
|
||||
|
||||
[a signal argument 'AbortSignal' should cause pipeTo() to reject]
|
||||
expected: FAIL
|
||||
|
||||
[a signal argument 'true' should cause pipeTo() to reject]
|
||||
expected: FAIL
|
||||
|
||||
[a signal argument '-1' should cause pipeTo() to reject]
|
||||
expected: FAIL
|
||||
|
||||
[a signal argument '[object AbortSignal\]' should cause pipeTo() to reject]
|
||||
expected: FAIL
|
||||
|
||||
[an aborted signal should cause the writable stream to reject with an AbortError]
|
||||
expected: FAIL
|
||||
|
||||
[(reason: 'null') all the error objects should be the same object]
|
||||
expected: FAIL
|
||||
|
||||
[(reason: 'undefined') all the error objects should be the same object]
|
||||
expected: FAIL
|
||||
|
||||
[(reason: 'error1: error1') all the error objects should be the same object]
|
||||
expected: FAIL
|
||||
|
||||
[preventCancel should prevent canceling the readable]
|
||||
expected: FAIL
|
||||
|
||||
[preventAbort should prevent aborting the readable]
|
||||
expected: FAIL
|
||||
|
||||
[preventCancel and preventAbort should prevent canceling the readable and aborting the readable]
|
||||
expected: FAIL
|
||||
|
||||
[(reason: 'null') abort should prevent further reads]
|
||||
expected: FAIL
|
||||
|
||||
[(reason: 'undefined') abort should prevent further reads]
|
||||
expected: FAIL
|
||||
|
||||
[(reason: 'error1: error1') abort should prevent further reads]
|
||||
expected: FAIL
|
||||
|
||||
[(reason: 'null') all pending writes should complete on abort]
|
||||
expected: FAIL
|
||||
|
||||
[(reason: 'undefined') all pending writes should complete on abort]
|
||||
expected: FAIL
|
||||
|
||||
[(reason: 'error1: error1') all pending writes should complete on abort]
|
||||
expected: FAIL
|
||||
|
||||
[(reason: 'null') underlyingSource.cancel() should called when abort, even with pending pull]
|
||||
expected: FAIL
|
||||
|
||||
[(reason: 'undefined') underlyingSource.cancel() should called when abort, even with pending pull]
|
||||
expected: FAIL
|
||||
|
||||
[(reason: 'error1: error1') underlyingSource.cancel() should called when abort, even with pending pull]
|
||||
expected: FAIL
|
||||
|
||||
[a rejection from underlyingSource.cancel() should be returned by pipeTo()]
|
||||
expected: FAIL
|
||||
|
||||
[a rejection from underlyingSink.abort() should be returned by pipeTo()]
|
||||
expected: FAIL
|
||||
|
||||
[a rejection from underlyingSink.abort() should be preferred to one from underlyingSource.cancel()]
|
||||
expected: FAIL
|
||||
|
||||
[abort signal takes priority over closed readable]
|
||||
expected: FAIL
|
||||
|
||||
[abort signal takes priority over errored readable]
|
||||
expected: FAIL
|
||||
|
||||
[abort signal takes priority over closed writable]
|
||||
expected: FAIL
|
||||
|
||||
[abort signal takes priority over errored writable]
|
||||
expected: FAIL
|
||||
|
||||
[abort should do nothing after the readable is closed]
|
||||
expected: FAIL
|
||||
|
||||
[abort should do nothing after the readable is errored]
|
||||
expected: FAIL
|
||||
|
||||
[abort should do nothing after the readable is errored, even with pending writes]
|
||||
expected: FAIL
|
||||
|
||||
[abort should do nothing after the writable is errored]
|
||||
expected: FAIL
|
||||
|
||||
[pipeTo on a teed readable byte stream should only be aborted when both branches are aborted]
|
||||
expected: FAIL
|
||||
|
||||
|
||||
[abort.any.shadowrealm-in-dedicatedworker.html]
|
||||
expected: ERROR
|
||||
|
@ -21,6 +120,105 @@
|
|||
|
||||
[abort.any.worker.html]
|
||||
expected: ERROR
|
||||
[a signal argument 'null' should cause pipeTo() to reject]
|
||||
expected: FAIL
|
||||
|
||||
[a signal argument 'AbortSignal' should cause pipeTo() to reject]
|
||||
expected: FAIL
|
||||
|
||||
[a signal argument 'true' should cause pipeTo() to reject]
|
||||
expected: FAIL
|
||||
|
||||
[a signal argument '-1' should cause pipeTo() to reject]
|
||||
expected: FAIL
|
||||
|
||||
[a signal argument '[object AbortSignal\]' should cause pipeTo() to reject]
|
||||
expected: FAIL
|
||||
|
||||
[an aborted signal should cause the writable stream to reject with an AbortError]
|
||||
expected: FAIL
|
||||
|
||||
[(reason: 'null') all the error objects should be the same object]
|
||||
expected: FAIL
|
||||
|
||||
[(reason: 'undefined') all the error objects should be the same object]
|
||||
expected: FAIL
|
||||
|
||||
[(reason: 'error1: error1') all the error objects should be the same object]
|
||||
expected: FAIL
|
||||
|
||||
[preventCancel should prevent canceling the readable]
|
||||
expected: FAIL
|
||||
|
||||
[preventAbort should prevent aborting the readable]
|
||||
expected: FAIL
|
||||
|
||||
[preventCancel and preventAbort should prevent canceling the readable and aborting the readable]
|
||||
expected: FAIL
|
||||
|
||||
[(reason: 'null') abort should prevent further reads]
|
||||
expected: FAIL
|
||||
|
||||
[(reason: 'undefined') abort should prevent further reads]
|
||||
expected: FAIL
|
||||
|
||||
[(reason: 'error1: error1') abort should prevent further reads]
|
||||
expected: FAIL
|
||||
|
||||
[(reason: 'null') all pending writes should complete on abort]
|
||||
expected: FAIL
|
||||
|
||||
[(reason: 'undefined') all pending writes should complete on abort]
|
||||
expected: FAIL
|
||||
|
||||
[(reason: 'error1: error1') all pending writes should complete on abort]
|
||||
expected: FAIL
|
||||
|
||||
[(reason: 'null') underlyingSource.cancel() should called when abort, even with pending pull]
|
||||
expected: FAIL
|
||||
|
||||
[(reason: 'undefined') underlyingSource.cancel() should called when abort, even with pending pull]
|
||||
expected: FAIL
|
||||
|
||||
[(reason: 'error1: error1') underlyingSource.cancel() should called when abort, even with pending pull]
|
||||
expected: FAIL
|
||||
|
||||
[a rejection from underlyingSource.cancel() should be returned by pipeTo()]
|
||||
expected: FAIL
|
||||
|
||||
[a rejection from underlyingSink.abort() should be returned by pipeTo()]
|
||||
expected: FAIL
|
||||
|
||||
[a rejection from underlyingSink.abort() should be preferred to one from underlyingSource.cancel()]
|
||||
expected: FAIL
|
||||
|
||||
[abort signal takes priority over closed readable]
|
||||
expected: FAIL
|
||||
|
||||
[abort signal takes priority over errored readable]
|
||||
expected: FAIL
|
||||
|
||||
[abort signal takes priority over closed writable]
|
||||
expected: FAIL
|
||||
|
||||
[abort signal takes priority over errored writable]
|
||||
expected: FAIL
|
||||
|
||||
[abort should do nothing after the readable is closed]
|
||||
expected: FAIL
|
||||
|
||||
[abort should do nothing after the readable is errored]
|
||||
expected: FAIL
|
||||
|
||||
[abort should do nothing after the readable is errored, even with pending writes]
|
||||
expected: FAIL
|
||||
|
||||
[abort should do nothing after the writable is errored]
|
||||
expected: FAIL
|
||||
|
||||
[pipeTo on a teed readable byte stream should only be aborted when both branches are aborted]
|
||||
expected: FAIL
|
||||
|
||||
|
||||
[abort.https.any.shadowrealm-in-audioworklet.html]
|
||||
expected: ERROR
|
||||
|
|
|
@ -6,6 +6,27 @@
|
|||
|
||||
[pipe-through.any.worker.html]
|
||||
expected: ERROR
|
||||
[pipeThrough should accept a real AbortSignal]
|
||||
expected: FAIL
|
||||
|
||||
[invalid values of signal should throw; specifically 'null']
|
||||
expected: FAIL
|
||||
|
||||
[invalid values of signal should throw; specifically '0']
|
||||
expected: FAIL
|
||||
|
||||
[invalid values of signal should throw; specifically 'NaN']
|
||||
expected: FAIL
|
||||
|
||||
[invalid values of signal should throw; specifically 'true']
|
||||
expected: FAIL
|
||||
|
||||
[invalid values of signal should throw; specifically 'AbortSignal']
|
||||
expected: FAIL
|
||||
|
||||
[invalid values of signal should throw; specifically '[object AbortSignal\]']
|
||||
expected: FAIL
|
||||
|
||||
|
||||
[pipe-through.any.sharedworker.html]
|
||||
expected: ERROR
|
||||
|
@ -27,3 +48,23 @@
|
|||
|
||||
[pipe-through.any.html]
|
||||
expected: ERROR
|
||||
[pipeThrough should accept a real AbortSignal]
|
||||
expected: FAIL
|
||||
|
||||
[invalid values of signal should throw; specifically 'null']
|
||||
expected: FAIL
|
||||
|
||||
[invalid values of signal should throw; specifically '0']
|
||||
expected: FAIL
|
||||
|
||||
[invalid values of signal should throw; specifically 'NaN']
|
||||
expected: FAIL
|
||||
|
||||
[invalid values of signal should throw; specifically 'true']
|
||||
expected: FAIL
|
||||
|
||||
[invalid values of signal should throw; specifically 'AbortSignal']
|
||||
expected: FAIL
|
||||
|
||||
[invalid values of signal should throw; specifically '[object AbortSignal\]']
|
||||
expected: FAIL
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue