diff --git a/index.html b/index.html index 7016956..2a41b64 100644 --- a/index.html +++ b/index.html @@ -164,6 +164,281 @@
+ A declarative push message is a [=push message=] whose data is encoded in such + a way that it results in some automatic action on behalf of the web application. E.g., + the creation and display of a notification. +
++ A [=declarative push message=] is a JSON document that contains the instructions to + create and display a notification. +
++ { + "web_push": 9001, + "notification": { + "title": "Watch the new season of Return of the Example now!", + "lang": "en-US", + "dir": "ltr", + "body": "The examples are going to great lengths once more.", + "url": "https://tv.example/return" + } + } ++
+ A [=declarative push message=] has the following members: +
+web_push
(required)
+ + An integer that must be 9001. Used to disambiguate a [=declarative push message=] + from other JSON documents. +
+notification
(required)
+ + A JSON object consisting of the following members, many being analogous to + Notifications API features. +
+title
(required)
+ + A string. +
+dir
+
+ "auto
", "ltr
", or "rtl
".
+
lang
+ + A string that holds a language tag. +
+body
+ + A string. +
+url
(required)
+ + A string that holds a URL. +
+tag
+ + A string. +
+icon
+ + A string that holds a URL. +
+silent
+ + A boolean. +
+data
+ + Any JSON value. +
+mutable
+
+ A boolean. When true causes a pushnotification
to be dispatched to
+ a service worker (if any).
+
app_badge
+ + An integer in the range 0 to 9223372036854775807, inclusive. +
++ A declarative push message parser result is a [=/tuple=] consisting of a + notification (a + [=/notification=]), mutable + notification (a boolean), and an app badge (null or an integer). +
++ The declarative push message parser given a [=/byte sequence=] + bytes, [=/origin=] origin, [=/URL=] baseURL, and + {{EpochTimestamp}} fallbackTimestamp runs these steps. They return failure + or a [=/declarative push message parser result=]. +
++ Let message be the result of [=parsing JSON bytes to an Infra value=] + given bytes. If that throws an exception, then return failure. +
++ If message is not a [=/map=], then return failure. +
++ If message["`web_push`"] [=map/does not exist=], then return failure. +
++ If message["`web_push`"] is not 9001, then return failure. +
++ If message["`notification`"] [=map/does not exist=], then return + failure. +
++ Let notificationInput be message["`notification`"]. +
++ If notificationInput is not a [=/map=], then return failure. +
++ If notificationInput["`title`"] [=map/does not exist=], then return + failure. +
++ If notificationInput["`title`"] is not a string, then return failure. +
++ Let title be notificationInput["`title`"]. +
++ Let mutable be false. +
++ If notificationInput["`mutable`"] [=map/exists=] and + notificationInput["`mutable`"] is a boolean, then set mutable + to notificationInput["`mutable`"]. +
++ Let jsNotificationInput be the result of running convert an Infra + value to a JSON-compatible JavaScript value given notificationInput. +
++ Let notificationOptions be the result of converting jsNotificationInput to the + dictionary type {{NotificationOptions}}. If this throws an exception, then return + failure. +
++ Let notification be the result of creating a notification given + title, notificationOptions, origin, + baseURL, and fallbackTimestamp. If this throws an exception, + then return failure. +
++ If notification's [=notification/URL=] is null, then return failure. +
++ Let appBadge be null. +
++ If message["`app_badge`"] [=map/exists=] and + message["`app_badge`"] is an integer in the range 0 to + 9223372036854775807, inclusive, then set appBadge to + message["`app_badge`"]. +
++ Return (notification, mutable, appBadge). +
++ [Exposed=ServiceWorker, SecureContext] + interface PushNotificationEvent : ExtendableEvent { + constructor(DOMString type, optional PushNotificationEventInit eventInitDict = {}); + readonly attribute Notification notification; + readonly attribute unsigned long long? appBadge; + }; + + dictionary PushNotificationEventInit : ExtendableEventInit { + required Notification notification; + unsigned long long? appBadge = null; + }; ++
+ The notification attribute must return the value it was initialized with. +
++ The appBadge attribute must return the value it was initialized with. +
++ A `push` event is not fired for a push message that was not successfully + decrypted using the key pair associated with the push subscription. +
+ If |bytes| is non-null: +
++ Let |baseURL| be |registration|'s [=service worker registration/scope URL=]. +
++ Let |origin| be |baseURL|'s [=url/origin=]. +
++ Let |fallbackTimestamp| be w3c/hr-time #165. +
++ Let |declarativeResult| be the result of running the [=/declarative push message + parser=] given |bytes|, |origin|, |baseURL|, and |fallbackTimestamp|. +
++ If |declarativeResult| is not failure: +
++ Let |notification| be |declarativeResult|'s [=declarative push message parser + result/notification=]. +
++ Set |notification|'s [=notification/service worker registration=] to + |registration|. +
++ If |declarativeResult|'s [=declarative push message parser result/mutable + notification=] is true: +
++ [=/Fire a functional event=] named "`pushnotification`" using + {{PushNotificationEvent}} on |registration| with the following + properties: +
++ Wait for all of the promises in the [=ExtendableEvent/extend lifetime + promises=] of the dispatched event to resolve. +
++ If a notification has been shown through {{showNotification()}} at this + point, then abort these steps. +
++ Run the [=notification show steps=] given |notification|. +
++ w3c/badging #111 +
++ Abort these steps. +
+