Bug 1892041 - Part 2: Update test262. r=spidermonkey-reviewers,dminor
[gecko.git] / js / src / tests / test262 / built-ins / Object / assign / target-is-sealed-property-creation-throws.js
blobdd7ebae67b5b9967193f1840072fbc6ef7f26fc6
1 // Copyright (C) 2021 Alexey Shvayka. All rights reserved.
2 // This code is governed by the license found in the LICENSE file.
4 /*---
5 esid: sec-object.assign
6 description: >
7   [[Set]] to non-existing property of sealed `target` fails with TypeError.
8 info: |
9   SetIntegrityLevel ( O, level )
11   [...]
12   3. Let status be ? O.[[PreventExtensions]]().
13   [...]
15   Object.assign ( target, ...sources )
17   [...]
18   3. For each element nextSource of sources, do
19     a. If nextSource is neither undefined nor null, then
20       [...]
21       iii. For each element nextKey of keys, do
22         1. Let desc be ? from.[[GetOwnProperty]](nextKey).
23         2. If desc is not undefined and desc.[[Enumerable]] is true, then
24           [...]
25           b. Perform ? Set(to, nextKey, propValue, true).
27   OrdinarySetWithOwnDescriptor ( O, P, V, Receiver, ownDesc )
29   [...]
30   3. If IsDataDescriptor(ownDesc) is true, then
31     [...]
32     c. Let existingDescriptor be ? Receiver.[[GetOwnProperty]](P).
33     d. If existingDescriptor is not undefined, then
34       [...]
35     e. Else,
36       i. Assert: Receiver does not currently have a property P.
37       ii. Return ? CreateDataProperty(Receiver, P, V).
39   ValidateAndApplyPropertyDescriptor ( O, P, extensible, Desc, current )
41   [...]
42   2. If current is undefined, then
43     a. If extensible is false, return false.
44 features: [Symbol, Reflect]
45 ---*/
47 var target1 = Object.seal({ foo: 1 });
49 assert.throws(TypeError, function() {
50   Object.assign(target1, { get bar() {} });
51 });
54 var target2 = {};
56 Object.seal(target2);
57 assert.throws(TypeError, function() {
58   Object.assign(target2, { [Symbol()]: 1 });
59 });
61 reportCompare(0, 0);