tor-browser

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

symbol-for-value-throws.js (2369B)


      1 // |reftest| shell-option(--setpref=atomics_wait_async) skip-if(!this.hasOwnProperty('SharedArrayBuffer')||!this.hasOwnProperty('Atomics')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))||!xulRuntime.shell) -- SharedArrayBuffer,Atomics is not enabled unconditionally, ARM64 Simulator cannot emulate atomics, 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 /*---
      6 esid: sec-atomics.waitasync
      7 description: >
      8  Throws a TypeError if value arg is a Symbol
      9 info: |
     10  Atomics.waitAsync( typedArray, index, value, timeout )
     11 
     12  1. Return DoWait(async, typedArray, index, value, timeout).
     13 
     14  DoWait ( mode, typedArray, index, value, timeout )
     15 
     16  5. Otherwise, let v be ? ToInt32(value).
     17 
     18  ToInt32(value)
     19 
     20  1.Let number be ? ToNumber(argument).
     21 
     22    Symbol --> Throw a TypeError exception.
     23 
     24 features: [Atomics.waitAsync, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray, computed-property-names, Atomics]
     25 ---*/
     26 assert.sameValue(typeof Atomics.waitAsync, 'function', 'The value of `typeof Atomics.waitAsync` is "function"');
     27 const i32a = new Int32Array(
     28  new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
     29 );
     30 
     31 const poisonedValueOf = {
     32  valueOf() {
     33    throw new Test262Error('should not evaluate this code');
     34  }
     35 };
     36 
     37 const poisonedToPrimitive = {
     38  [Symbol.toPrimitive]() {
     39    throw new Test262Error("passing a poisoned object using @@ToPrimitive");
     40  }
     41 };
     42 
     43 assert.throws(Test262Error, function() {
     44  Atomics.waitAsync(i32a, 0, poisonedValueOf, poisonedValueOf);
     45 }, '`Atomics.waitAsync(i32a, 0, poisonedValueOf, poisonedValueOf)` throws a Test262Error exception');
     46 
     47 assert.throws(Test262Error, function() {
     48  Atomics.waitAsync(i32a, 0, poisonedToPrimitive, poisonedToPrimitive);
     49 }, '`Atomics.waitAsync(i32a, 0, poisonedToPrimitive, poisonedToPrimitive)` throws a Test262Error exception');
     50 
     51 assert.throws(TypeError, function() {
     52  Atomics.waitAsync(i32a, 0, Symbol("foo"), poisonedValueOf);
     53 }, '`Atomics.waitAsync(i32a, 0, Symbol("foo"), poisonedValueOf)` throws a TypeError exception');
     54 
     55 assert.throws(TypeError, function() {
     56  Atomics.waitAsync(i32a, 0, Symbol("foo"), poisonedToPrimitive);
     57 }, '`Atomics.waitAsync(i32a, 0, Symbol("foo"), poisonedToPrimitive)` throws a TypeError exception');
     58 
     59 reportCompare(0, 0);