tor-browser

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

target-not-callable-throws.js (1784B)


      1 // Copyright (C) 2019 Leo Balter. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 esid: sec-finalization-registry-target
      6 description: >
      7  Throws a TypeError if target is not callable
      8 info: |
      9  FinalizationRegistry ( cleanupCallback )
     10 
     11  1. If NewTarget is undefined, throw a TypeError exception.
     12  2. If IsCallable(cleanupCallback) is false, throw a TypeError exception.
     13  ...
     14 features: [FinalizationRegistry, WeakRef]
     15 ---*/
     16 
     17 assert.sameValue(
     18  typeof FinalizationRegistry, 'function',
     19  'typeof FinalizationRegistry is function'
     20 );
     21 
     22 assert.throws(TypeError, function() {
     23  new FinalizationRegistry({});
     24 }, 'ordinary object');
     25 
     26 assert.throws(TypeError, function() {
     27  new FinalizationRegistry(WeakRef.prototype);
     28 }, 'WeakRef.prototype');
     29 
     30 assert.throws(TypeError, function() {
     31  new FinalizationRegistry(FinalizationRegistry.prototype);
     32 }, 'FinalizationRegistry.prototype');
     33 
     34 assert.throws(TypeError, function() {
     35  new FinalizationRegistry([]);
     36 }, 'Array');
     37 
     38 assert.throws(TypeError, function() {
     39  new FinalizationRegistry();
     40 }, 'implicit undefined');
     41 
     42 assert.throws(TypeError, function() {
     43  new FinalizationRegistry(undefined);
     44 }, 'explicit undefined');
     45 
     46 assert.throws(TypeError, function() {
     47  new FinalizationRegistry(null);
     48 }, 'null');
     49 
     50 assert.throws(TypeError, function() {
     51  new FinalizationRegistry(1);
     52 }, 'number');
     53 
     54 assert.throws(TypeError, function() {
     55  new FinalizationRegistry('Object');
     56 }, 'string');
     57 
     58 var s = Symbol();
     59 assert.throws(TypeError, function() {
     60  new FinalizationRegistry(s);
     61 }, 'symbol');
     62 
     63 assert.throws(TypeError, function() {
     64  new FinalizationRegistry(true);
     65 }, 'Boolean, true');
     66 
     67 assert.throws(TypeError, function() {
     68  new FinalizationRegistry(false);
     69 }, 'Boolean, false');
     70 
     71 reportCompare(0, 0);