Skip to content

Commit 16cfb13

Browse files
committed
Make mutable top-level and validate JSON more directly
1 parent 4f6bd92 commit 16cfb13

File tree

1 file changed

+89
-34
lines changed

1 file changed

+89
-34
lines changed

index.html

Lines changed: 89 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ <h3>
217217
<dd>
218218
<p>
219219
A JSON object consisting of the following members, many being analogous to
220-
Notifications API features.
220+
Notifications API features. [[NOTIFICATIONS]]
221221
</p>
222222
<dl>
223223
<dt>
@@ -292,16 +292,6 @@ <h3>
292292
Any JSON value.
293293
</p>
294294
</dd>
295-
<dt>
296-
<code>mutable</code>
297-
</dt>
298-
<dd>
299-
<p>
300-
A boolean. When true causes a <code>push</code> event to be dispatched to a
301-
service worker (if any) containing the {{Notification}} object described by the
302-
<a>declarative push message</a>.
303-
</p>
304-
</dd>
305295
</dl>
306296
</dd>
307297
<dt>
@@ -316,6 +306,16 @@ <h3>
316306
displayed to the end user. [[BADGING]]
317307
</p>
318308
</dd>
309+
<dt>
310+
<code>mutable</code>
311+
</dt>
312+
<dd>
313+
<p>
314+
A boolean. When true causes a <code>push</code> event to be dispatched to a service
315+
worker (if any) containing the {{Notification}} object and app badge number (if
316+
any) described by the <a>declarative push message</a>.
317+
</p>
318+
</dd>
319319
</dl>
320320
</section>
321321
<section>
@@ -325,9 +325,9 @@ <h3>
325325
<p>
326326
A <dfn>declarative push message parser result</dfn> is a [=/tuple=] consisting of a
327327
<dfn data-dfn-for="declarative push message parser result">notification</dfn> (a
328-
[=/notification=]), <dfn data-dfn-for="declarative push message parser result">mutable
329-
notification</dfn> (a boolean), and an <dfn data-dfn-for=
330-
"declarative push message parser result">app badge</dfn> (null or an integer).
328+
[=/notification=]), an <dfn data-dfn-for="declarative push message parser result">app
329+
badge</dfn> (null or an integer), and a <dfn data-dfn-for=
330+
"declarative push message parser result">mutable</dfn> (a boolean).
331331
</p>
332332
<p>
333333
The <dfn>declarative push message parser</dfn> given a [=/byte sequence=]
@@ -349,7 +349,7 @@ <h3>
349349
</li>
350350
<li>
351351
<p>
352-
If <var>message</var>["`web_push`"] [=map/does not exist=], then return failure.
352+
If <var>message</var>["`web_push`"] does not [=map/exist=], then return failure.
353353
</p>
354354
</li>
355355
<li>
@@ -359,7 +359,7 @@ <h3>
359359
</li>
360360
<li>
361361
<p>
362-
If <var>message</var>["`notification`"] [=map/does not exist=], then return
362+
If <var>message</var>["`notification`"] does not [=map/exist=], then return
363363
failure.
364364
</p>
365365
</li>
@@ -375,50 +375,93 @@ <h3>
375375
</li>
376376
<li>
377377
<p>
378-
If <var>notificationInput</var>["`title`"] [=map/does not exist=], then return
379-
failure.
378+
If <var>notificationInput</var>["`title`"] does not [=map/exist=] or is not a
379+
string, then return failure.
380380
</p>
381381
</li>
382382
<li>
383383
<p>
384-
If <var>notificationInput</var>["`title`"] is not a string, then return failure.
384+
If <var>notificationInput</var>["`navigate`"] does not [=map/exist=] or is not a
385+
string, then return failure.
385386
</p>
386387
</li>
388+
<!-- We could also handle this the same way as any other NotificationOptions members as we still need to check that the final notification has a navigation URL regardless, but it seems better to illustrate early failures are possible. -->
387389
<li>
388390
<p>
389-
Let <var>title</var> be <var>notificationInput</var>["`title`"].
391+
Let <var>notificationTitle</var> be <var>notificationInput</var>["`title`"].
390392
</p>
391393
</li>
392394
<li>
393395
<p>
394-
Let <var>mutable</var> be false.
396+
Let <var>notificationOptions</var> be a {{NotificationOptions}} dictionary.
395397
</p>
396398
</li>
397399
<li>
398400
<p>
399-
If <var>notificationInput</var>["`mutable`"] [=map/exists=] and
400-
<var>notificationInput</var>["`mutable`"] is a boolean, then set <var>mutable</var>
401-
to <var>notificationInput</var>["`mutable`"].
401+
If <var>notificationInput</var>["`dir`"] [=map/exists=] and
402+
<var>notificationInput</var>["`dir`"] is "`auto`", "`ltr`", or "`rtl`", then set
403+
<var>notificationOptions</var>["{{NotificationOptions/dir}}"] to
404+
<var>notificationInput</var>["`dir`"].
402405
</p>
403406
</li>
404407
<li>
405408
<p>
406-
Let <var>jsNotificationInput</var> be the result of running <a>convert an Infra
407-
value to a JSON-compatible JavaScript value</a> given <var>notificationInput</var>.
409+
If <var>notificationInput</var>["`lang`"] [=map/exists=] and
410+
<var>notificationInput</var>["`lang`"] is a string, then set
411+
<var>notificationOptions</var>["{{NotificationOptions/lang}}"] to
412+
<var>notificationInput</var>["`lang`"].
408413
</p>
409414
</li>
410415
<li>
411416
<p>
412-
Let <var>notificationOptions</var> be the result of <a data-dfn-lt=
413-
"converted to an IDL value">converting</a> <var>jsNotificationInput</var> to the
414-
dictionary type {{NotificationOptions}}. If this throws an exception, then return
415-
failure.
417+
If <var>notificationInput</var>["`body`"] [=map/exists=] and
418+
<var>notificationInput</var>["`body`"] is a string, then set
419+
<var>notificationOptions</var>["{{NotificationOptions/body}}"] to
420+
<var>notificationInput</var>["`body`"].
421+
</p>
422+
</li>
423+
<li>
424+
<p>
425+
Set <var>notificationOptions</var>["{{NotificationOptions/navigate}}"] to
426+
<var>notificationInput</var>["`navigate`"], [=string/converted=].
427+
</p>
428+
</li>
429+
<li>
430+
<p>
431+
If <var>notificationInput</var>["`tag`"] [=map/exists=] and
432+
<var>notificationInput</var>["`tag`"] is a string, then set
433+
<var>notificationOptions</var>["{{NotificationOptions/tag}}"] to
434+
<var>notificationInput</var>["`tag`"].
435+
</p>
436+
</li>
437+
<li>
438+
<p>
439+
If <var>notificationInput</var>["`icon`"] [=map/exists=] and
440+
<var>notificationInput</var>["`icon`"] is a string, then set
441+
<var>notificationOptions</var>["{{NotificationOptions/icon}}"] to
442+
<var>notificationInput</var>["`icon`"], [=string/converted=].
443+
</p>
444+
</li>
445+
<li>
446+
<p>
447+
If <var>notificationInput</var>["`silent`"] [=map/exists=] and
448+
<var>notificationInput</var>["`silent`"] is a boolean, then set
449+
<var>notificationOptions</var>["{{NotificationOptions/silent}}"] to
450+
<var>notificationInput</var>["`silent`"].
451+
</p>
452+
</li>
453+
<li>
454+
<p>
455+
If <var>notificationInput</var>["`data`"] [=map/exists=], then set
456+
<var>notificationOptions</var>["{{NotificationOptions/data}}"] to the result of
457+
running <a>convert an Infra value to a JSON-compatible JavaScript value</a> given
458+
<var>notificationInput</var>["`data`"].
416459
</p>
417460
</li>
418461
<li>
419462
<p>
420463
Let <var>notification</var> be the result of <a>creating a notification</a> given
421-
<var>title</var>, <var>notificationOptions</var>, <var>origin</var>,
464+
<var>notificationTitle</var>, <var>notificationOptions</var>, <var>origin</var>,
422465
<var>baseURL</var>, and <var>fallbackTimestamp</var>. If this throws an exception,
423466
then return failure.
424467
</p>
@@ -443,7 +486,19 @@ <h3>
443486
</li>
444487
<li>
445488
<p>
446-
Return (<var>notification</var>, <var>mutable</var>, <var>appBadge</var>).
489+
Let <var>mutable</var> be false.
490+
</p>
491+
</li>
492+
<li>
493+
<p>
494+
If <var>message</var>["`mutable`"] [=map/exists=] and
495+
<var>message</var>["`mutable`"] is a boolean, then set <var>mutable</var> to
496+
<var>message</var>["`mutable`"].
497+
</p>
498+
</li>
499+
<li>
500+
<p>
501+
Return (<var>notification</var>, <var>appBadge</var>, <var>mutable</var>).
447502
</p>
448503
</li>
449504
</ol>
@@ -1478,8 +1533,8 @@ <h2>
14781533
</li>
14791534
<li>
14801535
<p>
1481-
If |declarativeResult|'s [=declarative push message parser result/mutable
1482-
notification=] is true:
1536+
If |declarativeResult|'s [=declarative push message parser result/mutable=]
1537+
is true:
14831538
</p>
14841539
<ol>
14851540
<li>

0 commit comments

Comments
 (0)