diff --git a/dom/abort/event.any.js b/dom/abort/event.any.js new file mode 100644 index 00000000000000..3b25702c2e4c77 --- /dev/null +++ b/dom/abort/event.any.js @@ -0,0 +1,22 @@ +test(t => { + const c = new AbortController(), + s = c.signal; + let state = "begin"; + + assert_false(s.aborted); + + s.addEventListener("abort", + t.step_func(e => { + assert_equals(state, "begin"); + state = "aborted"; + }) + ); + c.abort(); + + assert_equals(state, "aborted"); + assert_true(s.aborted); + + c.abort(); +}, "AbortController() basics"); + +done(); diff --git a/dom/interface-objects.html b/dom/interface-objects.html index df4ca51e47777a..936d63517eada5 100644 --- a/dom/interface-objects.html +++ b/dom/interface-objects.html @@ -15,6 +15,8 @@ "Event", "CustomEvent", "EventTarget", + "AbortController", + "AbortSignal", "Node", "Document", "DOMImplementation", diff --git a/dom/interfaces.html b/dom/interfaces.html index 8b4140d645ca7e..8e9572d0f09ca2 100644 --- a/dom/interfaces.html +++ b/dom/interfaces.html @@ -24,6 +24,8 @@

DOM IDL tests

EventTarget: ['new EventTarget()'], Event: ['document.createEvent("Event")', 'new Event("foo")'], CustomEvent: ['new CustomEvent("foo")'], + AbortController: ['new AbortController()'], + AbortSignal: ['new AbortController().signal'], Document: ['new Document()'], XMLDocument: ['xmlDoc'], DOMImplementation: ['document.implementation'], diff --git a/interfaces/dom.idl b/interfaces/dom.idl index 9ca270ea1c4d3e..e6915761871a9b 100644 --- a/interfaces/dom.idl +++ b/interfaces/dom.idl @@ -61,6 +61,23 @@ dictionary EventListenerOptions { }; +[Constructor, + Exposed=(Window,Worker)] +interface AbortController { + [SameObject] readonly attribute AbortSignal signal; + + void abort(); +}; + + +[Exposed=(Window,Worker)] +interface AbortSignal : EventTarget { + readonly attribute boolean aborted; + + attribute EventHandler onabort; +}; + + [NoInterfaceObject, Exposed=Window] interface NonElementParentNode {