diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/built-ins/Object/assign/target-is-non-extensible-property-creation-throws.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/Object/assign/target-is-non-extensible-property-creation-throws.js')
-rw-r--r-- | js/src/tests/test262/built-ins/Object/assign/target-is-non-extensible-property-creation-throws.js | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Object/assign/target-is-non-extensible-property-creation-throws.js b/js/src/tests/test262/built-ins/Object/assign/target-is-non-extensible-property-creation-throws.js new file mode 100644 index 0000000000..cbc5dda75e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/assign/target-is-non-extensible-property-creation-throws.js @@ -0,0 +1,55 @@ +// Copyright (C) 2021 Alexey Shvayka. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +esid: sec-object.assign +description: > + [[Set]] to non-existing property of non-extensible `target` fails with TypeError. +info: | + Object.assign ( target, ...sources ) + + [...] + 3. For each element nextSource of sources, do + a. If nextSource is neither undefined nor null, then + [...] + iii. For each element nextKey of keys, do + 1. Let desc be ? from.[[GetOwnProperty]](nextKey). + 2. If desc is not undefined and desc.[[Enumerable]] is true, then + [...] + b. Perform ? Set(to, nextKey, propValue, true). + + OrdinarySetWithOwnDescriptor ( O, P, V, Receiver, ownDesc ) + + [...] + 3. If IsDataDescriptor(ownDesc) is true, then + [...] + c. Let existingDescriptor be ? Receiver.[[GetOwnProperty]](P). + d. If existingDescriptor is not undefined, then + [...] + e. Else, + i. Assert: Receiver does not currently have a property P. + ii. Return ? CreateDataProperty(Receiver, P, V). + + ValidateAndApplyPropertyDescriptor ( O, P, extensible, Desc, current ) + + [...] + 2. If current is undefined, then + a. If extensible is false, return false. +features: [Symbol] +---*/ + +var target1 = Object.preventExtensions({ foo: 1 }); + +assert.throws(TypeError, function() { + Object.assign(target1, { get bar() {} }); +}); + + +var target2 = {}; + +Object.preventExtensions(target2); +assert.throws(TypeError, function() { + Object.assign(target2, { [Symbol()]: 1 }); +}); + +reportCompare(0, 0); |