tor-browser

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

poisoned-object-for-timeout-throws.js (1421B)


      1 // |reftest| skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics
      2 // Copyright (C) 2018 Amal Hussein. All rights reserved.
      3 // This code is governed by the BSD license found in the LICENSE file.
      4 
      5 /*---
      6 esid: sec-atomics.wait
      7 description: >
      8  Throws a TypeError if index arg can not be converted to an Integer
      9 info: |
     10  Atomics.wait( typedArray, index, value, timeout )
     11 
     12  4. Let q be ? ToNumber(timeout).
     13 
     14    Object -> Apply the following steps:
     15 
     16      Let primValue be ? ToPrimitive(argument, hint Number).
     17      Return ? ToNumber(primValue).
     18 
     19 features: [Atomics, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray]
     20 ---*/
     21 
     22 const i32a = new Int32Array(
     23  new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
     24 );
     25 
     26 const poisonedValueOf = {
     27  valueOf: function() {
     28    throw new Test262Error('should not evaluate this code');
     29  }
     30 };
     31 
     32 const poisonedToPrimitive = {
     33  [Symbol.toPrimitive]: function() {
     34    throw new Test262Error("passing a poisoned object using @@ToPrimitive");
     35  }
     36 };
     37 
     38 assert.throws(Test262Error, function() {
     39  Atomics.wait(i32a, 0, 0, poisonedValueOf);
     40 });
     41 
     42 assert.throws(Test262Error, function() {
     43  Atomics.wait(i32a, 0, 0, poisonedToPrimitive);
     44 });
     45 
     46 reportCompare(0, 0);