tor-browser

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

throws-when-target-cannot-be-held-weakly.js (1147B)


      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-weak-ref-target
      6 description: >
      7  Throws a TypeError if target cannot be held weakly
      8 info: |
      9  WeakRef ( _target_ )
     10  2. If CanBeHeldWeakly(_target_) is *false*, throw a *TypeError* exception.
     11 features: [WeakRef]
     12 ---*/
     13 
     14 assert.sameValue(
     15  typeof WeakRef, 'function',
     16  'typeof WeakRef is function'
     17 );
     18 
     19 assert.throws(TypeError, function() {
     20  new WeakRef();
     21 }, 'implicit undefined');
     22 
     23 assert.throws(TypeError, function() {
     24  new WeakRef(undefined);
     25 }, 'explicit undefined');
     26 
     27 assert.throws(TypeError, function() {
     28  new WeakRef(null);
     29 }, 'null');
     30 
     31 assert.throws(TypeError, function() {
     32  new WeakRef(1);
     33 }, 'number');
     34 
     35 assert.throws(TypeError, function() {
     36  new WeakRef('Object');
     37 }, 'string');
     38 
     39 var s = Symbol.for('registered symbol');
     40 assert.throws(TypeError, function() {
     41  new WeakRef(s);
     42 }, 'registered symbol');
     43 
     44 assert.throws(TypeError, function() {
     45  new WeakRef(true);
     46 }, 'Boolean, true');
     47 
     48 assert.throws(TypeError, function() {
     49  new WeakRef(false);
     50 }, 'Boolean, false');
     51 
     52 reportCompare(0, 0);