From ac53f535f2d744063d232d32f080a37659314f05 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Wed, 7 Oct 2015 17:01:28 -0400 Subject: [PATCH] Bug 1179397 - Disallow FetchEvent.respondWith() when the dispatch flag is unset; r=jdm --- dom/workers/ServiceWorkerEvents.cpp | 2 +- .../fetch-event-async-respond-with.https.html.ini | 5 ----- .../service-worker/fetch-event-async-respond-with.https.html | 2 +- 3 files changed, 2 insertions(+), 7 deletions(-) delete mode 100644 testing/web-platform/mozilla/meta/service-workers/service-worker/fetch-event-async-respond-with.https.html.ini diff --git a/dom/workers/ServiceWorkerEvents.cpp b/dom/workers/ServiceWorkerEvents.cpp index 9c4638650e85..b4eb020cfdb0 100644 --- a/dom/workers/ServiceWorkerEvents.cpp +++ b/dom/workers/ServiceWorkerEvents.cpp @@ -412,7 +412,7 @@ RespondWithHandler::CancelRequest(nsresult aStatus) void FetchEvent::RespondWith(Promise& aArg, ErrorResult& aRv) { - if (mWaitToRespond) { + if (EventPhase() == nsIDOMEvent::NONE || mWaitToRespond) { aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); return; } diff --git a/testing/web-platform/mozilla/meta/service-workers/service-worker/fetch-event-async-respond-with.https.html.ini b/testing/web-platform/mozilla/meta/service-workers/service-worker/fetch-event-async-respond-with.https.html.ini deleted file mode 100644 index 32689d1a489a..000000000000 --- a/testing/web-platform/mozilla/meta/service-workers/service-worker/fetch-event-async-respond-with.https.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[fetch-event-async-respond-with.https.html] - type: testharness - [Calling respondWith asynchronously throws an exception] - expected: FAIL - diff --git a/testing/web-platform/mozilla/tests/service-workers/service-worker/fetch-event-async-respond-with.https.html b/testing/web-platform/mozilla/tests/service-workers/service-worker/fetch-event-async-respond-with.https.html index 5c908b3d94fd..912e709ca38f 100644 --- a/testing/web-platform/mozilla/tests/service-workers/service-worker/fetch-event-async-respond-with.https.html +++ b/testing/web-platform/mozilla/tests/service-workers/service-worker/fetch-event-async-respond-with.https.html @@ -22,8 +22,8 @@ promise_test(function(t) { }); var worker = frame.contentWindow.navigator.serviceWorker.controller; - frame.remove(); worker.postMessage({port: channel.port2}, [channel.port2]); + frame.remove(); return saw_message; }) .then(function(message) {