tor-browser

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

throws-if-initializer-not-object.js (2057B)


      1 // |reftest| shell-option(--enable-explicit-resource-management) skip-if(!(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('explicit-resource-management'))||!xulRuntime.shell) -- explicit-resource-management is not enabled unconditionally, requires shell-options
      2 // Copyright (C) 2023 Ron Buckton. All rights reserved.
      3 // This code is governed by the BSD license found in the LICENSE file.
      4 
      5 /*---
      6 esid: sec-let-and-const-declarations-runtime-semantics-evaluation
      7 description: Throws if initialized value is not an Object
      8 info: |
      9  RS: Evaluation
     10    UsingDeclaration : using BindingList ;
     11 
     12    1. Perform ? BindingEvaluation of BindingList with argument sync-dispose.
     13    2. Return empty.
     14 
     15  RS: BindingEvaluation
     16    LexicalBinding : BindingIdentifier Initializer
     17 
     18    ...
     19    5. Return ? InitializeReferencedBinding(lhs, value, hint).
     20 
     21  InitializeReferencedBinding ( V, W )
     22 
     23  ...
     24  4. Return ? base.InitializeBinding(V.[[ReferencedName]], W).
     25 
     26  InitializeBinding ( N, V, hint )
     27 
     28  ...
     29  2. If hint is not normal, perform ? AddDisposableResource(envRec.[[DisposeCapability]], V, hint).
     30  ...
     31 
     32  AddDisposableResource ( disposeCapability, V, hint [, method ] )
     33 
     34  1. If method is not present then,
     35    a. If V is either null or undefined and hint is sync-dispose, then
     36      i. Return unused.
     37    b. Let resource be ? CreateDisposableResource(V, hint).
     38  ...
     39 
     40  CreateDisposableResource ( V, hint [ , method ] )
     41 
     42  1. If method is not present, then
     43    a. If V is either null or undefined, then
     44      ...
     45    b. Else,
     46      i. If V is not an Object, throw a TypeError exception.
     47      ...
     48  ...
     49 
     50 features: [explicit-resource-management]
     51 ---*/
     52 
     53 assert.throws(TypeError, function() {
     54  using x = true;
     55 }, 'true');
     56 
     57 assert.throws(TypeError, function() {
     58  using x = false;
     59 }, 'false');
     60 
     61 assert.throws(TypeError, function() {
     62  using x = 1;
     63 }, 'number');
     64 
     65 assert.throws(TypeError, function() {
     66  using x = 'object';
     67 }, 'string');
     68 
     69 var s = Symbol();
     70 assert.throws(TypeError, function() {
     71  using x = s;
     72 }, 'symbol');
     73 
     74 reportCompare(0, 0);