зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1698468 - Add AbortSignal.abort() r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D108503
This commit is contained in:
Родитель
fa8747857b
Коммит
a9e13dca62
|
@ -84,6 +84,12 @@ JSObject* AbortSignal::WrapObject(JSContext* aCx,
|
||||||
return AbortSignal_Binding::Wrap(aCx, this, aGivenProto);
|
return AbortSignal_Binding::Wrap(aCx, this, aGivenProto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
already_AddRefed<AbortSignal> AbortSignal::Abort(GlobalObject& aGlobal) {
|
||||||
|
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports());
|
||||||
|
RefPtr<AbortSignal> abortSignal = new AbortSignal(global, true);
|
||||||
|
return abortSignal.forget();
|
||||||
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#abortsignal-signal-abort
|
// https://dom.spec.whatwg.org/#abortsignal-signal-abort
|
||||||
void AbortSignal::SignalAbort() {
|
void AbortSignal::SignalAbort() {
|
||||||
// Steps 1-4.
|
// Steps 1-4.
|
||||||
|
|
|
@ -39,6 +39,8 @@ class AbortSignal final : public DOMEventTargetHelper,
|
||||||
|
|
||||||
IMPL_EVENT_HANDLER(abort);
|
IMPL_EVENT_HANDLER(abort);
|
||||||
|
|
||||||
|
static already_AddRefed<AbortSignal> Abort(GlobalObject& aGlobal);
|
||||||
|
|
||||||
// AbortSignalImpl
|
// AbortSignalImpl
|
||||||
void SignalAbort() override;
|
void SignalAbort() override;
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
[Exposed=(Window,Worker)]
|
[Exposed=(Window,Worker)]
|
||||||
interface AbortSignal : EventTarget {
|
interface AbortSignal : EventTarget {
|
||||||
|
[NewObject] static AbortSignal abort();
|
||||||
|
|
||||||
readonly attribute boolean aborted;
|
readonly attribute boolean aborted;
|
||||||
|
|
||||||
attribute EventHandler onabort;
|
attribute EventHandler onabort;
|
||||||
|
|
|
@ -64,4 +64,9 @@ test(t => {
|
||||||
controller.abort();
|
controller.abort();
|
||||||
}, "the abort event should have the right properties");
|
}, "the abort event should have the right properties");
|
||||||
|
|
||||||
|
test(t => {
|
||||||
|
const signal = AbortSignal.abort();
|
||||||
|
assert_true(signal.aborted);
|
||||||
|
}, "the AbortSignal.abort() static returns an already aborted signal");
|
||||||
|
|
||||||
done();
|
done();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче