Title: [283377] trunk
Revision
283377
Author
[email protected]
Date
2021-10-01 10:30:38 -0700 (Fri, 01 Oct 2021)

Log Message

Add support for PushEvent
https://bugs.webkit.org/show_bug.cgi?id=231007
<rdar://problem/83707470>

Reviewed by Chris Dumez.

LayoutTests/imported/w3c:

* web-platform-tests/push-api/idlharness.https.any.serviceworker-expected.txt:

Source/WebCore:

Implement PushEvent and PushMessageData as per specification.
https://w3c.github.io/push-api/#pushevent-interface and
https://w3c.github.io/push-api/#pushmessagedata-interface.

We model PushMessageData as a Vector<uint8_t> following the spec which tells us that it has an associated byte sequence.

Put them behind a runtime flag, off by default.

Test: http/wpt/push-api/pushEvent.any.serviceworker.html

* CMakeLists.txt:
* DerivedSources-input.xcfilelist:
* DerivedSources-output.xcfilelist:
* DerivedSources.make:
* Modules/push-api/PushEvent.cpp: Added.
* Modules/push-api/PushEvent.h: Added.
* Modules/push-api/PushEvent.idl: Added.
* Modules/push-api/PushEventInit.h: Added.
* Modules/push-api/PushEventInit.idl: Added.
* Modules/push-api/PushMessageData.cpp: Added.
* Modules/push-api/PushMessageData.h: Added.
* Modules/push-api/PushMessageData.idl: Added.
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/WebCoreBuiltinNames.h:
* dom/EventNames.in:
* page/RuntimeEnabledFeatures.h:

Source/WTF:

* Scripts/Preferences/WebPreferencesExperimental.yaml:

LayoutTests:

Skip tests in WK1.

* http/wpt/push-api/pushEvent.any.js: Added.
* http/wpt/push-api/pushEvent.any.serviceworker-expected.txt: Added.
* http/wpt/push-api/pushEvent.any.serviceworker.html: Added.
* platform/mac-wk1/TestExpectations:
* platform/win/TestExpectations:
* platform/wincairo-wk1/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (283376 => 283377)


--- trunk/LayoutTests/ChangeLog	2021-10-01 17:20:03 UTC (rev 283376)
+++ trunk/LayoutTests/ChangeLog	2021-10-01 17:30:38 UTC (rev 283377)
@@ -1,3 +1,20 @@
+2021-10-01  Youenn Fablet  <[email protected]>
+
+        Add support for PushEvent
+        https://bugs.webkit.org/show_bug.cgi?id=231007
+        <rdar://problem/83707470>
+
+        Reviewed by Chris Dumez.
+
+        Skip tests in WK1.
+
+        * http/wpt/push-api/pushEvent.any.js: Added.
+        * http/wpt/push-api/pushEvent.any.serviceworker-expected.txt: Added.
+        * http/wpt/push-api/pushEvent.any.serviceworker.html: Added.
+        * platform/mac-wk1/TestExpectations:
+        * platform/win/TestExpectations:
+        * platform/wincairo-wk1/TestExpectations:
+
 2021-10-01  Eric Hutchison  <[email protected]>
 
         [ iOS Mac wk2 Debug ] imported/w3c/web-platform-tests/content-security-policy/generic/policy-inherited-correctly-by-plznavigate.html is a flaky failure.

Added: trunk/LayoutTests/http/wpt/push-api/pushEvent.any.js (0 => 283377)


--- trunk/LayoutTests/http/wpt/push-api/pushEvent.any.js	                        (rev 0)
+++ trunk/LayoutTests/http/wpt/push-api/pushEvent.any.js	2021-10-01 17:30:38 UTC (rev 283377)
@@ -0,0 +1,54 @@
+// META: title=PushEvent tests
+// META: global=serviceworker
+
+test(() => {
+    let event = new PushEvent("push");
+    assert_equals(event.data, null, "1");
+
+    event = new PushEvent("push", { });
+    assert_equals(event.data, null, "2");
+}, "PushEvent without data");
+
+test(() => {
+    let event = new PushEvent("push", { data : "" });
+    assert_not_equals(event.data, null);
+    assert_equals(event.data.text(), "");
+
+    const value = { test : 1 };
+    const stringValue = JSON.stringify(value);
+    const encoder = new TextEncoder();
+
+    for (let value of [stringValue, encoder.encode(stringValue)]) {
+        event = new PushEvent("push", { data : value });
+        assert_true(event instanceof PushEvent);
+        assert_true(event instanceof ExtendableEvent);
+
+        const data = ""
+        assert_true(data instanceof PushMessageData);
+        assert_equals(data.text(), stringValue);
+        assert_true(data.blob() instanceof Blob);
+        assert_equals(data.json().test, 1);
+        assert_equals(data.arrayBuffer().byteLength, stringValue.length);
+    }
+}, "PushEvent with data");
+
+test(() => {
+    let event = new PushEvent("push", { data : new ArrayBuffer() });
+    assert_not_equals(event.data, null);
+    assert_equals(event.data.text(), "");
+
+    const value = "potato";
+    const decoder = new TextDecoder();
+    const encoder = new TextEncoder();
+    const buffer = encoder.encode(value);
+    event = new PushEvent("push", { data : buffer });
+
+    assert_false(event.data.arrayBuffer() === buffer, "test 1");
+    assert_false(event.data.arrayBuffer() === event.data.arrayBuffer(), "test 2");
+    assert_equals(decoder.decode(event.data.arrayBuffer()), value);
+}, "PushEvent arrayBuffer handling");
+
+test(() => {
+    const event = new PushEvent("push", { data : "{test : 1}" });
+    assert_throws_dom("SyntaxError", () => event.data.json());
+}, "PushEvent with bad json");

