tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

null-bufferdata-throws.js (1854B)


      1 // |reftest| shell-option(--setpref=atomics_wait_async) skip-if(!this.hasOwnProperty('Atomics')||!xulRuntime.shell) -- Atomics is not enabled unconditionally, requires shell-options
      2 // Copyright (C) 2020 Rick Waldron. All rights reserved.
      3 // This code is governed by the BSD license found in the LICENSE file.
      4 /*---
      5 esid: sec-atomics.waitasync
      6 description: >
      7  A null value for bufferData throws a TypeError
      8 info: |
      9  Atomics.waitAsync( typedArray, index, value, timeout )
     10 
     11  1. Return DoWait(async, typedArray, index, value, timeout).
     12 
     13  DoWait ( mode, typedArray, index, value, timeout )
     14 
     15  1. Let buffer be ? ValidateSharedIntegerTypedArray(typedArray, true).
     16 
     17  ValidateSharedIntegerTypedArray ( typedArray [ , waitable ] )
     18 
     19  2. Perform ? RequireInternalSlot(typedArray, [[TypedArrayName]]).
     20 
     21  RequireInternalSlot ( O, internalSlot )
     22 
     23  1. If Type(O) is not Object, throw a TypeError exception.
     24  2. If O does not have an internalSlot internal slot, throw a TypeError exception.
     25 
     26 includes: [detachArrayBuffer.js]
     27 features: [Atomics.waitAsync, ArrayBuffer, Atomics, TypedArray, BigInt]
     28 ---*/
     29 assert.sameValue(typeof Atomics.waitAsync, 'function', 'The value of `typeof Atomics.waitAsync` is "function"');
     30 const i64a = new BigInt64Array(
     31  new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4)
     32 );
     33 
     34 const poisoned = {
     35  valueOf() {
     36    throw new Test262Error('should not evaluate this code');
     37  }
     38 };
     39 
     40 try {
     41  $DETACHBUFFER(i64a.buffer); // Detaching a non-shared ArrayBuffer sets the [[ArrayBufferData]] value to null
     42 } catch (error) {
     43  throw new Test262Error(`An unexpected error occurred when detaching ArrayBuffer: ${error.message}`);
     44 }
     45 
     46 assert.throws(TypeError, function() {
     47  Atomics.waitAsync(i64a, poisoned, poisoned, poisoned);
     48 }, '`Atomics.waitAsync(i64a, poisoned, poisoned, poisoned)` throws a TypeError exception');
     49 
     50 
     51 reportCompare(0, 0);