aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/script/dom/abortsignal.rs71
-rw-r--r--components/script/dom/mod.rs1
-rw-r--r--components/script_bindings/webidls/AbortSignal.webidl14
-rw-r--r--tests/wpt/meta/dom/abort/abort-signal-any.any.js.ini5
-rw-r--r--tests/wpt/meta/streams/piping/abort.any.js.ini198
-rw-r--r--tests/wpt/meta/streams/piping/pipe-through.any.js.ini41
6 files changed, 330 insertions, 0 deletions
diff --git a/components/script/dom/abortsignal.rs b/components/script/dom/abortsignal.rs
new file mode 100644
index 00000000000..57c6e9cd67e
--- /dev/null
+++ b/components/script/dom/abortsignal.rs
@@ -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);
+}
diff --git a/components/script/dom/mod.rs b/components/script/dom/mod.rs
index 388d8cfde2a..5d7f1966207 100644
--- a/components/script/dom/mod.rs
+++ b/components/script/dom/mod.rs
@@ -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;
diff --git a/components/script_bindings/webidls/AbortSignal.webidl b/components/script_bindings/webidls/AbortSignal.webidl
new file mode 100644
index 00000000000..1ec9fbcd3a4
--- /dev/null
+++ b/components/script_bindings/webidls/AbortSignal.webidl
@@ -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;
+};
diff --git a/tests/wpt/meta/dom/abort/abort-signal-any.any.js.ini b/tests/wpt/meta/dom/abort/abort-signal-any.any.js.ini
index f1013fd736d..8164c20ef3c 100644
--- a/tests/wpt/meta/dom/abort/abort-signal-any.any.js.ini
+++ b/tests/wpt/meta/dom/abort/abort-signal-any.any.js.ini
@@ -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
diff --git a/tests/wpt/meta/streams/piping/abort.any.js.ini b/tests/wpt/meta/streams/piping/abort.any.js.ini
index 703ed108ffb..3d3e8a59942 100644
--- a/tests/wpt/meta/streams/piping/abort.any.js.ini
+++ b/tests/wpt/meta/streams/piping/abort.any.js.ini
@@ -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
diff --git a/tests/wpt/meta/streams/piping/pipe-through.any.js.ini b/tests/wpt/meta/streams/piping/pipe-through.any.js.ini
index 1828ea894f4..77cd1734611 100644
--- a/tests/wpt/meta/streams/piping/pipe-through.any.js.ini
+++ b/tests/wpt/meta/streams/piping/pipe-through.any.js.ini
@@ -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