tor-browser

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

prop-expr-obj-ref-non-strict.js (1825B)


      1 // Copyright (C) 2016 the V8 project authors. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 /*---
      4 esid: sec-super-keyword
      5 es6id: 12.3.5
      6 description: SuperProperty's behavior as a non-strict reference
      7 info: |
      8  [...]
      9  4. If the code matched by the syntactic production that is being evaluated is
     10     strict mode code, let strict be true, else let strict be false.
     11  5. Return ? MakeSuperPropertyReference(propertyKey, strict).
     12 
     13  12.3.5.3 Runtime Semantics: MakeSuperPropertyReference
     14 
     15  1. Let env be GetThisEnvironment( ).
     16  2. If env.HasSuperBinding() is false, throw a ReferenceError exception.
     17  3. Let actualThis be ? env.GetThisBinding().
     18  4. Let baseValue be ? env.GetSuperBase().
     19  5. Let bv be ? RequireObjectCoercible(baseValue).
     20  6. Return a value of type Reference that is a Super Reference whose base
     21     value component is bv, whose referenced name component is propertyKey,
     22     whose thisValue component is actualThis, and whose strict reference flag
     23     is strict.
     24 
     25  6.2.3.2 PutValue
     26 
     27  [...]
     28  5. If IsUnresolvableReference(V) is true, then
     29     [...]
     30  6. Else if IsPropertyReference(V) is true, then
     31     a. If HasPrimitiveBase(V) is true, then
     32        [...]
     33     b. Let succeeded be ? base.[[Set]](GetReferencedName(V), W,
     34        GetThisValue(V)).
     35     c. If succeeded is false and IsStrictReference(V) is true, throw a
     36        TypeError exception.
     37     d. Return.
     38 flags: [noStrict]
     39 ---*/
     40 
     41 var obj = {
     42  method() {
     43    super['x'] = 8;
     44    Object.freeze(obj);
     45    super['y'] = 9;
     46  }
     47 };
     48 
     49 obj.method();
     50 
     51 assert(
     52  Object.prototype.hasOwnProperty.call(obj, 'x'),
     53  "x is defined as an own property"
     54 );
     55 assert(
     56  !Object.prototype.hasOwnProperty.call(obj, 'y'),
     57  "y is not defined as an own property after the object is frozen"
     58 );
     59 
     60 reportCompare(0, 0);