mirror of
https://github.com/servo/servo.git
synced 2025-07-25 16:20:36 +01:00
Dom: Implement AbortSignal ThrowIfAborted method (#37245)
Implement the ThrowIfAborted method of AbortSignal; part of https://github.com/servo/servo/issues/36935. Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
This commit is contained in:
parent
39ee27eea6
commit
aff38cdbd0
1 changed files with 12 additions and 2 deletions
|
@ -6,7 +6,7 @@ use std::cell::RefCell;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use js::jsapi::Heap;
|
use js::jsapi::{ExceptionStackBehavior, Heap, JS_SetPendingException};
|
||||||
use js::jsval::{JSVal, UndefinedValue};
|
use js::jsval::{JSVal, UndefinedValue};
|
||||||
use js::rust::{HandleObject, HandleValue, MutableHandleValue};
|
use js::rust::{HandleObject, HandleValue, MutableHandleValue};
|
||||||
use script_bindings::inheritance::Castable;
|
use script_bindings::inheritance::Castable;
|
||||||
|
@ -139,7 +139,17 @@ impl AbortSignalMethods<crate::DomTypeHolder> for AbortSignal {
|
||||||
/// <https://dom.spec.whatwg.org/#dom-abortsignal-throwifaborted>
|
/// <https://dom.spec.whatwg.org/#dom-abortsignal-throwifaborted>
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
fn ThrowIfAborted(&self) {
|
fn ThrowIfAborted(&self) {
|
||||||
// TODO
|
// The throwIfAborted() method steps are to throw this’s abort reason, if this is aborted.
|
||||||
|
if self.aborted() {
|
||||||
|
let cx = GlobalScope::get_cx();
|
||||||
|
unsafe {
|
||||||
|
JS_SetPendingException(
|
||||||
|
*cx,
|
||||||
|
self.abort_reason.handle(),
|
||||||
|
ExceptionStackBehavior::Capture,
|
||||||
|
)
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// <https://dom.spec.whatwg.org/#dom-abortsignal-onabort>
|
// <https://dom.spec.whatwg.org/#dom-abortsignal-onabort>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue