tor-browser

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

get-mutable-binding-binding-deleted-in-get-unscopables-strict-mode.js (1024B)


      1 // Copyright (C) 2024 André Bargull. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 esid: sec-object-environment-records-getbindingvalue-n-s
      6 description: >
      7  Binding deleted when retrieving unscopables.
      8 info: |
      9  9.1.1.2.6 GetBindingValue ( N, S )
     10 
     11  1. Let bindingObject be envRec.[[BindingObject]].
     12  2. Let value be ? HasProperty(bindingObject, N).
     13  3. If value is false, then
     14    a. If S is false, return undefined; otherwise throw a ReferenceError exception.
     15  ...
     16 
     17 flags: [noStrict]
     18 features: [Symbol.unscopables]
     19 ---*/
     20 
     21 var unscopablesCalled = 0;
     22 
     23 var env = {
     24  binding: 0,
     25  get [Symbol.unscopables]() {
     26    unscopablesCalled++;
     27    delete env.binding;
     28    return null;
     29  }
     30 };
     31 
     32 var result = null;
     33 with (env) {
     34  assert.throws(ReferenceError, function() {
     35    "use strict";
     36    result = binding;
     37  });
     38 }
     39 
     40 assert.sameValue(unscopablesCalled, 1, "get [Symbol.unscopables] called once");
     41 
     42 assert.sameValue(result, null, "result not modified");
     43 
     44 reportCompare(0, 0);