Added: trunk/LayoutTests/http/wpt/push-api/pushEvent.any.serviceworker-expected.txt (0 => 283377)


--- trunk/LayoutTests/http/wpt/push-api/pushEvent.any.serviceworker-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/wpt/push-api/pushEvent.any.serviceworker-expected.txt	2021-10-01 17:30:38 UTC (rev 283377)
@@ -0,0 +1,6 @@
+
+PASS PushEvent without data
+PASS PushEvent with data
+PASS PushEvent arrayBuffer handling
+PASS PushEvent with bad json
+

Added: trunk/LayoutTests/http/wpt/push-api/pushEvent.any.serviceworker.html (0 => 283377)


--- trunk/LayoutTests/http/wpt/push-api/pushEvent.any.serviceworker.html	                        (rev 0)
+++ trunk/LayoutTests/http/wpt/push-api/pushEvent.any.serviceworker.html	2021-10-01 17:30:38 UTC (rev 283377)
@@ -0,0 +1 @@
+<!-- This file is required for WebKit test infrastructure to run the templated test -->
\ No newline at end of file

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (283376 => 283377)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-10-01 17:20:03 UTC (rev 283376)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-10-01 17:30:38 UTC (rev 283377)
@@ -1,5 +1,15 @@
 2021-10-01  Youenn Fablet  <[email protected]>
 
+        Add support for PushEvent
+        https://bugs.webkit.org/show_bug.cgi?id=231007
+        <rdar://problem/83707470>
+
+        Reviewed by Chris Dumez.
+
+        * web-platform-tests/push-api/idlharness.https.any.serviceworker-expected.txt:
+
+2021-10-01  Youenn Fablet  <[email protected]>
+
         Rebase WebRTC perfect negotiation tests
         https://bugs.webkit.org/show_bug.cgi?id=231018
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/push-api/idlharness.https.any.serviceworker-expected.txt (283376 => 283377)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/push-api/idlharness.https.any.serviceworker-expected.txt	2021-10-01 17:20:03 UTC (rev 283376)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/push-api/idlharness.https.any.serviceworker-expected.txt	2021-10-01 17:30:38 UTC (rev 283377)
@@ -45,26 +45,26 @@
 FAIL PushSubscription interface: operation getKey(PushEncryptionKeyName) assert_own_property: self does not have own property "PushSubscription" expected property "PushSubscription" missing
 FAIL PushSubscription interface: operation unsubscribe() assert_own_property: self does not have own property "PushSubscription" expected property "PushSubscription" missing
 FAIL PushSubscription interface: operation toJSON() assert_own_property: self does not have own property "PushSubscription" expected property "PushSubscription" missing
-FAIL PushMessageData interface: existence and properties of interface object assert_own_property: self does not have own property "PushMessageData" expected property "PushMessageData" missing
-FAIL PushMessageData interface object length assert_own_property: self does not have own property "PushMessageData" expected property "PushMessageData" missing
-FAIL PushMessageData interface object name assert_own_property: self does not have own property "PushMessageData" expected property "PushMessageData" missing
-FAIL PushMessageData interface: existence and properties of interface prototype object assert_own_property: self does not have own property "PushMessageData" expected property "PushMessageData" missing
-FAIL PushMessageData interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "PushMessageData" expected property "PushMessageData" missing
-FAIL PushMessageData interface: existence and properties of interface prototype object's @@unscopables property assert_own_property: self does not have own property "PushMessageData" expected property "PushMessageData" missing
-FAIL PushMessageData interface: operation arrayBuffer() assert_own_property: self does not have own property "PushMessageData" expected property "PushMessageData" missing
-FAIL PushMessageData interface: operation blob() assert_own_property: self does not have own property "PushMessageData" expected property "PushMessageData" missing
-FAIL PushMessageData interface: operation json() assert_own_property: self does not have own property "PushMessageData" expected property "PushMessageData" missing
-FAIL PushMessageData interface: operation text() assert_own_property: self does not have own property "PushMessageData" expected property "PushMessageData" missing
-FAIL PushEvent interface: existence and properties of interface object assert_own_property: self does not have own property "PushEvent" expected property "PushEvent" missing
-FAIL PushEvent interface object length assert_own_property: self does not have own property "PushEvent" expected property "PushEvent" missing
-FAIL PushEvent interface object name assert_own_property: self does not have own property "PushEvent" expected property "PushEvent" missing
-FAIL PushEvent interface: existence and properties of interface prototype object assert_own_property: self does not have own property "PushEvent" expected property "PushEvent" missing
-FAIL PushEvent interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "PushEvent" expected property "PushEvent" missing
-FAIL PushEvent interface: existence and properties of interface prototype object's @@unscopables property assert_own_property: self does not have own property "PushEvent" expected property "PushEvent" missing
-FAIL PushEvent interface: attribute data assert_own_property: self does not have own property "PushEvent" expected property "PushEvent" missing
-FAIL PushEvent must be primary interface of new PushEvent("type") assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: PushEvent"
-FAIL Stringification of new PushEvent("type") assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: PushEvent"
-FAIL PushEvent interface: new PushEvent("type") must inherit property "data" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: PushEvent"
+PASS PushMessageData interface: existence and properties of interface object
+PASS PushMessageData interface object length
+PASS PushMessageData interface object name
+PASS PushMessageData interface: existence and properties of interface prototype object
+PASS PushMessageData interface: existence and properties of interface prototype object's "constructor" property
+PASS PushMessageData interface: existence and properties of interface prototype object's @@unscopables property
+PASS PushMessageData interface: operation arrayBuffer()
+PASS PushMessageData interface: operation blob()
+PASS PushMessageData interface: operation json()
+PASS PushMessageData interface: operation text()
+PASS PushEvent interface: existence and properties of interface object
+PASS PushEvent interface object length
+PASS PushEvent interface object name
+PASS PushEvent interface: existence and properties of interface prototype object
+PASS PushEvent interface: existence and properties of interface prototype object's "constructor" property
+PASS PushEvent interface: existence and properties of interface prototype object's @@unscopables property
+PASS PushEvent interface: attribute data
+PASS PushEvent must be primary interface of new PushEvent("type")
+PASS Stringification of new PushEvent("type")
+PASS PushEvent interface: new PushEvent("type") must inherit property "data" with the proper type
 FAIL PushSubscriptionChangeEvent interface: existence and properties of interface object assert_own_property: self does not have own property "PushSubscriptionChangeEvent" expected property "PushSubscriptionChangeEvent" missing
 FAIL PushSubscriptionChangeEvent interface object length assert_own_property: self does not have own property "PushSubscriptionChangeEvent" expected property "PushSubscriptionChangeEvent" missing
 FAIL PushSubscriptionChangeEvent interface object name assert_own_property: self does not have own property "PushSubscriptionChangeEvent" expected property "PushSubscriptionChangeEvent" missing

Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (283376 => 283377)


