script: Add stub interface for AbortController. (#34519)

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Co-authored-by: syvb <me@iter.ca>
This commit is contained in:
Josh Matthews 2024-12-10 02:31:04 -05:00 committed by GitHub
parent 2f64dde623
commit bc2def0582
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 72 additions and 0 deletions

View file

@ -247,6 +247,10 @@ mod gen {
enabled: bool,
}
},
abort_controller: {
/// Whether to expose the AbortControll/AbortSignal DOM interfaces.
enabled: bool,
},
allow_scripts_to_close_windows: bool,
canvas_capture: {
enabled: bool,

View file

@ -0,0 +1,53 @@
/* 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::Value;
use js::rust::{Handle, HandleObject};
use crate::dom::bindings::codegen::Bindings::AbortControllerBinding::AbortControllerMethods;
use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, Reflector};
use crate::dom::bindings::root::DomRoot;
use crate::dom::globalscope::GlobalScope;
use crate::script_runtime::{CanGc, JSContext};
#[dom_struct]
pub struct AbortController {
reflector_: Reflector,
}
impl AbortController {
fn new_inherited() -> AbortController {
AbortController {
reflector_: Reflector::new(),
}
}
fn new_with_proto(
global: &GlobalScope,
proto: Option<HandleObject>,
can_gc: CanGc,
) -> DomRoot<AbortController> {
reflect_dom_object_with_proto(
Box::new(AbortController::new_inherited()),
global,
proto,
can_gc,
)
}
}
impl AbortControllerMethods<crate::DomTypeHolder> for AbortController {
/// <https://dom.spec.whatwg.org/#dom-abortcontroller-abortcontroller>
fn Constructor(
global: &GlobalScope,
proto: Option<HandleObject>,
can_gc: CanGc,
) -> DomRoot<AbortController> {
AbortController::new_with_proto(global, proto, can_gc)
}
/// <https://dom.spec.whatwg.org/#dom-abortcontroller-abort>
fn Abort(&self, _cx: JSContext, _reason: Handle<'_, Value>) {}
}

View file

@ -209,6 +209,7 @@ pub mod types {
include!(concat!(env!("OUT_DIR"), "/InterfaceTypes.rs"));
}
pub mod abortcontroller;
pub mod abstractrange;
pub mod abstractworker;
pub mod abstractworkerglobalscope;

View file

@ -0,0 +1,13 @@
/* 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/#interface-abortcontroller
[Exposed=*, Pref="dom.abort_controller.enabled"]
interface AbortController {
constructor();
//[SameObject] readonly attribute AbortSignal signal;
undefined abort(optional any reason);
};

View file

@ -1,6 +1,7 @@
{
"devtools.server.enabled": false,
"devtools.server.port": 0,
"dom.abort_controller.enabled": false,
"dom.allow_scripts_to_close_windows": false,
"dom.bluetooth.enabled": false,
"dom.bluetooth.testing.enabled": false,