Bug 1181056 - waitUntil() should throw if called when event is not dispatching. r=smaug

--HG--
extra : commitid : 5Caz3xiFQQe
extra : rebase_source : ef708cda07cbaf897ec3201e19defcf02d85e06f
This commit is contained in:
Nikhil Marathe 2015-08-18 16:28:04 -07:00
parent fe51723b9e
commit 0756a03abe
4 changed files with 8 additions and 7 deletions

View File

@ -11,6 +11,7 @@
Exposed=ServiceWorker]
interface ExtendableEvent : Event {
// https://github.com/slightlyoff/ServiceWorker/issues/261
[Throws]
void waitUntil(Promise<any> p);
};

View File

@ -395,10 +395,15 @@ ExtendableEvent::ExtendableEvent(EventTarget* aOwner)
}
void
ExtendableEvent::WaitUntil(Promise& aPromise)
ExtendableEvent::WaitUntil(Promise& aPromise, ErrorResult& aRv)
{
MOZ_ASSERT(!NS_IsMainThread());
if (EventPhase() == nsIDOMEvent::NONE) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}
// Only first caller counts.
if (EventPhase() == AT_TARGET && !mPromise) {
mPromise = &aPromise;

View File

@ -141,7 +141,7 @@ public:
}
void
WaitUntil(Promise& aPromise);
WaitUntil(Promise& aPromise, ErrorResult& aRv);
already_AddRefed<Promise>
GetPromise() const

View File

@ -1,5 +0,0 @@
[extendable-event-async-waituntil.https.html]
type: testharness
[Calling waitUntil asynchronously throws an exception]
expected: FAIL