--- trunk/LayoutTests/platform/mac-wk1/TestExpectations	2021-10-01 17:20:03 UTC (rev 283376)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations	2021-10-01 17:30:38 UTC (rev 283377)
@@ -339,6 +339,7 @@
 http/tests/cookies/same-site/fetch-in-cross-origin-service-worker.html [ Skip ]
 http/tests/cookies/same-site/fetch-in-same-origin-service-worker.html [ Skip ]
 http/wpt/cache-storage [ Skip ]
+http/wpt/push-api [ Skip ]
 http/wpt/service-workers [ Skip ]
 imported/w3c/web-platform-tests/content-security-policy/inside-worker/serviceworker-report-only.https.sub.html [ Skip ]
 imported/w3c/web-platform-tests/content-security-policy/sandbox/service-worker-sandbox.https.html [ Skip ]

Modified: trunk/LayoutTests/platform/win/TestExpectations (283376 => 283377)


--- trunk/LayoutTests/platform/win/TestExpectations	2021-10-01 17:20:03 UTC (rev 283376)
+++ trunk/LayoutTests/platform/win/TestExpectations	2021-10-01 17:30:38 UTC (rev 283377)
@@ -3712,6 +3712,7 @@
 http/tests/inspector/network/resource-response-service-worker.html [ Skip ]
 http/tests/workers/service [ Skip ]
 http/wpt/cache-storage [ Skip ]
+http/wpt/push-api [ Skip ]
 http/wpt/service-workers [ Skip ]
 imported/w3c/web-platform-tests/content-security-policy/securitypolicyviolation/inside-service-worker.https.html [ Skip ]
 imported/w3c/web-platform-tests/content-security-policy/worker-src/service-worker-src-child-fallback-blocked.https.sub.html [ Skip ]
@@ -3725,6 +3726,7 @@
 imported/w3c/web-platform-tests/fetch/api/policies/referrer-unsafe-url-service-worker.https.html [ Skip ]
 imported/w3c/web-platform-tests/fetch/api/request/destination [ Skip ]
 imported/w3c/web-platform-tests/fetch/cross-origin-resource-policy [ Skip ]
+imported/w3c/web-platform-tests/push-api [ Skip ]
 imported/w3c/web-platform-tests/server-timing/service_worker_idl.html [ Skip ]
 imported/w3c/web-platform-tests/service-workers [ Skip ]
 imported/w3c/web-platform-tests/html/webappapis/scripting/processing-model-2/integration-with-the-_javascript_-agent-formalism/requires-failure.https.any.serviceworker.html [ Skip ]

Modified: trunk/LayoutTests/platform/wincairo-wk1/TestExpectations (283376 => 283377)


--- trunk/LayoutTests/platform/wincairo-wk1/TestExpectations	2021-10-01 17:20:03 UTC (rev 283376)
+++ trunk/LayoutTests/platform/wincairo-wk1/TestExpectations	2021-10-01 17:30:38 UTC (rev 283377)
@@ -323,6 +323,8 @@
 
 # Skip Service Workers in WK1
 http/tests/workers/service [ Skip ]
+http/wpt/push-api [ Skip ]
+imported/w3c/web-platform-tests/push-api [ Skip ]
 http/wpt/service-workers [ Skip ]
 
 fast/css/aspect-ratio-invalidate-if-disabled.html [ Failure ]

Modified: trunk/Source/WTF/ChangeLog (283376 => 283377)


--- trunk/Source/WTF/ChangeLog	2021-10-01 17:20:03 UTC (rev 283376)
+++ trunk/Source/WTF/ChangeLog	2021-10-01 17:30:38 UTC (rev 283377)
@@ -1,3 +1,13 @@
+2021-10-01  Youenn Fablet  <[email protected]>
+
+        Add support for PushEvent
+        https://bugs.webkit.org/show_bug.cgi?id=231007
+        <rdar://problem/83707470>
+
+        Reviewed by Chris Dumez.
+
+        * Scripts/Preferences/WebPreferencesExperimental.yaml:
+
 2021-10-01  Chris Dumez  <[email protected]>
 
         Drop legacy USE(LEGACY_CFNETWORK_DOWNLOADS) code paths

Modified: trunk/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml (283376 => 283377)


