Skip to content

Commit e858846

Browse files
authored
Validate mutability in DetachArrayBuffer (#38)
Ref #30
1 parent 3c049b9 commit e858846

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

spec.emu

+25
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,31 @@ contributors: Mark S. Miller, Richard Gibson
492492
</emu-clause>
493493
</ins>
494494

495+
<emu-clause id="sec-detacharraybuffer" type="abstract operation" number="5">
496+
<h1>
497+
DetachArrayBuffer (
498+
_arrayBuffer_: an ArrayBuffer,
499+
optional _key_: anything,
500+
): either a normal completion containing ~unused~ or a throw completion
501+
</h1>
502+
<dl class="header">
503+
<dt>skip global checks</dt>
504+
<dd>true</dd>
505+
</dl>
506+
<emu-alg>
507+
1. Assert: IsSharedArrayBuffer(_arrayBuffer_) is *false*.
508+
1. If _key_ is not present, set _key_ to *undefined*.
509+
1. If _arrayBuffer_.[[ArrayBufferDetachKey]] is not _key_, throw a *TypeError* exception.
510+
1. <ins>If IsImmutableBuffer(_arrayBuffer_) is *true*, throw a *TypeError* exception.</ins>
511+
1. Set _arrayBuffer_.[[ArrayBufferData]] to *null*.
512+
1. Set _arrayBuffer_.[[ArrayBufferByteLength]] to 0.
513+
1. Return ~unused~.
514+
</emu-alg>
515+
<emu-note>
516+
<p>Detaching an ArrayBuffer instance disassociates the Data Block used as its backing store from the instance and sets the byte length of the buffer to 0.</p>
517+
</emu-note>
518+
</emu-clause>
519+
495520
<emu-clause id="sec-setvalueinbuffer" type="abstract operation" number="18">
496521
<h1>
497522
SetValueInBuffer (

0 commit comments

Comments
 (0)