tor-browser

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

target-is-sealed-existing-data-property.js (1805B)


      1 // Copyright (C) 2021 Alexey Shvayka. All rights reserved.
      2 // This code is governed by the license found in the LICENSE file.
      3 
      4 /*---
      5 esid: sec-object.assign
      6 description: >
      7  [[Set]] to existing data property of sealed `target` is successful.
      8 info: |
      9  SetIntegrityLevel ( O, level )
     10 
     11  [...]
     12  3. Let status be ? O.[[PreventExtensions]]().
     13  [...]
     14 
     15  OrdinaryPreventExtensions ( O )
     16 
     17  1. Set O.[[Extensible]] to false.
     18 
     19  Object.assign ( target, ...sources )
     20 
     21  [...]
     22  3. For each element nextSource of sources, do
     23    a. If nextSource is neither undefined nor null, then
     24      [...]
     25      iii. For each element nextKey of keys, do
     26        1. Let desc be ? from.[[GetOwnProperty]](nextKey).
     27        2. If desc is not undefined and desc.[[Enumerable]] is true, then
     28          [...]
     29          b. Perform ? Set(to, nextKey, propValue, true).
     30 
     31  OrdinarySetWithOwnDescriptor ( O, P, V, Receiver, ownDesc )
     32 
     33  [...]
     34  3. If IsDataDescriptor(ownDesc) is true, then
     35    [...]
     36    c. Let existingDescriptor be ? Receiver.[[GetOwnProperty]](P).
     37    d. If existingDescriptor is not undefined, then
     38      [...]
     39      iii. Let valueDesc be the PropertyDescriptor { [[Value]]: V }.
     40      iv. Return ? Receiver.[[DefineOwnProperty]](P, valueDesc).
     41 
     42  ValidateAndApplyPropertyDescriptor ( O, P, extensible, Desc, current )
     43 
     44  [...]
     45  9. If O is not undefined, then
     46    a. For each field of Desc that is present, set the corresponding attribute
     47       of the property named P of object O to the value of the field.
     48  10. Return true.
     49 ---*/
     50 
     51 var target1 = Object.seal({ foo: 1 });
     52 
     53 Object.assign(target1, { foo: 2 });
     54 assert.sameValue(target1.foo, 2);
     55 
     56 
     57 var sym = Symbol();
     58 var target2 = { [sym]: 1 };
     59 
     60 Object.seal(target2);
     61 Object.assign(target2, { [sym]: 2 });
     62 assert.sameValue(target2[sym], 2);
     63 
     64 reportCompare(0, 0);