--- trunk/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml	2021-10-01 17:20:03 UTC (rev 283376)
+++ trunk/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml	2021-10-01 17:30:38 UTC (rev 283377)
@@ -997,6 +997,18 @@
       "PLATFORM(MAC) || PLATFORM(IOS) || PLATFORM(GTK) || PLATFORM(WPE)": true
       default: false
 
+PushAPIEnabled:
+  type: bool
+  condition: ENABLE(SERVICE_WORKER)
+  humanReadableName: "Push API"
+  humanReadableDescription: "Enable Push API"
+  webcoreBinding: RuntimeEnabledFeatures
+  defaultValue:
+    WebCore:
+      default: false
+    WebKit:
+      default: false
+
 ReadableByteStreamAPIEnabled:
   type: bool
   humanReadableName: "ReadableByteStream"

Modified: trunk/Source/WebCore/CMakeLists.txt (283376 => 283377)


--- trunk/Source/WebCore/CMakeLists.txt	2021-10-01 17:20:03 UTC (rev 283376)
+++ trunk/Source/WebCore/CMakeLists.txt	2021-10-01 17:30:38 UTC (rev 283377)
@@ -52,6 +52,7 @@
     "${WEBCORE_DIR}/Modules/permissions"
     "${WEBCORE_DIR}/Modules/pictureinpicture"
     "${WEBCORE_DIR}/Modules/plugins"
+    "${WEBCORE_DIR}/Modules/push-api"
     "${WEBCORE_DIR}/Modules/remoteplayback"
     "${WEBCORE_DIR}/Modules/speech"
     "${WEBCORE_DIR}/Modules/storage"
@@ -209,6 +210,7 @@
     Modules/notifications
     Modules/paymentrequest
     Modules/permissions
+    Modules/push-api
     Modules/speech
     Modules/storage
     Modules/streams
@@ -496,6 +498,10 @@
     Modules/pictureinpicture/HTMLVideoElement+PictureInPicture.idl
     Modules/pictureinpicture/PictureInPictureWindow.idl
 
+    Modules/push-api/PushEvent.idl
+    Modules/push-api/PushEventInit.idl
+    Modules/push-api/PushMessageData.idl
+
     Modules/remoteplayback/RemotePlayback.idl
     Modules/remoteplayback/RemotePlaybackAvailabilityCallback.idl
 

Modified: trunk/Source/WebCore/ChangeLog (283376 => 283377)


--- trunk/Source/WebCore/ChangeLog	2021-10-01 17:20:03 UTC (rev 283376)
+++ trunk/Source/WebCore/ChangeLog	2021-10-01 17:30:38 UTC (rev 283377)
@@ -1,5 +1,41 @@
 2021-10-01  Youenn Fablet  <[email protected]>
 
+        Add support for PushEvent
+        https://bugs.webkit.org/show_bug.cgi?id=231007
+        <rdar://problem/83707470>
+
+        Reviewed by Chris Dumez.
+
+        Implement PushEvent and PushMessageData as per specification.
+        https://w3c.github.io/push-api/#pushevent-interface and
+        https://w3c.github.io/push-api/#pushmessagedata-interface.
+
+        We model PushMessageData as a Vector<uint8_t> following the spec which tells us that it has an associated byte sequence.
+
+        Put them behind a runtime flag, off by default.
+
+        Test: http/wpt/push-api/pushEvent.any.serviceworker.html
+
+        * CMakeLists.txt:
+        * DerivedSources-input.xcfilelist:
+        * DerivedSources-output.xcfilelist:
+        * DerivedSources.make:
+        * Modules/push-api/PushEvent.cpp: Added.
+        * Modules/push-api/PushEvent.h: Added.
+        * Modules/push-api/PushEvent.idl: Added.
+        * Modules/push-api/PushEventInit.h: Added.
+        * Modules/push-api/PushEventInit.idl: Added.
+        * Modules/push-api/PushMessageData.cpp: Added.
+        * Modules/push-api/PushMessageData.h: Added.
+        * Modules/push-api/PushMessageData.idl: Added.
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/WebCoreBuiltinNames.h:
+        * dom/EventNames.in:
+        * page/RuntimeEnabledFeatures.h:
+
+2021-10-01  Youenn Fablet  <[email protected]>
+
         Attribute IOSurfaces created by camera and decoders to responsible WebProcess
         https://bugs.webkit.org/show_bug.cgi?id=231075
 

Modified: trunk/Source/WebCore/DerivedSources-input.xcfilelist (283376 => 283377)


--- trunk/Source/WebCore/DerivedSources-input.xcfilelist	2021-10-01 17:20:03 UTC (rev 283376)
+++ trunk/Source/WebCore/DerivedSources-input.xcfilelist	2021-10-01 17:30:38 UTC (rev 283377)
@@ -421,6 +421,9 @@
 $(PROJECT_DIR)/Modules/plugins/QuickTimePluginReplacement.css
 $(PROJECT_DIR)/Modules/plugins/QuickTimePluginReplacement.idl
 $(PROJECT_DIR)/Modules/plugins/QuickTimePluginReplacement.js
+$(PROJECT_DIR)/Modules/push-api/PushEvent.idl
+$(PROJECT_DIR)/Modules/push-api/PushEventInit.idl
+$(PROJECT_DIR)/Modules/push-api/PushMessageData.idl
 $(PROJECT_DIR)/Modules/remoteplayback/HTMLMediaElement+RemotePlayback.idl
 $(PROJECT_DIR)/Modules/remoteplayback/RemotePlayback.idl
 $(PROJECT_DIR)/Modules/remoteplayback/RemotePlaybackAvailabilityCallback.idl
@@ -1440,6 +1443,9 @@
 $(PROJECT_DIR)/workers/service/ExtendableEventInit.idl
 $(PROJECT_DIR)/workers/service/ExtendableMessageEvent.idl
 $(PROJECT_DIR)/workers/service/FetchEvent.idl
