Diff
Modified: branches/safari-605-branch/LayoutTests/ChangeLog (226681 => 226682)
--- branches/safari-605-branch/LayoutTests/ChangeLog 2018-01-10 04:31:14 UTC (rev 226681)
+++ branches/safari-605-branch/LayoutTests/ChangeLog 2018-01-10 04:31:18 UTC (rev 226682)
@@ -1,5 +1,21 @@
2018-01-09 Jason Marcell <[email protected]>
+ Cherry-pick r226526. rdar://problem/36392384
+
+ 2018-01-08 Youenn Fablet <[email protected]>
+
+ Stop exposing fetch and extendable events to window
+ https://bugs.webkit.org/show_bug.cgi?id=181325
+
+ Reviewed by Chris Dumez.
+
+ * http/wpt/service-workers/extendableEvent.https-expected.txt:
+ * http/wpt/service-workers/extendableEvent.https.html:
+ * http/wpt/service-workers/fetchEvent.https-expected.txt:
+ * http/wpt/service-workers/fetchEvent.https.html:
+
+2018-01-09 Jason Marcell <[email protected]>
+
Cherry-pick r226521. rdar://problem/36392339
2018-01-08 Antti Koivisto <[email protected]>
Added: branches/safari-605-branch/LayoutTests/http/wpt/service-workers/extendableEvent-worker.js (0 => 226682)
--- branches/safari-605-branch/LayoutTests/http/wpt/service-workers/extendableEvent-worker.js (rev 0)
+++ branches/safari-605-branch/LayoutTests/http/wpt/service-workers/extendableEvent-worker.js 2018-01-10 04:31:18 UTC (rev 226682)
@@ -0,0 +1,42 @@
+function testWaitUntilNonPromiseParameters()
+{
+ var event = new ExtendableEvent('ExtendableEvent', {});
+ try {
+ event.waitUntil(new Request(''));
+ return 'Should throw';
+ } catch (e) {
+ return e.name === 'InvalidStateError' ? 'PASS' : 'Got exception ' + e;
+ }
+}
+
+function testExtendableEvent()
+{
+ if (new ExtendableEvent('ExtendableEvent').type !== 'ExtendableEvent')
+ return 'Type of ExtendableEvent should be ExtendableEvent';
+ if (new ExtendableEvent('ExtendableEvent', {}).type !== 'ExtendableEvent')
+ return 'Type of ExtendableEvent should be ExtendableEvent';
+ if (new ExtendableEvent('ExtendableEvent', {}).cancelable !== false)
+ return 'Default ExtendableEvent.cancelable should be false';
+ if (new ExtendableEvent('ExtendableEvent', {}).bubbles !== false)
+ return 'Default ExtendableEvent.bubbles should be false';
+ if (new ExtendableEvent('ExtendableEvent', {cancelable: false}).cancelable !== false)
+ return 'ExtendableEvent.cancelable should be false';
+ return "PASS";
+}
+
+async function doTest(event)
+{
+ try {
+ var result = event.data + " is an unknown test";
+ if (event.data ="" "waitUntil-non-promise-parameters")
+ result = testWaitUntilNonPromiseParameters();
+ else if (event.data ="" "extendable-event")
+ result = testExtendableEvent();
+
+ event.source.postMessage(result);
+ } catch (e) {
+ event.source.postMessage("Exception: " + e.message);
+ }
+}
+
+self.addEventListener("message", doTest);
Modified: branches/safari-605-branch/LayoutTests/http/wpt/service-workers/extendableEvent.https-expected.txt (226681 => 226682)
--- branches/safari-605-branch/LayoutTests/http/wpt/service-workers/extendableEvent.https-expected.txt 2018-01-10 04:31:14 UTC (rev 226681)
+++ branches/safari-605-branch/LayoutTests/http/wpt/service-workers/extendableEvent.https-expected.txt 2018-01-10 04:31:18 UTC (rev 226682)
@@ -1,4 +1,5 @@
+PASS Setup worker
PASS ExtendableEvent waitUntil should support non promise parameters
PASS Event constructors
Modified: branches/safari-605-branch/LayoutTests/http/wpt/service-workers/extendableEvent.https.html (226681 => 226682)
--- branches/safari-605-branch/LayoutTests/http/wpt/service-workers/extendableEvent.https.html 2018-01-10 04:31:14 UTC (rev 226681)
+++ branches/safari-605-branch/LayoutTests/http/wpt/service-workers/extendableEvent.https.html 2018-01-10 04:31:18 UTC (rev 226682)
@@ -1,31 +1,48 @@
-<!DOCTYPE html>
+<html>
+<head>
<title>Service Worker Extendable Event</title>
<script src=""
<script src=""
+</head>
+<body>
<script>
-// FIXME: Should be run on a service worker.
-test(() => {
- if (!window.internals)
- return Promise.reject("test require internals");
- var event = new ExtendableEvent('ExtendableEvent', {});
- assert_throws('InvalidStateError', () => event.waitUntil(new Request('')));
-}, "ExtendableEvent waitUntil should support non promise parameters");
+var scope = "";
+var activeWorker;
-test(function() {
- assert_equals(
- new ExtendableEvent('ExtendableEvent').type,
- 'ExtendableEvent', 'Type of ExtendableEvent should be ExtendableEvent');
- assert_equals(
- new ExtendableEvent('ExtendableEvent', {}).type,
- 'ExtendableEvent', 'Type of ExtendableEvent should be ExtendableEvent');
- assert_equals(
- new ExtendableEvent('ExtendableEvent', {}).cancelable,
- false, 'Default ExtendableEvent.cancelable should be false');
- assert_equals(
- new ExtendableEvent('ExtendableEvent', {}).bubbles,
- false, 'Default ExtendableEvent.bubbles should be false');
- assert_equals(
- new ExtendableEvent('ExtendableEvent', {cancelable: false}).cancelable,
- false, 'ExtendableEvent.cancelable should be false');
- }, 'Event constructors');
+promise_test(async (test) => {
+ var registration = await navigator.serviceWorker.register("extendableEvent-worker.js", { scope : scope });
+ activeWorker = registration.active;
+ if (activeWorker)
+ return;
+ activeWorker = registration.installing;
+ return new Promise(resolve => {
+ activeWorker.addEventListener('statechange', () => {
+ if (activeWorker.state === "activated")
+ resolve();
+ });
+ });
+}, "Setup worker");
+
+function doTest(name, title)
+{
+ promise_test(async (test) => {
+ var promise = new Promise((resolve, reject) => {
+ navigator.serviceWorker.addEventListener("message", (event) => {
+ resolve(event.data);
+ });
+ setTimeout(() => reject("No response message from service worker"), 5000);
+ });
+
+ activeWorker.postMessage(name);
+ var result = await promise;
+
+ assert_equals(result, "PASS");
+ }, title);
+}
+
+doTest("waitUntil-non-promise-parameters", "ExtendableEvent waitUntil should support non promise parameters");
+doTest("extendable-event", "Event constructors");
+
</script>
+</body>
+</html>
Added: branches/safari-605-branch/LayoutTests/http/wpt/service-workers/fetchEvent-worker.js (0 => 226682)
--- branches/safari-605-branch/LayoutTests/http/wpt/service-workers/fetchEvent-worker.js (rev 0)
+++ branches/safari-605-branch/LayoutTests/http/wpt/service-workers/fetchEvent-worker.js 2018-01-10 04:31:18 UTC (rev 226682)
@@ -0,0 +1,113 @@
+function testRespondTwice()
+{
+ var event = self.internals.createBeingDispatchedFetchEvent();
+ event.respondWith(undefined);
+ try {
+ event.respondWith(undefined);
+ return 'Should throw';
+ } catch (e) {
+ return e.name === 'InvalidStateError' ? 'PASS' : 'Got exception ' + e;
+ }
+}
+
+function gc()
+{
+ // FIXME: Add gc in WTR
+ function gcRec(n) {
+ if (n < 1)
+ return {};
+ var temp = {i: "ab" + i + (i / 100000)};
+ temp += "foo";
+ gcRec(n-1);
+ }
+ for (var i = 0; i < 10000; i++)
+ gcRec(10);
+}
+
+function testRequestSameObject()
+{
+ var event = new FetchEvent('FetchEvent', { request : new Request('test') });
+ event.request.value = 1;
+ gc();
+ return event.request.value === 1 ? "PASS" : "FAIL";
+}
+
+async function promise_rejects(promise)
+{
+ return promise.then(() => {
+ return "FAIL";
+ }, (e) => {
+ return e.name === 'TypeError' ? 'PASS' : 'Got error ' + e;
+ })
+}
+
+async function testRespondUndefined()
+{
+ var event = internals.createBeingDispatchedFetchEvent();
+ var promise = internals.waitForFetchEventToFinish(event);
+ event.respondWith(undefined);
+ return await promise_rejects(promise);
+}
+
+async function testRespondNotResponse()
+{
+ var event = internals.createBeingDispatchedFetchEvent();
+ var promise = internals.waitForFetchEventToFinish(event);
+ event.respondWith(new Request(''));
+ return await promise_rejects(promise);
+}
+
+async function testRespondPromiseNotResponse()
+{
+ var event = internals.createBeingDispatchedFetchEvent();
+ var promise = internals.waitForFetchEventToFinish(event);
+ event.respondWith(new Promise((resolve, reject) => {
+ resolve(new Request(''));
+ }));
+ return await promise_rejects(promise);
+}
+
+async function testRespondPromiseReject()
+{
+ var event = internals.createBeingDispatchedFetchEvent();
+ var promise = internals.waitForFetchEventToFinish(event);
+ event.respondWith(new Promise((resolve, reject) => {
+ reject('not good');
+ }));
+ return await promise_rejects(promise);
+}
+
+async function testRespondPromiseResponse()
+{
+ var event = internals.createBeingDispatchedFetchEvent();
+ var response = new Response;
+ event.respondWith(response);
+ return (response === await internals.waitForFetchEventToFinish(event)) ? "PASS" : "FAIL";
+}
+
+async function doTest(event)
+{
+ try {
+ var result = event.data + " is an unknown test";
+ if (event.data ="" "respond-twice")
+ result = testRespondTwice();
+ else if (event.data ="" "request-sameobject")
+ result = testRequestSameObject();
+ else if (event.data ="" "respond-undefined")
+ result = await testRespondUndefined();
+ else if (event.data ="" "respond-not-response")
+ result = await testRespondNotResponse();
+ else if (event.data ="" "respond-promise-not-response")
+ result = await testRespondPromiseNotResponse();
+ else if (event.data ="" "respond-promise-reject")
+ result = await testRespondPromiseReject();
+ else if (event.data ="" "respond-promise-response")
+ result = await testRespondPromiseResponse();
+
+ event.source.postMessage(result);
+ } catch (e) {
+ event.source.postMessage("Exception: " + e.message);
+ }
+}
+
+self.addEventListener("message", doTest);
Modified: branches/safari-605-branch/LayoutTests/http/wpt/service-workers/fetchEvent.https-expected.txt (226681 => 226682)
--- branches/safari-605-branch/LayoutTests/http/wpt/service-workers/fetchEvent.https-expected.txt 2018-01-10 04:31:14 UTC (rev 226681)
+++ branches/safari-605-branch/LayoutTests/http/wpt/service-workers/fetchEvent.https-expected.txt 2018-01-10 04:31:18 UTC (rev 226682)
@@ -1,4 +1,5 @@
+PASS Setup worker
PASS FetchEvent respondWith should throw if called twice
PASS FetchEvent request is SameObject
PASS FetchEvent should be in error if responding with undefined
@@ -6,5 +7,4 @@
PASS FetchEvent should be in error if responding with a Promise that does not resolve to a Response
PASS FetchEvent should be in error if responding with a Promise that rejects
PASS FetchEvent should resolve when responding with a Response
-PASS Event constructors
Modified: branches/safari-605-branch/LayoutTests/http/wpt/service-workers/fetchEvent.https.html (226681 => 226682)
--- branches/safari-605-branch/LayoutTests/http/wpt/service-workers/fetchEvent.https.html 2018-01-10 04:31:14 UTC (rev 226681)
+++ branches/safari-605-branch/LayoutTests/http/wpt/service-workers/fetchEvent.https.html 2018-01-10 04:31:18 UTC (rev 226682)
@@ -1,107 +1,53 @@
-<!DOCTYPE html>
+<html>
+<head>
<title>Service Worker Fetch Event</title>
<script src=""
<script src=""
-<script src=""
+</head>
+<body>
<script>
-// FIXME: Should be run on a service worker.
-test(() => {
- var event = internals.createBeingDispatchedFetchEvent();
- event.respondWith(undefined);
- assert_throws('InvalidStateError', () => event.respondWith(undefined));
-}, "FetchEvent respondWith should throw if called twice");
+var scope = "";
+var activeWorker;
-test(() => {
- var event = new FetchEvent('FetchEvent', { request : new Request('test') });
- event.request.value = 1;
- gc();
- assert_equals(event.request.value, 1);
-}, "FetchEvent request is SameObject");
+promise_test(async (test) => {
+ var registration = await navigator.serviceWorker.register("fetchEvent-worker.js", { scope : scope });
+ activeWorker = registration.active;
+ if (activeWorker)
+ return;
+ activeWorker = registration.installing;
+ return new Promise(resolve => {
+ activeWorker.addEventListener('statechange', () => {
+ if (activeWorker.state === "activated")
+ resolve();
+ });
+ });
+}, "Setup worker");
-promise_test(async t => {
- if (!window.internals)
- return Promise.reject("test require internals");
- var event = internals.createBeingDispatchedFetchEvent();
- var promise = internals.waitForFetchEventToFinish(event);
- event.respondWith(undefined);
- return promise_rejects(t, new TypeError, promise);
-}, "FetchEvent should be in error if responding with undefined");
+function doTest(name, title)
+{
+ promise_test(async (test) => {
+ var promise = new Promise((resolve, reject) => {
+ navigator.serviceWorker.addEventListener("message", (event) => {
+ resolve(event.data);
+ });
+ setTimeout(() => reject("No response message from service worker"), 5000);
+ });
-promise_test(async t => {
- if (!window.internals)
- return Promise.reject("test require internals");
- var event = internals.createBeingDispatchedFetchEvent();
- var promise = internals.waitForFetchEventToFinish(event);
- event.respondWith(new Request(''));
- return promise_rejects(t, new TypeError, promise);
-}, "FetchEvent should be in error if not responding with a Response");
+ activeWorker.postMessage(name);
+ var result = await promise;
-promise_test(async t => {
- if (!window.internals)
- return Promise.reject("test require internals");
- var event = internals.createBeingDispatchedFetchEvent();
- var promise = internals.waitForFetchEventToFinish(event);
- event.respondWith(new Promise((resolve, reject) => {
- resolve(new Request(''));
- }));
- return promise_rejects(t, new TypeError, promise);
-}, "FetchEvent should be in error if responding with a Promise that does not resolve to a Response");
+ assert_equals(result, "PASS");
+ }, title);
+}
-promise_test(async t => {
- if (!window.internals)
- return Promise.reject("test require internals");
- var event = internals.createBeingDispatchedFetchEvent();
- var promise = internals.waitForFetchEventToFinish(event);
- event.respondWith(new Promise((resolve, reject) => {
- reject('not good');
- }));
- return promise_rejects(t, new TypeError, promise);
-}, "FetchEvent should be in error if responding with a Promise that rejects");
+doTest("respond-twice", "FetchEvent respondWith should throw if called twice");
+doTest("request-sameobject", "FetchEvent request is SameObject");
+doTest("respond-undefined", "FetchEvent should be in error if responding with undefined");
+doTest("respond-not-response", "FetchEvent should be in error if not responding with a Response");
+doTest("respond-promise-not-response", "FetchEvent should be in error if responding with a Promise that does not resolve to a Response");
+doTest("respond-promise-reject", "FetchEvent should be in error if responding with a Promise that rejects");
+doTest("respond-promise-response", "FetchEvent should resolve when responding with a Response");
-promise_test(async t => {
- if (!window.internals)
- return Promise.reject("test require internals");
- var event = internals.createBeingDispatchedFetchEvent();
- var response = new Response;
- event.respondWith(response);
- assert_true(response === await internals.waitForFetchEventToFinish(event));
-}, "FetchEvent should resolve when responding with a Response");
-
-// Duplicate test from WPT. To be removed once WPT service worker tests are active.
-test(function() {
- var req = new Request('http://localhost:8800/',
- {method: 'POST',
- headers: [['Content-Type', 'Text/Html']]});
- assert_equals(
- new ExtendableEvent('ExtendableEvent').type,
- 'ExtendableEvent', 'Type of ExtendableEvent should be ExtendableEvent');
- assert_throws(new TypeError, function() {
- new FetchEvent('FetchEvent');
- }, 'FetchEvent constructor with one argument throws');
- assert_throws(new TypeError, function() {
- new FetchEvent('FetchEvent', {});
- }, 'FetchEvent constructor with empty init dict throws');
- assert_throws(new TypeError, function() {
- new FetchEvent('FetchEvent', {request: null});
- }, 'FetchEvent constructor with null request member throws');
- assert_equals(
- new FetchEvent('FetchEvent', {request: req}).type,
- 'FetchEvent', 'Type of FetchEvent should be FetchEvent');
- assert_equals(
- new FetchEvent('FetchEvent', {request: req}).cancelable,
- false, 'Default FetchEvent.cancelable should be false');
- assert_equals(
- new FetchEvent('FetchEvent', {request: req}).bubbles,
- false, 'Default FetchEvent.bubbles should be false');
- assert_equals(
- new FetchEvent('FetchEvent', {request: req, cancelable: false}).cancelable,
- false, 'FetchEvent.cancelable should be false');
- assert_equals(
- new FetchEvent('FetchEvent', {request: req, clientId : 'test-client-id'}).clientId, 'test-client-id',
- 'FetchEvent.clientId with option {clientId : "test-client-id"} should be "test-client-id"');
- assert_equals(
- new FetchEvent('FetchEvent', {request : req, isReload : true}).request.url,
- 'http://localhost:8800/',
- 'FetchEvent.request.url should return the value it was initialized to');
- }, 'Event constructors');
</script>
+</body>
+</html>
Modified: branches/safari-605-branch/Source/WebCore/ChangeLog (226681 => 226682)
--- branches/safari-605-branch/Source/WebCore/ChangeLog 2018-01-10 04:31:14 UTC (rev 226681)
+++ branches/safari-605-branch/Source/WebCore/ChangeLog 2018-01-10 04:31:18 UTC (rev 226682)
@@ -1,5 +1,34 @@
2018-01-09 Jason Marcell <[email protected]>
+ Cherry-pick r226526. rdar://problem/36392384
+
+ 2018-01-08 Youenn Fablet <[email protected]>
+
+ Stop exposing fetch and extendable events to window
+ https://bugs.webkit.org/show_bug.cgi?id=181325
+
+ Reviewed by Chris Dumez.
+
+ Covered by updated tests.
+
+ Marked FetchEvent and ExtendableEvent as visible in ServiceWorker environments only.
+ Moved related Internals testing routines to ServiceWorkerInternals.
+
+ * testing/Internals.cpp:
+ (WebCore::Internals::waitForFetchEventToFinish): Deleted.
+ (WebCore::Internals::createBeingDispatchedFetchEvent): Deleted.
+ * testing/Internals.h:
+ * testing/Internals.idl:
+ * testing/ServiceWorkerInternals.cpp:
+ (WebCore::ServiceWorkerInternals::waitForFetchEventToFinish):
+ (WebCore::ServiceWorkerInternals::createBeingDispatchedFetchEvent):
+ * testing/ServiceWorkerInternals.h:
+ * testing/ServiceWorkerInternals.idl:
+ * workers/service/ExtendableEvent.idl:
+ * workers/service/FetchEvent.idl:
+
+2018-01-09 Jason Marcell <[email protected]>
+
Cherry-pick r226521. rdar://problem/36392339
2018-01-08 Antti Koivisto <[email protected]>
Modified: branches/safari-605-branch/Source/WebCore/testing/Internals.cpp (226681 => 226682)
--- branches/safari-605-branch/Source/WebCore/testing/Internals.cpp 2018-01-10 04:31:14 UTC (rev 226681)
+++ branches/safari-605-branch/Source/WebCore/testing/Internals.cpp 2018-01-10 04:31:18 UTC (rev 226682)
@@ -62,7 +62,7 @@
#include "EventHandler.h"
#include "ExtendableEvent.h"
#include "ExtensionStyleSheets.h"
-#include "FetchEvent.h"
+#include "FetchResponse.h"
#include "File.h"
#include "FontCache.h"
#include "FormController.h"
@@ -91,7 +91,6 @@
#include "InstrumentingAgents.h"
#include "IntRect.h"
#include "InternalSettings.h"
-#include "JSFetchResponse.h"
#include "JSImageData.h"
#include "LibWebRTCProvider.h"
#include "MainFrame.h"
@@ -4291,23 +4290,6 @@
}
#if ENABLE(SERVICE_WORKER)
-void Internals::waitForFetchEventToFinish(FetchEvent& event, DOMPromiseDeferred<IDLInterface<FetchResponse>>&& promise)
-{
- event.onResponse([promise = WTFMove(promise), event = makeRef(event)] (FetchResponse* response) mutable {
- if (response)
- promise.resolve(*response);
- else
- promise.reject(TypeError, ASCIILiteral("fetch event responded with error"));
- });
-}
-
-Ref<FetchEvent> Internals::createBeingDispatchedFetchEvent(ScriptExecutionContext& context)
-{
- auto event = FetchEvent::createForTesting(context);
- event->setEventPhase(Event::CAPTURING_PHASE);
- return event;
-}
-
void Internals::hasServiceWorkerRegistration(const String& clientURL, HasRegistrationPromise&& promise)
{
if (!contextDocument())
Modified: branches/safari-605-branch/Source/WebCore/testing/Internals.h (226681 => 226682)
--- branches/safari-605-branch/Source/WebCore/testing/Internals.h 2018-01-10 04:31:14 UTC (rev 226681)
+++ branches/safari-605-branch/Source/WebCore/testing/Internals.h 2018-01-10 04:31:18 UTC (rev 226682)
@@ -52,7 +52,6 @@
class Document;
class Element;
class ExtendableEvent;
-class FetchEvent;
class FetchResponse;
class File;
class Frame;
@@ -626,8 +625,6 @@
void setConsoleMessageListener(RefPtr<StringCallback>&&);
#if ENABLE(SERVICE_WORKER)
- void waitForFetchEventToFinish(FetchEvent&, DOMPromiseDeferred<IDLInterface<FetchResponse>>&&);
- Ref<FetchEvent> createBeingDispatchedFetchEvent(ScriptExecutionContext&);
using HasRegistrationPromise = DOMPromiseDeferred<IDLBoolean>;
void hasServiceWorkerRegistration(const String& clientURL, HasRegistrationPromise&&);
void terminateServiceWorker(ServiceWorker&);
Modified: branches/safari-605-branch/Source/WebCore/testing/Internals.idl (226681 => 226682)
--- branches/safari-605-branch/Source/WebCore/testing/Internals.idl 2018-01-10 04:31:14 UTC (rev 226681)
+++ branches/safari-605-branch/Source/WebCore/testing/Internals.idl 2018-01-10 04:31:18 UTC (rev 226682)
@@ -568,8 +568,6 @@
DOMString audioSessionCategory();
- [Conditional=SERVICE_WORKER] Promise<Response> waitForFetchEventToFinish(FetchEvent event);
- [Conditional=SERVICE_WORKER, CallWith=ScriptExecutionContext] FetchEvent createBeingDispatchedFetchEvent();
[Conditional=SERVICE_WORKER] Promise<boolean> hasServiceWorkerRegistration(DOMString scopeURL);
[Conditional=SERVICE_WORKER] void terminateServiceWorker(ServiceWorker worker);
Modified: branches/safari-605-branch/Source/WebCore/testing/ServiceWorkerInternals.cpp (226681 => 226682)
--- branches/safari-605-branch/Source/WebCore/testing/ServiceWorkerInternals.cpp 2018-01-10 04:31:14 UTC (rev 226681)
+++ branches/safari-605-branch/Source/WebCore/testing/ServiceWorkerInternals.cpp 2018-01-10 04:31:18 UTC (rev 226682)
@@ -28,6 +28,8 @@
#if ENABLE(SERVICE_WORKER)
+#include "FetchEvent.h"
+#include "JSFetchResponse.h"
#include "SWContextManager.h"
namespace WebCore {
@@ -47,6 +49,23 @@
});
}
+void ServiceWorkerInternals::waitForFetchEventToFinish(FetchEvent& event, DOMPromiseDeferred<IDLInterface<FetchResponse>>&& promise)
+{
+ event.onResponse([promise = WTFMove(promise), event = makeRef(event)] (FetchResponse* response) mutable {
+ if (response)
+ promise.resolve(*response);
+ else
+ promise.reject(TypeError, ASCIILiteral("fetch event responded with error"));
+ });
+}
+
+Ref<FetchEvent> ServiceWorkerInternals::createBeingDispatchedFetchEvent(ScriptExecutionContext& context)
+{
+ auto event = FetchEvent::createForTesting(context);
+ event->setEventPhase(Event::CAPTURING_PHASE);
+ return event;
+}
+
} // namespace WebCore
#endif
Modified: branches/safari-605-branch/Source/WebCore/testing/ServiceWorkerInternals.h (226681 => 226682)
--- branches/safari-605-branch/Source/WebCore/testing/ServiceWorkerInternals.h 2018-01-10 04:31:14 UTC (rev 226681)
+++ branches/safari-605-branch/Source/WebCore/testing/ServiceWorkerInternals.h 2018-01-10 04:31:18 UTC (rev 226682)
@@ -27,11 +27,16 @@
#if ENABLE(SERVICE_WORKER)
+#include "JSDOMPromiseDeferred.h"
#include "ServiceWorkerIdentifier.h"
#include <wtf/RefCounted.h>
namespace WebCore {
+class FetchEvent;
+class FetchResponse;
+class ScriptExecutionContext;
+
class WEBCORE_EXPORT ServiceWorkerInternals : public RefCounted<ServiceWorkerInternals> {
public:
static Ref<ServiceWorkerInternals> create(ServiceWorkerIdentifier identifier) { return adoptRef(*new ServiceWorkerInternals { identifier }); }
@@ -38,6 +43,8 @@
~ServiceWorkerInternals();
void setOnline(bool isOnline);
+ void waitForFetchEventToFinish(FetchEvent&, DOMPromiseDeferred<IDLInterface<FetchResponse>>&&);
+ Ref<FetchEvent> createBeingDispatchedFetchEvent(ScriptExecutionContext&);
private:
explicit ServiceWorkerInternals(ServiceWorkerIdentifier);
Modified: branches/safari-605-branch/Source/WebCore/testing/ServiceWorkerInternals.idl (226681 => 226682)
--- branches/safari-605-branch/Source/WebCore/testing/ServiceWorkerInternals.idl 2018-01-10 04:31:14 UTC (rev 226681)
+++ branches/safari-605-branch/Source/WebCore/testing/ServiceWorkerInternals.idl 2018-01-10 04:31:18 UTC (rev 226682)
@@ -30,4 +30,6 @@
NoInterfaceObject,
] interface ServiceWorkerInternals {
void setOnline(boolean isOnline);
+ Promise<Response> waitForFetchEventToFinish(FetchEvent event);
+ [CallWith=ScriptExecutionContext] FetchEvent createBeingDispatchedFetchEvent();
};
Modified: branches/safari-605-branch/Source/WebCore/workers/service/ExtendableEvent.idl (226681 => 226682)
--- branches/safari-605-branch/Source/WebCore/workers/service/ExtendableEvent.idl 2018-01-10 04:31:14 UTC (rev 226681)
+++ branches/safari-605-branch/Source/WebCore/workers/service/ExtendableEvent.idl 2018-01-10 04:31:18 UTC (rev 226682)
@@ -23,12 +23,11 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-// FIXME: Should be exposed on ServiceWorker only.
[
Constructor(DOMString type, optional ExtendableEventInit eventInitDict),
Conditional=SERVICE_WORKER,
EnabledAtRuntime=ServiceWorker,
- Exposed=(ServiceWorker,Window),
+ Exposed=(ServiceWorker),
ExportMacro=WEBCORE_EXPORT,
JSGenerateToNativeObject,
] interface ExtendableEvent : Event {
Modified: branches/safari-605-branch/Source/WebCore/workers/service/FetchEvent.idl (226681 => 226682)
--- branches/safari-605-branch/Source/WebCore/workers/service/FetchEvent.idl 2018-01-10 04:31:14 UTC (rev 226681)
+++ branches/safari-605-branch/Source/WebCore/workers/service/FetchEvent.idl 2018-01-10 04:31:18 UTC (rev 226682)
@@ -23,7 +23,6 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-// FIXME: Should be exposed on ServiceWorker only.
[
Constructor(DOMString type, FetchEventInit eventInitDict),
Conditional=SERVICE_WORKER,
@@ -30,7 +29,7 @@
JSCustomMarkFunction,
EnabledAtRuntime=ServiceWorker,
ExportMacro=WEBCORE_EXPORT,
- Exposed=(ServiceWorker,Window),
+ Exposed=(ServiceWorker),
JSGenerateToNativeObject
] interface FetchEvent : ExtendableEvent {
[SameObject] readonly attribute FetchRequest request;