Skip to content

Commit

Permalink
Correct PushMessageData
Browse files Browse the repository at this point in the history
Give PushMessageData a clear internal concept to hold the bytes and also make it clear that it cannot be null. None of the methods were prepared to handle it being null and nothing ever creates a PushMessageData object where it is null.

Partially addresses the concerns in #380 and fixes #381.
  • Loading branch information
annevk committed Jul 9, 2024
1 parent f30bf3d commit 531a7db
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -982,30 +982,29 @@ <h2>
};
</pre>
<p>
<a>PushMessageData</a> objects have an associated [=byte sequence=] set on creation, which
is `null` if there was no data in the <a>push message</a>.
<a>PushMessageData</a> objects have an associated <dfn for=PushMessageData>bytes</dfn> (a
[=byte sequence=]), which is set on creation.
</p>
<p>
The <dfn>arrayBuffer()</dfn> method, when invoked, MUST return an {{ArrayBuffer}} whose
contents are |bytes|. Exceptions thrown during the creation of the {{ArrayBuffer}} object
are re-thrown.
The <dfn>arrayBuffer()</dfn> method steps are to return an {{ArrayBuffer}} whose contents
are <a>this</a>'s <a for=PushMessageData>bytes</a>. Exceptions thrown during the creation of
the {{ArrayBuffer}} object are re-thrown.
</p>
<p>
The <dfn>blob()</dfn> method, when invoked, MUST return a {{Blob}} whose contents are
|bytes| and |type| is not provided.
The <dfn>blob()</dfn> method steps are to return a new {{Blob}} object whose contents are
<a>this</a>'s <a for=PushMessageData>bytes</a>.
</p>
<p>
The <dfn>bytes()</dfn> method, when invoked, MUST return a {{Uint8Array}} backed by a
{{ArrayBuffer}} whose contents are |bytes|. Exceptions thrown during the creation of the
The <dfn>bytes()</dfn> method steps are to return a new {{Uint8Array}} backed by a
{{ArrayBuffer}} whose contents are <a>this</a>'s <a for=PushMessageData>bytes</a>. Exceptions thrown during the creation of the
{{ArrayBuffer}} object are re-thrown.
</p>
<p data-cite="encoding">
The <dfn>json()</dfn> method, when invoked, MUST return the result of invoking the initial
value of `JSON`.{{JSON/parse()}} with the result of running <a>utf-8 decode</a> on |bytes|
as argument. Re-throw any exceptions thrown by `JSON`.{{JSON/parse()}}.
The <dfn>json()</dfn> method steps are to return the result of
<a>parsing JSON bytes to a JavaScript value</a> given <a>this</a>'s <a for=PushMessageData>bytes</a>.
</p>
<p data-cite="encoding">
The <dfn>text</dfn> method, when invoked, MUST return the result of running <a>utf-8
The <dfn>text</dfn> method, when invoked, MUST return the result of running <a>UTF-8
decode</a> on |bytes|.
</p>
<p>
Expand Down

0 comments on commit 531a7db

Please sign in to comment.