+$(PROJECT_DIR)/workers/service/PushEvent.idl
+$(PROJECT_DIR)/workers/service/PushEventInit.idl
+$(PROJECT_DIR)/workers/service/PushMessageData.idl
 $(PROJECT_DIR)/workers/service/ServiceWorker.idl
 $(PROJECT_DIR)/workers/service/ServiceWorkerClient.idl
 $(PROJECT_DIR)/workers/service/ServiceWorkerClientType.idl

Modified: trunk/Source/WebCore/DerivedSources-output.xcfilelist (283376 => 283377)


--- trunk/Source/WebCore/DerivedSources-output.xcfilelist	2021-10-01 17:20:03 UTC (rev 283376)
+++ trunk/Source/WebCore/DerivedSources-output.xcfilelist	2021-10-01 17:30:38 UTC (rev 283377)
@@ -1695,6 +1695,12 @@
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSPublicKeyCredentialRequestOptions.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSPublicKeyCredentialType.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSPublicKeyCredentialType.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSPushEvent.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSPushEvent.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSPushEventInit.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSPushEventInit.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSPushMessageData.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSPushMessageData.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSQuickTimePluginReplacement.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSQuickTimePluginReplacement.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRTCAnswerOptions.cpp

Modified: trunk/Source/WebCore/DerivedSources.make (283376 => 283377)


--- trunk/Source/WebCore/DerivedSources.make	2021-10-01 17:20:03 UTC (rev 283376)
+++ trunk/Source/WebCore/DerivedSources.make	2021-10-01 17:30:38 UTC (rev 283377)
@@ -346,6 +346,9 @@
     $(WebCore)/Modules/pictureinpicture/HTMLVideoElement+PictureInPicture.idl \
     $(WebCore)/Modules/pictureinpicture/PictureInPictureWindow.idl \
     $(WebCore)/Modules/plugins/QuickTimePluginReplacement.idl \
+    $(WebCore)/Modules/push-api/PushEvent.idl \
+    $(WebCore)/Modules/push-api/PushEventInit.idl \
+    $(WebCore)/Modules/push-api/PushMessageData.idl \
     $(WebCore)/Modules/remoteplayback/HTMLMediaElement+RemotePlayback.idl \
     $(WebCore)/Modules/remoteplayback/RemotePlayback.idl \
     $(WebCore)/Modules/remoteplayback/RemotePlaybackAvailabilityCallback.idl \

Added: trunk/Source/WebCore/Modules/push-api/PushEvent.cpp (0 => 283377)


