@@ -42,8 +42,9 @@ IDL, Service Workers, URL, and Vibration API Standards.
42
42
<p> A <dfn id=concept-notification>notification</dfn> is an abstract
43
43
representation of something that happened, such as the delivery of a message.
44
44
45
- <p> A <a>notification</a> <em> can</em> have an associated
46
- <dfn for=notification id=service-worker-registration>service worker registration</dfn> .
45
+ <p> A <a>notification</a> has an associated
46
+ <dfn for=notification id=service-worker-registration>service worker registration</dfn> (null
47
+ or a <a for=/>service worker registration</a> ). It is initially null.
47
48
48
49
<p> A <a>notification</a> has an associated
49
50
<dfn for=notification id=concept-title>title</dfn> which is a string.
@@ -156,35 +157,45 @@ corners or painting it in a specific color. Developers are encouraged to use an
156
157
such cases gracefully and does not lose important information through, e.g., loss of color or
157
158
clipped corners.
158
159
159
- <p> A <dfn>non-persistent notification</dfn> is a
160
- <a>notification</a> without an associated
161
- <a for=notification>service worker registration</a> .
160
+ <p> A <dfn>non-persistent notification</dfn> is a <a>notification</a> whose
161
+ <a for=notification>service worker registration</a> is null.
162
162
163
- <p> A <dfn>persistent notification</dfn> is a
164
- <a>notification</a> with an associated
165
- <a for=notification>service worker registration</a> .
163
+ <p> A <dfn>persistent notification</dfn> is a <a>notification</a> whose
164
+ <a for=notification>service worker registration</a> is non-null.
166
165
167
166
<!-- XXX https://html.spec.whatwg.org/#fingerprinting-vector -->
168
167
169
168
<hr>
170
169
171
- <p> To <dfn lt="create a notification|creating a notification">create a notification</dfn> , given a
172
- string <var> title </var> , {{NotificationOptions}} <a for=/>dictionary</a> <var> options </var> ,
173
- <a for=/>environment settings object </a> <var> settings </var> , and optionally a
174
- {{ServiceWorkerRegistration}} object <var> serviceWorkerRegistration </var> , run these steps :
170
+ <div algorithm>
171
+ <p> To <dfn>create a notification with a settings object</dfn> , given a string <var> title </var> ,
172
+ {{NotificationOptions}} <a for=/>dictionary </a> <var> options </var> , and
173
+ <a for=/>environment settings object</a> <var> settings </var> :
175
174
176
175
<ol>
177
- <li><p> Let <var> notification</var> be a new <a>notification</a> .
176
+ <li><p> Let <var> origin</var> be <var> settings</var> 's
177
+ <a for="environment settings object">origin</a> .
178
+
179
+ <li><p> Let <var> baseURL</var> be <var> settings</var> 's
180
+ <a for="environment settings object">API base URL</a> .
178
181
179
- <li><p> If a <var> serviceWorkerRegistration</var> was provided, then set <var> notification</var> 's
180
- <a for=notification>service worker registration</a> to <var> serviceWorkerRegistration</var> .
182
+ <li><p> Let <var> fallbackTimestamp</var> be the number of milliseconds from the <a>Unix epoch</a> to
183
+ <var> settings</var> 's <a for="environment settings object">current wall time</a> , rounded to the
184
+ nearest integer.
181
185
182
- <li>
183
- <p> If a <var> serviceWorkerRegistration </var> was not provided and
184
- <var> options </var> ["{{NotificationOptions/actions}}"] is not <a for=list>empty</a> , then
185
- <a>throw</a> a {{TypeError}} .
186
+ <li><p> Return the result of <a>creating a notification</a> given <var> title </var> ,
187
+ <var> options </var> , <var> origin </var> , <var> baseURL </var> , and <var> fallbackTimestamp </var> .
188
+ </ol>
189
+ </div>
186
190
187
- <p class=note> <a>Actions</a> are only currently supported for <a>persistent notifications</a> .
191
+ <div algorithm>
192
+ <p> To <dfn export>create a notification</dfn> , given a string <var> title</var> ,
193
+ {{NotificationOptions}} <a for=/>dictionary</a> <var> options</var> , an <a for=/>origin</a>
194
+ <var> origin</var> , a <a for=/>URL</a> <var> baseURL</var> , and an {{EpochTimeStamp}}
195
+ <var> fallbackTimestamp</var> :
196
+
197
+ <ol>
198
+ <li><p> Let <var> notification</var> be a new <a>notification</a> .
188
199
189
200
<li><p> If <var> options</var> ["{{NotificationOptions/silent}}"] is true and
190
201
<var> options</var> ["{{NotificationOptions/vibrate}}"] <a for=map>exists</a> , then <a>throw</a> a
@@ -205,18 +216,14 @@ string <var>title</var>, {{NotificationOptions}} <a for=/>dictionary</a> <var>op
205
216
<li><p> Set <var> notification</var> 's <a for=notification>language</a> to
206
217
<var> options</var> ["{{NotificationOptions/lang}}"] .
207
218
208
- <li><p> Set <var> notification</var> 's <a for=notification>origin</a> to <var>settings</var>' s
209
- <a for="environment settings object">origin</a> .
219
+ <li><p> Set <var> notification</var> 's <a for=notification>origin</a> to <var> origin</var> .
210
220
211
221
<li><p> Set <var> notification</var> 's <a for=notification>body</a> to
212
222
<var> options</var> ["{{NotificationOptions/body}}"] .
213
223
214
224
<li><p> Set <var> notification</var> 's <a for=notification>tag</a> to
215
225
<var> options</var> ["{{NotificationOptions/tag}}"] .
216
226
217
- <li><p> Let <var> baseURL</var> be <var> settings</var> 's
218
- <a for="environment settings object">API base URL</a> .
219
-
220
227
<li><p> If <var> options</var> ["{{NotificationOptions/image}}"] <a for=map>exists</a> , then
221
228
<a lt="URL parser">parse</a> it using <var> baseURL</var> , and if that does not return failure, set
222
229
<var> notification</var> 's <a>image URL</a> to the return value. (Otherwise
@@ -238,9 +245,7 @@ string <var>title</var>, {{NotificationOptions}} <a for=/>dictionary</a> <var>op
238
245
239
246
<li><p> If <var> options</var> ["{{NotificationOptions/timestamp}}"] <a for=map>exists</a> , then set
240
247
<var> notification</var> 's <a for=notification>timestamp</a> to the value. Otherwise, set
241
- <var> notification</var> 's <a for=notification>timestamp</a> to the number of milliseconds from the
242
- <a>Unix epoch</a> to <var> settings</var> 's
243
- <a for="environment settings object">current wall time</a> , rounded to the nearest integer.
248
+ <var> notification</var> 's <a for=notification>timestamp</a> to <var> fallbackTimestamp</var> .
244
249
245
250
<li><p> Set <var> notification</var> 's <a for=notification>renotify preference</a> to
246
251
<var> options</var> ["{{NotificationOptions/renotify}}"] .
@@ -276,6 +281,7 @@ string <var>title</var>, {{NotificationOptions}} <a for=/>dictionary</a> <var>op
276
281
277
282
<li><p> Return <var> notification</var> .
278
283
</ol>
284
+ </div>
279
285
280
286
281
287
<h3 id=lifetime-and-ui-integrations>Lifetime and UI integration</h3>
@@ -692,6 +698,7 @@ object and can be created through {{Notification}}'s
692
698
693
699
<h3 id=constructors>Constructors</h3>
694
700
701
+ <div algorithm>
695
702
<p> The
696
703
<dfn constructor for=Notification lt="Notification(title, options)"><code>new Notification(<var>title</var>, <var>options</var>)</code></dfn>
697
704
constructor steps are:
@@ -700,8 +707,15 @@ constructor steps are:
700
707
<li><p> If <a>this</a> 's <a>relevant global object</a> is a {{ServiceWorkerGlobalScope}} object,
701
708
then <a>throw</a> a {{TypeError}} .
702
709
703
- <li><p> Let <var> notification</var> be the result of <a>creating a notification</a> given
704
- <var> title</var> , <var> options</var> , and <a>this</a> 's <a>relevant settings object</a> .
710
+ <li>
711
+ <p> If <var> options</var> ["{{NotificationOptions/actions}}"] is not <a for=list>empty</a> , then
712
+ <a>throw</a> a {{TypeError}} .
713
+
714
+ <p class=note> <a>Actions</a> are only supported for <a>persistent notifications</a> .
715
+
716
+ <li><p> Let <var> notification</var> be the result of
717
+ <a>creating a notification with a settings object</a> given <var> title</var> , <var> options</var> ,
718
+ and <a>this</a> 's <a>relevant settings object</a> .
705
719
706
720
<li><p> Associate <a>this</a> with <var> notification</var> .
707
721
@@ -718,12 +732,15 @@ constructor steps are:
718
732
<li><p> Run the <a>show steps</a> for <var> notification</var> .
719
733
</ol>
720
734
</ol>
735
+ </div>
721
736
722
737
723
738
<h3 id=static-members>Static members</h3>
724
739
740
+ <div algorithm>
725
741
<p> The static <dfn attribute for=Notification><code>permission</code></dfn> getter steps are to
726
742
return the result of <a>getting the notifications permission state</a> .
743
+ </div>
727
744
728
745
<div class=note>
729
746
<p> If you edit standards please refrain from copying the above. Synchronous permissions are like
@@ -740,6 +757,7 @@ return the result of <a>getting the notifications permission state</a>.
740
757
</pre>
741
758
</div>
742
759
760
+ <div algorithm>
743
761
<p> The static
744
762
<dfn method for=Notification><code>requestPermission(<var>deprecatedCallback</var>)</code></dfn>
745
763
method steps are:
@@ -770,6 +788,7 @@ method steps are:
770
788
771
789
<li><p> Return <var> promise</var> .
772
790
</ol>
791
+ </div>
773
792
774
793
<p class="warning"> Notifications are the one instance thus far where asking the end user upfront
775
794
makes sense. Specifications for other APIs should not use this pattern and instead employ one of the
@@ -1029,7 +1048,9 @@ partial interface ServiceWorkerGlobalScope {
1029
1048
};
1030
1049
</pre>
1031
1050
1032
- <p> The <dfn method for=ServiceWorkerRegistration><code>showNotification(title, options)</code></dfn>
1051
+ <div algorithm>
1052
+ <p> The
1053
+ <dfn method for=ServiceWorkerRegistration><code>showNotification(<var>title</var>, <var>options</var>)</code></dfn>
1033
1054
method steps are:
1034
1055
1035
1056
<ol>
@@ -1042,12 +1063,13 @@ method steps are:
1042
1063
<!-- We might have to throw directly here and below, see
1043
1064
https://github.com/web-platform-tests/wpt/pull/24601 -->
1044
1065
1045
- <li><p> Let <var> serviceWorkerRegistration</var> be <a>this</a> .
1066
+ <li><p> Let <var> notification</var> be the result of
1067
+ <a>creating a notification with a settings object</a> given <var> title</var> , <var> options</var> ,
1068
+ and <a>this</a> 's <a>relevant settings object</a> . If this threw an exception, then
1069
+ <a for=/>reject</a> <var> promise</var> with that exception and return <var> promise</var> .
1046
1070
1047
- <li><p> Let <var> notification</var> be the result of <a>creating a notification</a> given
1048
- <var> title</var> , <var> options</var> , <a>this</a> 's <a>relevant settings object</a> , and
1049
- <var> serviceWorkerRegistration</var> . If this threw an exception, then <a for=/>reject</a>
1050
- <var> promise</var> with that exception and return <var> promise</var> .
1071
+ <li><p> Set <var> notification</var> 's <a for=notification>service worker registration</a> to
1072
+ <a>this</a> .
1051
1073
1052
1074
<li>
1053
1075
<p> Run these steps <a>in parallel</a> :
@@ -1068,7 +1090,9 @@ method steps are:
1068
1090
1069
1091
<li><p> Return <var> promise</var> .
1070
1092
</ol>
1093
+ </div>
1071
1094
1095
+ <div algorithm>
1072
1096
<p> The
1073
1097
<dfn method for=ServiceWorkerRegistration><code>getNotifications(<var>filter</var>)</code></dfn>
1074
1098
method steps are:
@@ -1116,26 +1140,34 @@ method steps are:
1116
1140
1117
1141
<p class=note> This method returns zero or more new {{Notification}} objects which might represent
1118
1142
the same underlying <a>notification</a> of {{Notification}} objects already in existence.
1143
+ </div>
1119
1144
1120
1145
<hr>
1121
1146
1122
- <p> To <dfn>fire a service worker notification event</dfn> named <var> name</var> given
1123
- <var> notification</var> (a <a>notification</a> ), and an optional <var> action</var> (a DOMString,
1124
- defaulting to the empty string), <a>Fire Functional Event</a> <var> name</var> using
1125
- {{NotificationEvent}} on <var> notification</var> 's
1126
- <a for=notification>service worker registration</a> with the following properties:
1147
+ <div algorithm>
1148
+ <p> To <dfn>fire a service worker notification event</dfn> named <var> name</var> given a
1149
+ <a for=/>notification</a> <var> notification</var> , and an optional string <var> action</var> (default
1150
+ the empty string): run <a>Fire Functional Event</a> given <var> name</var> , {{NotificationEvent}} ,
1151
+ <var> notification</var> 's <a for=notification>service worker registration</a> , and the following
1152
+ initialization:
1127
1153
1128
1154
<dl>
1129
1155
<dt> {{NotificationEvent/notification}}
1130
1156
<dd> A new {{Notification}} object representing <var> notification</var> .
1131
1157
<dt> {{NotificationEvent/action}}
1132
1158
<dd><var> action</var>
1133
1159
</dl>
1160
+ </div>
1134
1161
1135
- <p> The {{NotificationEvent/notification}} getter steps are to return the value it was initialized
1136
- to.
1162
+ <div algorithm>
1163
+ <p> The <dfn attribute for=NotificationEvent><code>notification</code></dfn> getter steps are to
1164
+ return the value it was initialized to.
1165
+ </div>
1137
1166
1138
- <p> The {{NotificationEvent/action}} getter steps are to return the value it was initialized to.
1167
+ <div algorithm>
1168
+ <p> The <dfn attribute for=NotificationEvent><code>action</code></dfn> getter steps are to return the
1169
+ value it was initialized to.
1170
+ </div>
1139
1171
1140
1172
<p> The following is the <a>event handler</a> (and its corresponding
1141
1173
<a>event handler event type</a> ) that must be supported as attribute by the
0 commit comments