tor-browser

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

object-pattern-emulates-undefined.js (1086B)


      1 // Copyright (C) 2020 Alexey Shvayka. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 /*---
      4 esid: sec-destructuring-binding-patterns-runtime-semantics-bindinginitialization
      5 description: >
      6  Destructuring initializer is not evaluated when value is an object
      7  with [[IsHTMLDDA]] internal slot.
      8 info: |
      9  BindingPattern : ObjectBindingPattern
     10 
     11  1. Perform ? RequireObjectCoercible(value).
     12  2. Return the result of performing BindingInitialization for
     13  ObjectBindingPattern using value and environment as arguments.
     14 
     15  Runtime Semantics: KeyedBindingInitialization
     16 
     17  SingleNameBinding : BindingIdentifier Initializer[opt]
     18 
     19  [...]
     20  4. If Initializer is present and v is undefined, then
     21    [...]
     22  5. If environment is undefined, return ? PutValue(lhs, v).
     23 features: [destructuring-binding, IsHTMLDDA]
     24 ---*/
     25 
     26 let initCount = 0;
     27 const counter = function() {
     28  initCount += 1;
     29 };
     30 
     31 const IsHTMLDDA = $262.IsHTMLDDA;
     32 const {x = counter()} = {x: IsHTMLDDA};
     33 
     34 assert.sameValue(x, IsHTMLDDA);
     35 assert.sameValue(initCount, 0);
     36 
     37 reportCompare(0, 0);