tor-browser

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

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


      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 value arg is a Symbol
      9 info: |
     10  Atomics.wait( typedArray, index, value, timeout )
     11 
     12  3. Let v be ? ToInt32(value).
     13 
     14  ToInt32(value)
     15 
     16  1.Let number be ? ToNumber(argument).
     17 
     18    Symbol --> Throw a TypeError exception.
     19 
     20 features: [Atomics, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray]
     21 ---*/
     22 
     23 const i32a = new Int32Array(
     24  new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
     25 );
     26 
     27 const poisonedValueOf = {
     28  valueOf: function() {
     29    throw new Test262Error('should not evaluate this code');
     30  }
     31 };
     32 
     33 const poisonedToPrimitive = {
     34  [Symbol.toPrimitive]: function() {
     35    throw new Test262Error("passing a poisoned object using @@ToPrimitive");
     36  }
     37 };
     38 
     39 assert.throws(Test262Error, function() {
     40  Atomics.wait(i32a, 0, poisonedValueOf, poisonedValueOf);
     41 });
     42 
     43 assert.throws(Test262Error, function() {
     44  Atomics.wait(i32a, 0, poisonedToPrimitive, poisonedToPrimitive);
     45 });
     46 
     47 assert.throws(TypeError, function() {
     48  Atomics.wait(i32a, 0, Symbol("foo"), poisonedValueOf);
     49 });
     50 
     51 assert.throws(TypeError, function() {
     52  Atomics.wait(i32a, 0, Symbol("foo"), poisonedToPrimitive);
     53 });
     54 
     55 reportCompare(0, 0);