Changeset 223562 in webkit


Ignore:
Timestamp:
Oct 17, 2017 11:39:48 AM (7 years ago)
Author:
commit-queue@webkit.org
Message:

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:
Location:
trunk
Files:
14 added
17 edited
3 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r223558 r223562  
     12017-10-17  Youenn Fablet  <youenn@apple.com>
     2
     3        Add preliminary support for fetch event
     4        https://bugs.webkit.org/show_bug.cgi?id=178171
     5
     6        Reviewed by Chris Dumez.
     7
     8        Skipping new tests for WK1 and GTK that do not have SW.
     9
     10        * http/wpt/service-workers/extendableEvent.https-expected.txt: Added.
     11        * http/wpt/service-workers/extendableEvent.https.html: Added.
     12        * http/wpt/service-workers/fetchEvent.https-expected.txt: Added.
     13        * http/wpt/service-workers/fetchEvent.https.html: Added.
     14        * platform/gtk/TestExpectations:
     15        * platform/ios-wk1/TestExpectations:
     16        * platform/mac-wk1/TestExpectations:
     17
    1182017-10-17  Youenn Fablet  <youenn@apple.com>
    219
  • trunk/LayoutTests/platform/ios-wk1/TestExpectations

    r222926 r223562  
    1010# No service worker implementation for WK1
    1111imported/w3c/web-platform-tests/service-workers [ Skip ]
     12http/wpt/service-workers [ Skip ]
    1213http/wpt/cache-storage [ Skip ]
    1314http/tests/cache-storage [ Skip ]
  • trunk/LayoutTests/platform/mac-wk1/TestExpectations

    r223440 r223562  
    105105# No service worker implementation for WK1
    106106imported/w3c/web-platform-tests/service-workers [ Skip ]
     107http/wpt/service-workers [ Skip ]
    107108http/wpt/cache-storage [ Skip ]
    108109http/tests/cache-storage [ Skip ]
  • trunk/Source/JavaScriptCore/ChangeLog

    r223523 r223562  
     12017-10-17  Youenn Fablet  <youenn@apple.com>
     2
     3        Add preliminary support for fetch event
     4        https://bugs.webkit.org/show_bug.cgi?id=178171
     5
     6        Reviewed by Chris Dumez.
     7
     8        Adding events
     9
     10        * runtime/JSPromise.h:
     11
    1122017-10-10  Yusuke Suzuki  <utatane.tea@gmail.com>
    213
  • trunk/Source/JavaScriptCore/runtime/JSPromise.h

    r216501 r223562  
    4545    };
    4646
    47     Status status(VM&) const;
     47    JS_EXPORT_PRIVATE Status status(VM&) const;
    4848    JS_EXPORT_PRIVATE JSValue result(VM&) const;
    4949    JS_EXPORT_PRIVATE bool isHandled(VM&) const;
  • trunk/Source/WebCore/CMakeLists.txt

    r223412 r223562  
    787787    workers/WorkerType.idl
    788788
     789    workers/service/ExtendableEvent.idl
     790    workers/service/ExtendableEventInit.idl
     791    workers/service/FetchEvent.idl
    789792    workers/service/ServiceWorker.idl
    790793    workers/service/ServiceWorkerContainer.idl
     
    12881291    bindings/js/JSDOMGuardedObject.cpp
    12891292    bindings/js/JSDOMMapLike.cpp
     1293    bindings/js/JSDOMPromise.cpp
    12901294    bindings/js/JSDOMPromiseDeferred.cpp
    12911295    bindings/js/JSDOMWindowBase.cpp
     
    30763080    workers/WorkerThread.cpp
    30773081
     3082    workers/service/ExtendableEvent.cpp
     3083    workers/service/FetchEvent.cpp
    30783084    workers/service/ServiceWorker.cpp
    30793085    workers/service/ServiceWorkerContainer.cpp
  • trunk/Source/WebCore/ChangeLog

    r223560 r223562  
     12017-10-17  Youenn Fablet  <youenn@apple.com>
     2
     3        Add preliminary support for fetch event
     4        https://bugs.webkit.org/show_bug.cgi?id=178171
     5
     6        Reviewed by Chris Dumez.
     7
     8        Test: http/wpt/service-workers/fetchEvent.https.html
     9              http/wpt/service-workers/extendableEvent.https.html
     10
     11        Adding support for ExtendableEvent and FetchEvent as per
     12        https://w3c.github.io/ServiceWorker/v1/#extendableevent-interface and
     13        https://w3c.github.io/ServiceWorker/v1/#fetchevent-interface.
     14
     15        Both events need to handle promises as method parameters.
     16        Beefing up DOMPromise for that purpose by exposing status, result and being able to call then.
     17        Adding a new DOMPromise create method that would be the base for https://heycam.github.io/webidl/#es-promise
     18        which might be implemented in the binding generator as a follow-up.
     19
     20        This patch makes them exposed on Window for test purposes until they can be fully tested on ServiceWorker environment.
     21        It is also adding two internal methods for the same reason. These should be removed once events can be tested in its environment.
     22
     23        * CMakeLists.txt:
     24        * DerivedSources.make:
     25        * Modules/fetch/FetchResponse.idl:
     26        * WebCore.xcodeproj/project.pbxproj:
     27        * bindings/js/JSDOMPromise.cpp: Added.
     28        (WebCore::callFunction):
     29        (WebCore::DOMPromise::create):
     30        (WebCore::DOMPromise::whenSettled):
     31        (WebCore::DOMPromise::result const):
     32        (WebCore::DOMPromise::status const):
     33        * bindings/js/JSDOMPromise.h:
     34        * bindings/js/WebCoreBuiltinNames.h:
     35        * dom/EventNames.in:
     36        * testing/Internals.cpp:
     37        (WebCore::Internals::waitFetchEventToFinish):
     38        (WebCore::Internals::waitExtendableEventToFinish):
     39        * testing/Internals.h:
     40        * testing/Internals.idl:
     41        * workers/service/ExtendableEvent.cpp: Added.
     42        (WebCore::ExtendableEvent::ExtendableEvent):
     43        (WebCore::ExtendableEvent::waitUntil):
     44        (WebCore::ExtendableEvent::addPendingPromise):
     45        * workers/service/ExtendableEvent.h:
     46        (WebCore::ExtendableEvent::onFinishedWaiting):
     47        (WebCore::ExtendableEvent::promiseSettled):
     48        * workers/service/ExtendableEvent.idl: Added.
     49        * workers/service/ExtendableEventInit.h: Added.
     50        * workers/service/ExtendableEventInit.idl: Added.
     51        * workers/service/FetchEvent.cpp: Added.
     52        (WebCore::FetchEvent::FetchEvent):
     53        (WebCore::FetchEvent::respondWith):
     54        (WebCore::FetchEvent::onResponse):
     55        (WebCore::FetchEvent::respondWithError):
     56        (WebCore::FetchEvent::processResponse):
     57        (WebCore::FetchEvent::promiseSettled):
     58        * workers/service/FetchEvent.h:
     59        * workers/service/FetchEvent.idl:
     60
    1612017-10-17  Jer Noble  <jer.noble@apple.com>
    262
  • trunk/Source/WebCore/DerivedSources.make

    r223338 r223562  
    911911    $(WebCore)/workers/WorkerLocation.idl \
    912912    $(WebCore)/workers/WorkerType.idl \
     913    $(WebCore)/workers/service/ExtendableEvent.idl \
     914    $(WebCore)/workers/service/ExtendableEventInit.idl \
     915    $(WebCore)/workers/service/FetchEvent.idl \
    913916    $(WebCore)/workers/service/ServiceWorker.idl \
    914917    $(WebCore)/workers/service/ServiceWorkerContainer.idl \
  • trunk/Source/WebCore/Modules/fetch/FetchRequest.idl

    r223441 r223562  
    4040    EnabledAtRuntime=FetchAPI,
    4141    Exposed=(Window,Worker),
     42    GenerateIsReachable=Impl,
    4243    InterfaceName=Request,
    4344] interface FetchRequest {
  • trunk/Source/WebCore/Modules/fetch/FetchResponse.idl

    r223073 r223562  
    4444    ConstructorMayThrowException,
    4545    EnabledAtRuntime=FetchAPI,
    46     ExportToWrappedFunction,
     46    ExportMacro=WEBCORE_EXPORT,
    4747    Exposed=(Window,Worker),
    4848    InterfaceName=Response,
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r223476 r223562  
    16941694                413015D91C7B571400091C6E /* FetchResponse.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 413015D51C7B570400091C6E /* FetchResponse.cpp */; };
    16951695                413015D91C7B571400091C6F /* FetchBodySource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 413015D51C7B570400091C6F /* FetchBodySource.cpp */; };
     1696                4131F3B31F9552860059995A /* JSFetchEventCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4131F3B11F9552810059995A /* JSFetchEventCustom.cpp */; };
    16961697                41380C261F3436A600155FDA /* DOMCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41380C201F34368A00155FDA /* DOMCache.cpp */; };
    16971698                41380C271F3436AC00155FDA /* DOMCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 41380C251F34369A00155FDA /* DOMCache.h */; };
     
    17771778                41ABE67C1D0580E0006D862D /* CrossOriginPreflightChecker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41ABE6791D0580D5006D862D /* CrossOriginPreflightChecker.cpp */; };
    17781779                41AD753A1CEF6BD100A31486 /* FetchOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 41AD75391CEF6BCE00A31486 /* FetchOptions.h */; settings = {ATTRIBUTES = (Private, ); }; };
     1780                41AF37991F8DADAA00111C31 /* ExtendableEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41AF37921F8DA48A00111C31 /* ExtendableEvent.cpp */; };
     1781                41AF379B1F8DADAE00111C31 /* FetchEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41AF37941F8DA49500111C31 /* FetchEvent.cpp */; };
     1782                41AF379D1F8DB1B500111C31 /* JSDOMPromise.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41AF379C1F8DB1B100111C31 /* JSDOMPromise.cpp */; };
    17791783                41B28B141F8501A600FB52AC /* MediaEndpointConfiguration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41B28B131F8501A400FB52AC /* MediaEndpointConfiguration.cpp */; };
    17801784                41B28B151F8501D300FB52AC /* MediaEndpointConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 41B28B121F8501A300FB52AC /* MediaEndpointConfiguration.h */; };
     
    34073411                7E4C96DC1AD4483500365A50 /* JSFetchRequest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7E4C96D81AD4483500365A50 /* JSFetchRequest.cpp */; };
    34083412                7E4C96DC1AD4483500365A51 /* JSReadableStreamSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7E4C96D81AD4483500365A51 /* JSReadableStreamSource.cpp */; };
     3413                7E4C96DC1AD4483500365A52 /* WebCore/JSFetchEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7E4C96D81AD4483500365A52 /* WebCore/JSFetchEvent.cpp */; };
     3414                7E4C96DC1AD4483500365A53 /* WebCore/JSExtendableEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7E4C96D81AD4483500365A53 /* WebCore/JSExtendableEvent.cpp */; };
     3415                7E4C96DC1AD4483500365A54 /* WebCore/JSExtendableEventInit.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7E4C96D81AD4483500365A54 /* WebCore/JSExtendableEventInit.cpp */; };
    34093416                7E4C96DD1AD4483500365A50 /* JSFetchRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E4C96D91AD4483500365A50 /* JSFetchRequest.h */; };
    34103417                7E4C96DD1AD4483500365A51 /* JSReadableStreamSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E4C96D91AD4483500365A51 /* JSReadableStreamSource.h */; };
     3418                7E4C96DD1AD4483500365A52 /* JSFetchEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E4C96D91AD4483500365A52 /* JSFetchEvent.h */; };
     3419                7E4C96DD1AD4483500365A53 /* JSExtendableEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E4C96D91AD4483500365A53 /* JSExtendableEvent.h */; };
    34113420                7E4DE10D198B10B60051CB02 /* DiskCacheMonitorCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7E4DE10C198B10B60051CB02 /* DiskCacheMonitorCocoa.mm */; };
    34123421                7E5D7A76161D3F8F00896C34 /* OESElementIndexUint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7E5D7A73161D3F8F00896C34 /* OESElementIndexUint.cpp */; };
     
    94979506                413015D61C7B570400091C6F /* FetchBodySource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FetchBodySource.h; sourceTree = "<group>"; };
    94989507                413015D71C7B570400091C6E /* FetchResponse.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = FetchResponse.idl; sourceTree = "<group>"; };
     9508                4131F3B11F9552810059995A /* JSFetchEventCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSFetchEventCustom.cpp; sourceTree = "<group>"; };
     9509                4131F3B41F955BC30059995A /* ExtendableEventInit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExtendableEventInit.h; sourceTree = "<group>"; };
     9510                4131F3B51F955BC50059995A /* ExtendableEventInit.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ExtendableEventInit.idl; sourceTree = "<group>"; };
    94999511                41380C201F34368A00155FDA /* DOMCache.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = DOMCache.cpp; path = Modules/cache/DOMCache.cpp; sourceTree = SOURCE_ROOT; };
    95009512                41380C211F34368D00155FDA /* DOMCacheStorage.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = DOMCacheStorage.cpp; path = Modules/cache/DOMCacheStorage.cpp; sourceTree = SOURCE_ROOT; };
     
    95999611                41ABE67A1D0580D5006D862D /* CrossOriginPreflightChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CrossOriginPreflightChecker.h; sourceTree = "<group>"; };
    96009612                41AD75391CEF6BCE00A31486 /* FetchOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FetchOptions.h; sourceTree = "<group>"; };
     9613                41AF37881F8C1E7900111C31 /* FetchEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FetchEvent.h; sourceTree = "<group>"; };
     9614                41AF378A1F8C1E7A00111C31 /* ExtendableEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExtendableEvent.h; sourceTree = "<group>"; };
     9615                41AF378D1F8C1E7B00111C31 /* FetchEvent.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = FetchEvent.idl; sourceTree = "<group>"; };
     9616                41AF378E1F8C1E7C00111C31 /* ExtendableEvent.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ExtendableEvent.idl; sourceTree = "<group>"; };
     9617                41AF37921F8DA48A00111C31 /* ExtendableEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExtendableEvent.cpp; sourceTree = "<group>"; };
     9618                41AF37941F8DA49500111C31 /* FetchEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FetchEvent.cpp; sourceTree = "<group>"; };
     9619                41AF379C1F8DB1B100111C31 /* JSDOMPromise.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMPromise.cpp; sourceTree = "<group>"; };
    96019620                41B28B121F8501A300FB52AC /* MediaEndpointConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaEndpointConfiguration.h; sourceTree = "<group>"; };
    96029621                41B28B131F8501A400FB52AC /* MediaEndpointConfiguration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaEndpointConfiguration.cpp; sourceTree = "<group>"; };
     
    1169411713                7E4C96D81AD4483500365A50 /* JSFetchRequest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSFetchRequest.cpp; sourceTree = "<group>"; };
    1169511714                7E4C96D81AD4483500365A51 /* JSReadableStreamSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSReadableStreamSource.cpp; sourceTree = "<group>"; };
     11715                7E4C96D81AD4483500365A52 /* WebCore/JSFetchEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebCore/JSFetchEvent.cpp; sourceTree = "<group>"; };
     11716                7E4C96D81AD4483500365A53 /* WebCore/JSExtendableEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebCore/JSExtendableEvent.cpp; sourceTree = "<group>"; };
     11717                7E4C96D81AD4483500365A54 /* WebCore/JSExtendableEventInit.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebCore/JSExtendableEventInit.cpp; sourceTree = "<group>"; };
    1169611718                7E4C96D91AD4483500365A50 /* JSFetchRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSFetchRequest.h; sourceTree = "<group>"; };
    1169711719                7E4C96D91AD4483500365A51 /* JSReadableStreamSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSReadableStreamSource.h; sourceTree = "<group>"; };
     11720                7E4C96D91AD4483500365A52 /* JSFetchEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSFetchEvent.h; sourceTree = "<group>"; };
     11721                7E4C96D91AD4483500365A53 /* JSExtendableEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSExtendableEvent.h; sourceTree = "<group>"; };
    1169811722                7E4DE10C198B10B60051CB02 /* DiskCacheMonitorCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DiskCacheMonitorCocoa.mm; sourceTree = "<group>"; };
    1169911723                7E5D7A73161D3F8F00896C34 /* OESElementIndexUint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OESElementIndexUint.cpp; sourceTree = "<group>"; };
     
    1910319127                        isa = PBXGroup;
    1910419128                        children = (
     19129                                7E4C96D91AD4483500365A53 /* JSExtendableEvent.h */,
     19130                                7E4C96D91AD4483500365A52 /* JSFetchEvent.h */,
    1910519131                                51F886BE1F32920700C193EF /* JSNavigatorServiceWorker.cpp */,
    1910619132                                51F886BF1F32920700C193EF /* JSNavigatorServiceWorker.h */,
     
    1911519141                                51F175001F358B3600C74950 /* JSServiceWorkerUpdateViaCache.cpp */,
    1911619142                                51F175011F358B3600C74950 /* JSServiceWorkerUpdateViaCache.h */,
     19143                                7E4C96D81AD4483500365A53 /* WebCore/JSExtendableEvent.cpp */,
     19144                                7E4C96D81AD4483500365A54 /* WebCore/JSExtendableEventInit.cpp */,
     19145                                7E4C96D81AD4483500365A52 /* WebCore/JSFetchEvent.cpp */,
    1911719146                        );
    1911819147                        name = ServiceWorkers;
     
    1918219211                                517C87071F8E8FF200EB8076 /* context */,
    1918319212                                517A52EC1F47532D00DCDC0A /* server */,
     19213                                41AF37921F8DA48A00111C31 /* ExtendableEvent.cpp */,
     19214                                41AF378A1F8C1E7A00111C31 /* ExtendableEvent.h */,
     19215                                41AF378E1F8C1E7C00111C31 /* ExtendableEvent.idl */,
     19216                                4131F3B41F955BC30059995A /* ExtendableEventInit.h */,
     19217                                4131F3B51F955BC50059995A /* ExtendableEventInit.idl */,
     19218                                41AF37941F8DA49500111C31 /* FetchEvent.cpp */,
     19219                                41AF37881F8C1E7900111C31 /* FetchEvent.h */,
     19220                                41AF378D1F8C1E7B00111C31 /* FetchEvent.idl */,
    1918419221                                51F1755B1F3EBC0C00C74950 /* ServiceWorker.cpp */,
    1918519222                                51F1755A1F3EBC0C00C74950 /* ServiceWorker.h */,
     
    2036220399                        children = (
    2036320400                                DEC2975D1B4DEB2A005F5945 /* JSCustomEventCustom.cpp */,
     20401                                4131F3B11F9552810059995A /* JSFetchEventCustom.cpp */,
    2036420402                                BCE7B1920D4E86960075A539 /* JSHistoryCustom.cpp */,
    2036520403                                410B7E711045FAB000D8224F /* JSMessageEventCustom.cpp */,
     
    2424924287                                7C8139A41ED6281D00CE26E8 /* JSDOMOperation.h */,
    2425024288                                7C8139A51ED6281D00CE26E8 /* JSDOMOperationReturningPromise.h */,
     24289                                41AF379C1F8DB1B100111C31 /* JSDOMPromise.cpp */,
    2425124290                                E37C864F1EB63E2D0087C6CA /* JSDOMPromise.h */,
    2425224291                                E172AF8D1811BC3700FBADB9 /* JSDOMPromiseDeferred.cpp */,
     
    2868628725                                46B63F6C1C6E8D19002E914B /* JSEventTargetCustom.h in Headers */,
    2868728726                                724ED3321A3A8B2300F5F13C /* JSEXTBlendMinMax.h in Headers */,
     28727                                7E4C96DD1AD4483500365A53 /* JSExtendableEvent.h in Headers */,
    2868828728                                5C4304B6191AEF46000E2BC0 /* JSEXTShaderTextureLOD.h in Headers */,
    2868928729                                7728698414FD9ADA00F484DC /* JSEXTTextureFilterAnisotropic.h in Headers */,
     
    2869228732                                77D510131ED5F4ED00DA4C87 /* JSFederatedCredentialRequestOptions.h in Headers */,
    2869328733                                7F4C96DD1AD4483500365A50 /* JSFetchBody.h in Headers */,
     28734                                7E4C96DD1AD4483500365A52 /* JSFetchEvent.h in Headers */,
    2869428735                                7D4C96DD1AD4483500365A50 /* JSFetchHeaders.h in Headers */,
    2869528736                                7CE191711F2ABE7100272F78 /* JSFetchReferrerPolicy.h in Headers */,
     
    3199532036                                51F645A41F4C001700B54DED /* ExceptionData.cpp in Sources */,
    3199632037                                724ED32C1A3A7E5400F5F13C /* EXTBlendMinMax.cpp in Sources */,
     32038                                41AF37991F8DADAA00111C31 /* ExtendableEvent.cpp in Sources */,
    3199732039                                31DCDF431DA1C45400EA5B93 /* ExtendedColor.cpp in Sources */,
    3199832040                                6E67D2A61280E8A4008758F7 /* Extensions3DOpenGL.cpp in Sources */,
     
    3202332065                                4147E2B81C89912F00A7E715 /* FetchBodyOwner.cpp in Sources */,
    3202432066                                413015D91C7B571400091C6F /* FetchBodySource.cpp in Sources */,
     32067                                41AF379B1F8DADAE00111C31 /* FetchEvent.cpp in Sources */,
    3202532068                                41F54F8D1C50C50800338488 /* FetchHeaders.cpp in Sources */,
    3202632069                                4147E2B71C89912C00A7E715 /* FetchLoader.cpp in Sources */,
     
    3267132714                                0F4966AC1DB40C4300A274BB /* JSDOMPointInit.cpp in Sources */,
    3267232715                                0F4966AE1DB40C4300A274BB /* JSDOMPointReadOnly.cpp in Sources */,
     32716                                41AF379D1F8DB1B500111C31 /* JSDOMPromise.cpp in Sources */,
    3267332717                                E172AF8F1811BC3700FBADB9 /* JSDOMPromiseDeferred.cpp in Sources */,
    3267432718                                0FF3B9281EE3B6DE00B84144 /* JSDOMQuad.cpp in Sources */,
     
    3271932763                                77D510141ED5F4F100DA4C87 /* JSFederatedCredentialRequestOptions.cpp in Sources */,
    3272032764                                7F4C96DC1AD4483500365A50 /* JSFetchBody.cpp in Sources */,
     32765                                4131F3B31F9552860059995A /* JSFetchEventCustom.cpp in Sources */,
    3272132766                                7D4C96DC1AD4483500365A50 /* JSFetchHeaders.cpp in Sources */,
    3272232767                                7CE191701F2ABE7100272F78 /* JSFetchReferrerPolicy.cpp in Sources */,
     
    3458334628                                9B0811241F67CDC00074BDE2 /* WebContentReaderIOS.mm in Sources */,
    3458434629                                9B9299AE1F67865B006723C2 /* WebContentReaderMac.mm in Sources */,
     34630                                7E4C96DC1AD4483500365A53 /* WebCore/JSExtendableEvent.cpp in Sources */,
     34631                                7E4C96DC1AD4483500365A54 /* WebCore/JSExtendableEventInit.cpp in Sources */,
     34632                                7E4C96DC1AD4483500365A52 /* WebCore/JSFetchEvent.cpp in Sources */,
    3458534633                                CD7E05221651C28200C1201F /* WebCoreAVFResourceLoader.mm in Sources */,
    3458634634                                2D3EF44B1917915C00034184 /* WebCoreCALayerExtras.mm in Sources */,
  • trunk/Source/WebCore/bindings/js/JSDOMPromise.h

    r216501 r223562  
    3434class DOMPromise : public DOMGuarded<JSC::JSPromise> {
    3535public:
     36    static Ref<DOMPromise> create(JSC::ExecState&, JSC::JSValue);
    3637    static Ref<DOMPromise> create(JSDOMGlobalObject& globalObject, JSC::JSPromise& promise)
    3738    {
     
    4546    }
    4647
     48    void whenSettled(std::function<void()>&&);
     49    JSC::JSValue result() const;
     50
     51    enum class Status { Pending, Fulfilled, Rejected };
     52    Status status() const;
     53
    4754private:
    4855    DOMPromise(JSDOMGlobalObject& globalObject, JSC::JSPromise& promise)
  • trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h

    r223328 r223562  
    4444    macro(DataTransferItemList) \
    4545    macro(DocumentTimeline) \
     46    macro(ExtendableEvent) \
    4647    macro(FederatedCredential) \
     48    macro(FetchEvent) \
    4749    macro(FileSystem) \
    4850    macro(FileSystemDirectoryEntry) \
  • trunk/Source/WebCore/dom/EventNames.in

    r223193 r223562  
    1111CompositionEvent
    1212CustomEvent
     13ExtendableEvent conditional=SERVICE_WORKER
    1314ErrorEvent
     15FetchEvent conditional=SERVICE_WORKER
    1416FocusEvent
    1517HashChangeEvent
  • trunk/Source/WebCore/testing/Internals.cpp

    r223476 r223562  
    5858#include "Element.h"
    5959#include "EventHandler.h"
     60#include "ExtendableEvent.h"
    6061#include "ExtensionStyleSheets.h"
    61 #include "FetchResponse.h"
     62#include "FetchEvent.h"
    6263#include "File.h"
    6364#include "FontCache.h"
     
    8889#include "IntRect.h"
    8990#include "InternalSettings.h"
     91#include "JSFetchResponse.h"
    9092#include "JSImageData.h"
    9193#include "LibWebRTCProvider.h"
     
    41964198}
    41974199
     4200#if ENABLE(SERVICE_WORKER)
     4201void Internals::waitForFetchEventToFinish(FetchEvent& event, DOMPromiseDeferred<IDLInterface<FetchResponse>>&& promise)
     4202{
     4203    event.onResponse([promise = WTFMove(promise), event = makeRef(event)] () mutable {
     4204        if (auto* response = event->response())
     4205            promise.resolve(*response);
     4206        else
     4207            promise.reject(TypeError, ASCIILiteral("fetch event responded with error"));
     4208    });
     4209}
     4210
     4211void Internals::waitForExtendableEventToFinish(ExtendableEvent& event, DOMPromiseDeferred<void>&& promise)
     4212{
     4213    event.onFinishedWaitingForTesting([promise = WTFMove(promise)] () mutable {
     4214        promise.resolve();
     4215    });
     4216}
     4217
     4218Ref<ExtendableEvent> Internals::createTrustedExtendableEvent()
     4219{
     4220    return ExtendableEvent::create("ExtendableEvent", { }, Event::IsTrusted::Yes);
     4221}
     4222#endif
     4223
    41984224} // namespace WebCore
  • trunk/Source/WebCore/testing/Internals.h

    r223073 r223562  
    5151class Document;
    5252class Element;
     53class ExtendableEvent;
     54class FetchEvent;
    5355class FetchResponse;
    5456class File;
     
    607609    void setConsoleMessageListener(RefPtr<StringCallback>&&);
    608610
     611#if ENABLE(SERVICE_WORKER)
     612    void waitForFetchEventToFinish(FetchEvent&, DOMPromiseDeferred<IDLInterface<FetchResponse>>&&);
     613    void waitForExtendableEventToFinish(ExtendableEvent&, DOMPromiseDeferred<void>&&);
     614    Ref<ExtendableEvent> createTrustedExtendableEvent();
     615#endif
     616
    609617private:
    610618    explicit Internals(Document&);
  • trunk/Source/WebCore/testing/Internals.idl

    r223073 r223562  
    554554
    555555    DOMString audioSessionCategory();
    556 };
     556
     557    [Conditional=SERVICE_WORKER] Promise<Response> waitForFetchEventToFinish(FetchEvent event);
     558    [Conditional=SERVICE_WORKER] Promise<void> waitForExtendableEventToFinish(ExtendableEvent event);
     559    [Conditional=SERVICE_WORKER] ExtendableEvent createTrustedExtendableEvent();
     560};
  • trunk/Source/WebCore/workers/service/ExtendableEvent.h

    r223560 r223562  
    11/*
    2  * Copyright (C) 2013-2017 Apple Inc. All rights reserved.
    3  * Copyright (C) 2017 Yusuke Suzuki <utatane.tea@gmail.com>.
     2 * Copyright (C) 2017 Apple Inc. All rights reserved.
    43 *
    54 * Redistribution and use in source and binary forms, with or without
     
    2726#pragma once
    2827
    29 #include "JSDOMGuardedObject.h"
    30 #include <runtime/JSPromise.h>
     28#if ENABLE(SERVICE_WORKER)
     29
     30#include "Event.h"
     31#include "ExtendableEventInit.h"
     32#include "JSDOMPromise.h"
     33#include <wtf/WeakPtr.h>
    3134
    3235namespace WebCore {
    3336
    34 class DOMPromise : public DOMGuarded<JSC::JSPromise> {
     37class ExtendableEvent : public Event {
    3538public:
    36     static Ref<DOMPromise> create(JSDOMGlobalObject& globalObject, JSC::JSPromise& promise)
     39    static Ref<ExtendableEvent> create(const AtomicString& type, const ExtendableEventInit& initializer, IsTrusted isTrusted = IsTrusted::No)
    3740    {
    38         return adoptRef(*new DOMPromise(globalObject, promise));
     41        return adoptRef(*new ExtendableEvent(type, initializer, isTrusted));
    3942    }
    4043
    41     JSC::JSPromise* promise() const
    42     {
    43         ASSERT(!isSuspended());
    44         return guarded();
    45     }
     44    EventInterface eventInterface() const override { return ExtendableEventInterfaceType; }
     45
     46    ExceptionOr<void> waitUntil(JSC::ExecState&, JSC::JSValue);
     47
     48    WEBCORE_EXPORT void onFinishedWaitingForTesting(WTF::Function<void()>&&);
     49
     50protected:
     51    WEBCORE_EXPORT ExtendableEvent(const AtomicString&, const ExtendableEventInit&, IsTrusted);
     52
     53    WeakPtr<ExtendableEvent> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); }
     54
     55    void addPendingPromise(Ref<DOMPromise>&&);
    4656
    4757private:
    48     DOMPromise(JSDOMGlobalObject& globalObject, JSC::JSPromise& promise)
    49         : DOMGuarded<JSC::JSPromise>(globalObject, promise)
    50     {
    51     }
     58    HashSet<Ref<DOMPromise>> m_pendingPromises;
     59    WeakPtrFactory<ExtendableEvent> m_weakPtrFactory;
     60    WTF::Function<void()> m_onFinishedWaitingForTesting;
    5261};
    5362
    5463} // namespace WebCore
     64
     65#endif // ENABLE(SERVICE_WORKER)
  • trunk/Source/WebCore/workers/service/ExtendableEventInit.h

    r223560 r223562  
    11/*
    2  * Copyright (C) 2013-2017 Apple Inc. All rights reserved.
    3  * Copyright (C) 2017 Yusuke Suzuki <utatane.tea@gmail.com>.
     2 * Copyright (C) 2017 Apple Inc. All rights reserved.
    43 *
    54 * Redistribution and use in source and binary forms, with or without
     
    2726#pragma once
    2827
    29 #include "JSDOMGuardedObject.h"
    30 #include <runtime/JSPromise.h>
     28#if ENABLE(SERVICE_WORKER)
     29
     30#include "Event.h"
    3131
    3232namespace WebCore {
    3333
    34 class DOMPromise : public DOMGuarded<JSC::JSPromise> {
    35 public:
    36     static Ref<DOMPromise> create(JSDOMGlobalObject& globalObject, JSC::JSPromise& promise)
    37     {
    38         return adoptRef(*new DOMPromise(globalObject, promise));
    39     }
    40 
    41     JSC::JSPromise* promise() const
    42     {
    43         ASSERT(!isSuspended());
    44         return guarded();
    45     }
    46 
    47 private:
    48     DOMPromise(JSDOMGlobalObject& globalObject, JSC::JSPromise& promise)
    49         : DOMGuarded<JSC::JSPromise>(globalObject, promise)
    50     {
    51     }
     34struct ExtendableEventInit : EventInit {
    5235};
    5336
    5437} // namespace WebCore
     38
     39#endif // ENABLE(SERVICE_WORKER)
  • trunk/Source/WebCore/workers/service/ExtendableEventInit.idl

    r223560 r223562  
    11/*
    2  * Copyright (C) 2013-2017 Apple Inc. All rights reserved.
    3  * Copyright (C) 2017 Yusuke Suzuki <utatane.tea@gmail.com>.
     2 * Copyright (C) 2017 Apple Inc. All rights reserved.
    43 *
    54 * Redistribution and use in source and binary forms, with or without
     
    2524 */
    2625
    27 #pragma once
    28 
    29 #include "JSDOMGuardedObject.h"
    30 #include <runtime/JSPromise.h>
    31 
    32 namespace WebCore {
    33 
    34 class DOMPromise : public DOMGuarded<JSC::JSPromise> {
    35 public:
    36     static Ref<DOMPromise> create(JSDOMGlobalObject& globalObject, JSC::JSPromise& promise)
    37     {
    38         return adoptRef(*new DOMPromise(globalObject, promise));
    39     }
    40 
    41     JSC::JSPromise* promise() const
    42     {
    43         ASSERT(!isSuspended());
    44         return guarded();
    45     }
    46 
    47 private:
    48     DOMPromise(JSDOMGlobalObject& globalObject, JSC::JSPromise& promise)
    49         : DOMGuarded<JSC::JSPromise>(globalObject, promise)
    50     {
    51     }
     26[
     27    Conditional=SERVICE_WORKER,
     28]
     29dictionary ExtendableEventInit : EventInit {
    5230};
    53 
    54 } // namespace WebCore
Note: See TracChangeset for help on using the changeset viewer.