tor-browser

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

prop-expr-getsuperbase-before-topropertykey-putvalue.js (1505B)


      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-super-keyword-runtime-semantics-evaluation
      6 description: >
      7  GetSuperBase is performed before ToPropertyKey in PutValue.
      8 info: |
      9  13.3.7.1 Runtime Semantics: Evaluation
     10 
     11    SuperProperty : super [ Expression ]
     12 
     13    ...
     14    2. Let actualThis be ? env.GetThisBinding().
     15    3. Let propertyNameReference be ? Evaluation of Expression.
     16    4. Let propertyNameValue be ? GetValue(propertyNameReference).
     17    ...
     18    7. Return ? MakeSuperPropertyReference(actualThis, propertyNameValue, strict).
     19 
     20  13.3.7.3 MakeSuperPropertyReference ( actualThis, propertyKey, strict )
     21 
     22    1. Let env be GetThisEnvironment().
     23    ...
     24    3. Let baseValue be ? env.GetSuperBase().
     25    ...
     26 
     27  6.2.5.6 PutValue ( V, W )
     28 
     29    3. If IsPropertyReference(V) is true, then
     30      ...
     31      c. If V.[[ReferencedName]] is not a property key, then
     32          i. Set V.[[ReferencedName]] to ? ToPropertyKey(V.[[ReferencedName]]).
     33      d. Let succeeded be ? baseObj.[[Set]](V.[[ReferencedName]], W, GetThisValue(V)).
     34      ...
     35    ...
     36 ---*/
     37 
     38 var result;
     39 
     40 var proto = {
     41  set p(v) {
     42    result = "ok";
     43  },
     44 };
     45 
     46 var proto2 = {
     47  set p(v) {
     48    result = "bad";
     49  },
     50 };
     51 
     52 var obj = {
     53  __proto__: proto,
     54  m() {
     55    super[key] = 10;
     56  }
     57 };
     58 
     59 var key = {
     60  toString() {
     61    Object.setPrototypeOf(obj, proto2);
     62    return "p";
     63  }
     64 };
     65 
     66 obj.m();
     67 
     68 assert.sameValue(result, "ok");
     69 
     70 reportCompare(0, 0);