Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOM: AbortController and AbortSignal #5960

Merged
merged 5 commits into from
Jul 14, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions dom/abort/event.any.js
Original file line number Diff line number Diff line change
@@ -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();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another good test (optional) would be that aborting twice does not fire the event twice.

2 changes: 2 additions & 0 deletions dom/interface-objects.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"Event",
"CustomEvent",
"EventTarget",
"AbortController",
"AbortSignal",
"Node",
"Document",
"DOMImplementation",
Expand Down
2 changes: 2 additions & 0 deletions dom/interfaces.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ <h1>DOM IDL tests</h1>
idlArray.add_objects({
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'],
Expand Down
19 changes: 18 additions & 1 deletion interfaces/dom.idl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ dictionary CustomEventInit : EventInit {
};


//[Exposed=(Window,Worker)]
[Exposed=(Window,Worker)]
interface EventTarget {
void addEventListener(DOMString type, EventListener? callback, optional (EventListenerOptions or boolean) options);
void removeEventListener(DOMString type, EventListener? callback, optional (EventListenerOptions or boolean) options);
Expand All @@ -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 {
Expand Down