Add preliminary support for fetch event
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Oct 2017 18:39:48 +0000 (18:39 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Oct 2017 18:39:48 +0000 (18:39 +0000)
commit77f9481683fce18b6e59ac11986696ca87aea498
tree7a88238a771b339f5471cb70191b85f94a779bb5
parent470ab2af1dab4957ffbfd82bc145f88f463bf485
Add preliminary support for fetch event
https://bugs.webkit.org/show_bug.cgi?id=178171

Patch by Youenn Fablet <youenn@apple.com> on 2017-10-17
Reviewed by Chris Dumez.

Source/JavaScriptCore:

Adding events

* runtime/JSPromise.h:

Source/WebCore:

Test: http/wpt/service-workers/fetchEvent.https.html
      http/wpt/service-workers/extendableEvent.https.html

Adding support for ExtendableEvent and FetchEvent as per
https://w3c.github.io/ServiceWorker/v1/#extendableevent-interface and
https://w3c.github.io/ServiceWorker/v1/#fetchevent-interface.

Both events need to handle promises as method parameters.
Beefing up DOMPromise for that purpose by exposing status, result and being able to call then.
Adding a new DOMPromise create method that would be the base for https://heycam.github.io/webidl/#es-promise
which might be implemented in the binding generator as a follow-up.

This patch makes them exposed on Window for test purposes until they can be fully tested on ServiceWorker environment.
It is also adding two internal methods for the same reason. These should be removed once events can be tested in its environment.

* CMakeLists.txt:
* DerivedSources.make:
* Modules/fetch/FetchResponse.idl:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSDOMPromise.cpp: Added.
(WebCore::callFunction):
(WebCore::DOMPromise::create):
(WebCore::DOMPromise::whenSettled):
(WebCore::DOMPromise::result const):
(WebCore::DOMPromise::status const):
* bindings/js/JSDOMPromise.h:
* bindings/js/WebCoreBuiltinNames.h:
* dom/EventNames.in:
* testing/Internals.cpp:
(WebCore::Internals::waitFetchEventToFinish):
(WebCore::Internals::waitExtendableEventToFinish):
* testing/Internals.h:
* testing/Internals.idl:
* workers/service/ExtendableEvent.cpp: Added.
(WebCore::ExtendableEvent::ExtendableEvent):
(WebCore::ExtendableEvent::waitUntil):
(WebCore::ExtendableEvent::addPendingPromise):
* workers/service/ExtendableEvent.h:
(WebCore::ExtendableEvent::onFinishedWaiting):
(WebCore::ExtendableEvent::promiseSettled):
* workers/service/ExtendableEvent.idl: Added.
* workers/service/ExtendableEventInit.h: Added.
* workers/service/ExtendableEventInit.idl: Added.
* workers/service/FetchEvent.cpp: Added.
(WebCore::FetchEvent::FetchEvent):
(WebCore::FetchEvent::respondWith):
(WebCore::FetchEvent::onResponse):
(WebCore::FetchEvent::respondWithError):
(WebCore::FetchEvent::processResponse):
(WebCore::FetchEvent::promiseSettled):
* workers/service/FetchEvent.h:
* workers/service/FetchEvent.idl:

LayoutTests:

Skipping new tests for WK1 and GTK that do not have SW.

* http/wpt/service-workers/extendableEvent.https-expected.txt: Added.
* http/wpt/service-workers/extendableEvent.https.html: Added.
* http/wpt/service-workers/fetchEvent.https-expected.txt: Added.
* http/wpt/service-workers/fetchEvent.https.html: Added.
* platform/gtk/TestExpectations:
* platform/ios-wk1/TestExpectations:
* platform/mac-wk1/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223562 268f45cc-cd09-0410-ab3c-d52691b4dbfc
32 files changed:
LayoutTests/ChangeLog
LayoutTests/http/wpt/resources/gc.js [new file with mode: 0644]
LayoutTests/http/wpt/service-workers/extendableEvent.https-expected.txt [new file with mode: 0644]
LayoutTests/http/wpt/service-workers/extendableEvent.https.html [new file with mode: 0644]
LayoutTests/http/wpt/service-workers/fetchEvent.https-expected.txt [new file with mode: 0644]
LayoutTests/http/wpt/service-workers/fetchEvent.https.html [new file with mode: 0644]
LayoutTests/platform/ios-wk1/TestExpectations
LayoutTests/platform/mac-wk1/TestExpectations
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/JSPromise.h
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.make
Source/WebCore/Modules/fetch/FetchRequest.idl
Source/WebCore/Modules/fetch/FetchResponse.idl
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/JSDOMPromise.cpp [new file with mode: 0644]
Source/WebCore/bindings/js/JSDOMPromise.h
Source/WebCore/bindings/js/JSFetchEventCustom.cpp [new file with mode: 0644]
Source/WebCore/bindings/js/WebCoreBuiltinNames.h
Source/WebCore/dom/EventNames.in
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl
Source/WebCore/workers/service/ExtendableEvent.cpp [new file with mode: 0644]
Source/WebCore/workers/service/ExtendableEvent.h [new file with mode: 0644]
Source/WebCore/workers/service/ExtendableEvent.idl [new file with mode: 0644]
Source/WebCore/workers/service/ExtendableEventInit.h [new file with mode: 0644]
Source/WebCore/workers/service/ExtendableEventInit.idl [new file with mode: 0644]
Source/WebCore/workers/service/FetchEvent.cpp [new file with mode: 0644]
Source/WebCore/workers/service/FetchEvent.h [new file with mode: 0644]
Source/WebCore/workers/service/FetchEvent.idl [new file with mode: 0644]