--- trunk/Source/WebCore/Modules/push-api/PushEvent.cpp	                        (rev 0)
+++ trunk/Source/WebCore/Modules/push-api/PushEvent.cpp	2021-10-01 17:30:38 UTC (rev 283377)
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "PushEvent.h"
+
+#if ENABLE(SERVICE_WORKER)
+
+#include "PushMessageData.h"
+#include <_javascript_Core/JSArrayBuffer.h>
+#include <_javascript_Core/JSArrayBufferView.h>
+#include <_javascript_Core/JSCInlines.h>
+#include <wtf/IsoMallocInlines.h>
+
+namespace WebCore {
+
+WTF_MAKE_ISO_ALLOCATED_IMPL(PushEvent);
+
+static Vector<uint8_t> dataFromPushMessageDataInit(PushMessageDataInit& data)
+{
+    return WTF::switchOn(data, [](RefPtr<JSC::ArrayBuffer>& value) -> Vector<uint8_t> {
+        if (!value)
+            return { };
+        return { reinterpret_cast<const uint8_t*>(value->data()), value->byteLength() };
+    }, [](RefPtr<JSC::ArrayBufferView>& value) -> Vector<uint8_t> {
+        if (!value)
+            return { };
+        return { reinterpret_cast<const uint8_t*>(value->baseAddress()), value->byteLength() };
+    }, [](String& value) -> Vector<uint8_t> {
+        auto utf8 = value.utf8();
+        return Vector<uint8_t> { reinterpret_cast<const uint8_t*>(utf8.data()), utf8.length() };
+    });
+}
+
+Ref<PushEvent> PushEvent::create(const AtomString& type, PushEventInit&& initializer, IsTrusted isTrusted)
+{
+    std::optional<Vector<uint8_t>> data;
+    if (initializer.data)
+        data = ""
+    return create(type, WTFMove(initializer), WTFMove(data), isTrusted);
+}
+
+Ref<PushEvent> PushEvent::create(const AtomString& type, ExtendableEventInit&& initializer, std::optional<Vector<uint8_t>>&& data, IsTrusted isTrusted)
+{
+    return adoptRef(*new PushEvent(type, WTFMove(initializer), WTFMove(data), isTrusted));
+}
+
+static inline RefPtr<PushMessageData> pushMessageDataFromOptionalVector(std::optional<Vector<uint8_t>>&& data)
+{
+    if (!data)
+        return nullptr;
+    return PushMessageData::create(WTFMove(*data));
+}
+
+PushEvent::PushEvent(const AtomString& type, ExtendableEventInit&& eventInit, std::optional<Vector<uint8_t>>&& data, IsTrusted isTrusted)
+    : ExtendableEvent(type, WTFMove(eventInit), isTrusted)
+    , m_data(pushMessageDataFromOptionalVector(WTFMove(data)))
+{
+}
+
+PushEvent::~PushEvent()
+{
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SERVICE_WORKER)

Added: trunk/Source/WebCore/Modules/push-api/PushEvent.h (0 => 283377)


--- trunk/Source/WebCore/Modules/push-api/PushEvent.h	                        (rev 0)
+++ trunk/Source/WebCore/Modules/push-api/PushEvent.h	2021-10-01 17:30:38 UTC (rev 283377)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(SERVICE_WORKER)
+
+#include "ExtendableEvent.h"
+#include "PushEventInit.h"
+
+namespace WebCore {
+
+class PushMessageData;
+
+class PushEvent final : public ExtendableEvent {
+    WTF_MAKE_ISO_ALLOCATED(PushEvent);
+public:
+    static Ref<PushEvent> create(const AtomString&, PushEventInit&&, IsTrusted = IsTrusted::No);
+    static Ref<PushEvent> create(const AtomString&, ExtendableEventInit&&, std::optional<Vector<uint8_t>>&&, IsTrusted);
+    ~PushEvent();
+
+    EventInterface eventInterface() const final { return PushEventInterfaceType; }
+    PushMessageData* data() { return m_data.get(); }
+
+private:
+    PushEvent(const AtomString&, ExtendableEventInit&&, std::optional<Vector<uint8_t>>&&, IsTrusted);
+
+    RefPtr<PushMessageData> m_data;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SERVICE_WORKER)

Added: trunk/Source/WebCore/Modules/push-api/PushEvent.idl (0 => 283377)


--- trunk/Source/WebCore/Modules/push-api/PushEvent.idl	                        (rev 0)
+++ trunk/Source/WebCore/Modules/push-api/PushEvent.idl	2021-10-01 17:30:38 UTC (rev 283377)
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+    Conditional=SERVICE_WORKER,
+    EnabledAtRuntime=PushAPI,
+    ExportMacro=WEBCORE_EXPORT,
+    Exposed=ServiceWorker,
+    JSGenerateToNativeObject,
+    SecureContext
+] interface PushEvent : ExtendableEvent {
+    constructor(DOMString type, optional PushEventInit eventInitDict);
+    readonly attribute PushMessageData? data;
+};

Added: trunk/Source/WebCore/Modules/push-api/PushEventInit.h (0 => 283377)


--- trunk/Source/WebCore/Modules/push-api/PushEventInit.h	                        (rev 0)
+++ trunk/Source/WebCore/Modules/push-api/PushEventInit.h	2021-10-01 17:30:38 UTC (rev 283377)
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(SERVICE_WORKER)
+
+#include "ExtendableEventInit.h"
+#include <_javascript_Core/ArrayBuffer.h>
+#include <wtf/Variant.h>
+
+namespace WebCore {
+
+using PushMessageDataInit = Variant<RefPtr<JSC::ArrayBufferView>, RefPtr<JSC::ArrayBuffer>, String>;
+
+struct PushEventInit : ExtendableEventInit {
+    std::optional<PushMessageDataInit> data;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SERVICE_WORKER)

Added: trunk/Source/WebCore/Modules/push-api/PushEventInit.idl (0 => 283377)


--- trunk/Source/WebCore/Modules/push-api/PushEventInit.idl	                        (rev 0)
+++ trunk/Source/WebCore/Modules/push-api/PushEventInit.idl	2021-10-01 17:30:38 UTC (rev 283377)
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+typedef (BufferSource or USVString) PushMessageDataInit;
+
+[
+    Conditional=SERVICE_WORKER
+] dictionary PushEventInit : ExtendableEventInit {
+    PushMessageDataInit data;
+};

Added: trunk/Source/WebCore/Modules/push-api/PushMessageData.cpp (0 => 283377)


--- trunk/Source/WebCore/Modules/push-api/PushMessageData.cpp	                        (rev 0)
+++ trunk/Source/WebCore/Modules/push-api/PushMessageData.cpp	2021-10-01 17:30:38 UTC (rev 283377)
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "PushMessageData.h"
+
+#if ENABLE(SERVICE_WORKER)
+
+#include "Blob.h"
+#include "JSDOMGlobalObject.h"
+#include "TextResourceDecoder.h"
+#include <_javascript_Core/JSLock.h>
+#include <_javascript_Core/JSONObject.h>
+#include <wtf/IsoMallocInlines.h>
+
+namespace WebCore {
+
+WTF_MAKE_ISO_ALLOCATED_IMPL(PushMessageData);
+
+ExceptionOr<RefPtr<JSC::ArrayBuffer>> PushMessageData::arrayBuffer()
+{
+    auto buffer = ArrayBuffer::tryCreate(m_data.data(), m_data.size());
+    if (!buffer)
+        return Exception { OutOfMemoryError };
+    return buffer;
+}
+
+RefPtr<Blob> PushMessageData::blob(ScriptExecutionContext& context)
+{
+    return Blob::create(&context, Vector<uint8_t> { m_data }, { });
+}
+
+ExceptionOr<JSC::JSValue> PushMessageData::json(JSDOMGlobalObject& globalObject)
+{
+    JSC::JSLockHolder lock(&globalObject);
+
+    auto value = JSC::JSONParse(&globalObject, text());
+    if (!value)
+        return Exception { SyntaxError, "JSON parsing failed"_s };
+
+    return value;
+}
+
+String PushMessageData::text()
+{
+    return TextResourceDecoder::textFromUTF8(m_data.data(), m_data.size());
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SERVICE_WORKER)

Added: trunk/Source/WebCore/Modules/push-api/PushMessageData.h (0 => 283377)


--- trunk/Source/WebCore/Modules/push-api/PushMessageData.h	                        (rev 0)
+++ trunk/Source/WebCore/Modules/push-api/PushMessageData.h	2021-10-01 17:30:38 UTC (rev 283377)
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(SERVICE_WORKER)
+
+#include "ExceptionOr.h"
+#include <_javascript_Core/ArrayBuffer.h>
+#include <_javascript_Core/JSCJSValue.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+class Blob;
+class JSDOMGlobalObject;
+class ScriptExecutionContext;
+
+class PushMessageData final : public RefCounted<PushMessageData> {
+    WTF_MAKE_ISO_ALLOCATED(PushMessageData);
+public:
+    static Ref<PushMessageData> create(Vector<uint8_t>&& data) { return adoptRef(*new PushMessageData(WTFMove(data))); }
+
+    ExceptionOr<RefPtr<JSC::ArrayBuffer>> arrayBuffer();
+    RefPtr<Blob> blob(ScriptExecutionContext&);
+    ExceptionOr<JSC::JSValue> json(JSDOMGlobalObject&);
+    String text();
+
+private:
+    explicit PushMessageData(Vector<uint8_t>&&);
+
+    Vector<uint8_t> m_data;
+};
+
+inline PushMessageData::PushMessageData(Vector<uint8_t>&& data)
+    : m_data(WTFMove(data))
+{
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SERVICE_WORKER)

Added: trunk/Source/WebCore/Modules/push-api/PushMessageData.idl (0 => 283377)


--- trunk/Source/WebCore/Modules/push-api/PushMessageData.idl	                        (rev 0)
+++ trunk/Source/WebCore/Modules/push-api/PushMessageData.idl	2021-10-01 17:30:38 UTC (rev 283377)
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+    Conditional=SERVICE_WORKER,
+    EnabledAtRuntime=PushAPI,
+    Exposed=ServiceWorker,
+    ImplementationLacksVTable,
+] interface PushMessageData {
+    ArrayBuffer arrayBuffer();
+    [CallWith=ScriptExecutionContext] Blob blob();
+    [CallWith=GlobalObject] any json();
+    USVString text();
+};

Modified: trunk/Source/WebCore/Sources.txt (283376 => 283377)


--- trunk/Source/WebCore/Sources.txt	2021-10-01 17:20:03 UTC (rev 283376)
+++ trunk/Source/WebCore/Sources.txt	2021-10-01 17:30:38 UTC (rev 283377)
@@ -219,6 +219,8 @@
 Modules/pictureinpicture/EnterPictureInPictureEvent.cpp
 Modules/pictureinpicture/HTMLVideoElementPictureInPicture.cpp
 Modules/pictureinpicture/PictureInPictureWindow.cpp
+Modules/push-api/PushEvent.cpp
+Modules/push-api/PushMessageData.cpp
 Modules/remoteplayback/RemotePlayback.cpp
 Modules/speech/SpeechRecognition.cpp
 Modules/speech/SpeechRecognitionAlternative.cpp
@@ -3352,6 +3354,9 @@
 JSPublicKeyCredentialDescriptor.cpp
 JSPublicKeyCredentialRequestOptions.cpp
 JSPublicKeyCredentialType.cpp
+JSPushEvent.cpp
+JSPushEventInit.cpp
+JSPushMessageData.cpp
 JSRTCAnswerOptions.cpp
 JSRTCCertificate.cpp
 JSRTCConfiguration.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (283376 => 283377)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2021-10-01 17:20:03 UTC (rev 283376)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2021-10-01 17:30:38 UTC (rev 283377)
@@ -1177,6 +1177,8 @@
 		418938B22429F9B4007FDC41 /* RetrieveRecordsOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 418938AF2429F9AB007FDC41 /* RetrieveRecordsOptions.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		418A06D0133C04D500CD379C /* EventDispatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 418A06CE133C04D500CD379C /* EventDispatcher.h */; };
 		418F88050FF957AF0080F045 /* JSAbstractWorker.h in Headers */ = {isa = PBXBuildFile; fileRef = 418F88030FF957AE0080F045 /* JSAbstractWorker.h */; };
+		418FCBC12706E4FB00F96ECA /* PushEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 418FCBBD2706E4F700F96ECA /* PushEvent.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		418FCBC22706E50100F96ECA /* PushEventInit.h in Headers */ = {isa = PBXBuildFile; fileRef = 418FCBBF2706E4F800F96ECA /* PushEventInit.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		4190F3A524A0B4EE00531C57 /* FrameRateMonitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 4190F3A3249D152800531C57 /* FrameRateMonitor.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		419242492127B93E00634FCF /* RealtimeOutgoingVideoSourceCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 419242472127B7CC00634FCF /* RealtimeOutgoingVideoSourceCocoa.mm */; };
 		419ACF921F97E7DA009F1A83 /* ServiceWorkerFetch.h in Headers */ = {isa = PBXBuildFile; fileRef = 419ACF8E1F97E7D5009F1A83 /* ServiceWorkerFetch.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -8103,6 +8105,14 @@
 		418C395F1C8F0AAB0051C8A3 /* ReadableStreamDefaultController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReadableStreamDefaultController.h; sourceTree = "<group>"; };
 		418F88020FF957AE0080F045 /* JSAbstractWorker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAbstractWorker.cpp; sourceTree = "<group>"; };
 		418F88030FF957AE0080F045 /* JSAbstractWorker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSAbstractWorker.h; sourceTree = "<group>"; };
+		418FCBBA2706E4F500F96ECA /* PushMessageData.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = PushMessageData.idl; sourceTree = "<group>"; };
+		418FCBBB2706E4F600F96ECA /* PushEvent.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = PushEvent.cpp; sourceTree = "<group>"; };
+		418FCBBC2706E4F600F96ECA /* PushMessageData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PushMessageData.h; sourceTree = "<group>"; };
+		418FCBBD2706E4F700F96ECA /* PushEvent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PushEvent.h; sourceTree = "<group>"; };
+		418FCBBE2706E4F700F96ECA /* PushMessageData.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = PushMessageData.cpp; sourceTree = "<group>"; };
+		418FCBBF2706E4F800F96ECA /* PushEventInit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PushEventInit.h; sourceTree = "<group>"; };
+		418FCBC02706E4F800F96ECA /* PushEvent.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = PushEvent.idl; sourceTree = "<group>"; };
+		418FCBC32706E62C00F96ECA /* PushEventInit.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = PushEventInit.idl; sourceTree = "<group>"; };
 		4190F3A1249D152700531C57 /* FrameRateMonitor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FrameRateMonitor.cpp; sourceTree = "<group>"; };
 		4190F3A3249D152800531C57 /* FrameRateMonitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FrameRateMonitor.h; sourceTree = "<group>"; };
 		419242472127B7CC00634FCF /* RealtimeOutgoingVideoSourceCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RealtimeOutgoingVideoSourceCocoa.mm; sourceTree = "<group>"; };
@@ -19862,6 +19872,21 @@
 			path = js;
 			sourceTree = "<group>";
 		};
+		418FCBB82706E4BD00F96ECA /* push-api */ = {
+			isa = PBXGroup;
+			children = (
+				418FCBBB2706E4F600F96ECA /* PushEvent.cpp */,
+				418FCBBD2706E4F700F96ECA /* PushEvent.h */,
+				418FCBC02706E4F800F96ECA /* PushEvent.idl */,
+				418FCBBF2706E4F800F96ECA /* PushEventInit.h */,
+				418FCBC32706E62C00F96ECA /* PushEventInit.idl */,
+				418FCBBE2706E4F700F96ECA /* PushMessageData.cpp */,
+				418FCBBC2706E4F600F96ECA /* PushMessageData.h */,
+				418FCBBA2706E4F500F96ECA /* PushMessageData.idl */,
+			);
+			path = "push-api";
+			sourceTree = "<group>";
+		};
 		41A023EA1A39DB7900F722CF /* streams */ = {
 			isa = PBXGroup;
 			children = (
@@ -24241,6 +24266,7 @@
 				93B0A64226CDC57400AA21E4 /* permissions */,
 				1DEF06A2233C32DB00EE228D /* pictureinpicture */,
 				072AE1DE183C0513000A5988 /* plugins */,
+				418FCBB82706E4BD00F96ECA /* push-api */,
 				CDC312E022FCD0B0001204EC /* remoteplayback */,
 				AA2A5AB716A485A400975A25 /* speech */,
 				93085DB326E0068E000EC6A7 /* storage */,
@@ -34631,6 +34657,8 @@
 				57303BEB20097F4000355965 /* PublicKeyCredentialType.h in Headers */,
 				0081FF0016B0A2D3008AAA7A /* PublicSuffix.h in Headers */,
 				10FB084B14E15C7E00A3DB98 /* PublicURLManager.h in Headers */,
+				418FCBC12706E4FB00F96ECA /* PushEvent.h in Headers */,
+				418FCBC22706E50100F96ECA /* PushEventInit.h in Headers */,
 				83D511F6250C1CBF002EDC51 /* PushPullFIFO.h in Headers */,
 				550A0BCA085F6039007353D6 /* QualifiedName.h in Headers */,
 				83C1F5941EDF69D300410D27 /* QualifiedNameCache.h in Headers */,

Modified: trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h (283376 => 283377)


--- trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h	2021-10-01 17:20:03 UTC (rev 283376)
+++ trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h	2021-10-01 17:30:38 UTC (rev 283377)
@@ -207,6 +207,8 @@
     macro(Permissions) \
     macro(PointerEvent) \
     macro(PublicKeyCredential) \
+    macro(PushEvent) \
+    macro(PushMessageData) \
     macro(ResizeObserver) \
     macro(ResizeObserverEntry) \
     macro(RTCCertificate) \

Modified: trunk/Source/WebCore/dom/EventNames.in (283376 => 283377)


--- trunk/Source/WebCore/dom/EventNames.in	2021-10-01 17:20:03 UTC (rev 283376)
+++ trunk/Source/WebCore/dom/EventNames.in	2021-10-01 17:30:38 UTC (rev 283377)
@@ -36,6 +36,7 @@
 PopStateEvent
 ProgressEvent
 PromiseRejectionEvent
+PushEvent conditional=SERVICE_WORKER
 SubmitEvent
 TextEvent
 TransitionEvent

Modified: trunk/Source/WebCore/page/RuntimeEnabledFeatures.h (283376 => 283377)


--- trunk/Source/WebCore/page/RuntimeEnabledFeatures.h	2021-10-01 17:20:03 UTC (rev 283376)
+++ trunk/Source/WebCore/page/RuntimeEnabledFeatures.h	2021-10-01 17:30:38 UTC (rev 283377)
@@ -180,6 +180,8 @@
     bool transformStreamAPIEnabled() const { return m_isTransformStreamAPIEnabled; }
 
 #if ENABLE(SERVICE_WORKER)
+    bool pushAPIEnabled() const { return m_pushAPIEnabled; }
+    void setPushAPIEnabled(bool isEnabled) { m_pushAPIEnabled = isEnabled; }
     bool serviceWorkerEnabled() const { return m_serviceWorkerEnabled; }
     void setServiceWorkerEnabled(bool isEnabled) { m_serviceWorkerEnabled = isEnabled; }
 #endif
@@ -336,6 +338,7 @@
     bool m_isTransformStreamAPIEnabled { false };
 
 #if ENABLE(SERVICE_WORKER)
+    bool m_pushAPIEnabled { false };
     bool m_serviceWorkerEnabled { false };
 #endif
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to