Debian Codegraph @

js/src/tests/test262/language/arguments-object/mapped/nonconfigurable-descriptors-define-failure.js

raw
1 // Copyright (C) 2020 Alexey Shvayka. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 esid: sec-arguments-exotic-objects-defineownproperty-p-desc
6 description: >
7 OrdinaryDefineOwnProperty returning `false` doesn't leave `arguments` in a
8 corrupted state, for both mapped and unmapped indices.
9 info: |
10 [[DefineOwnProperty]] ( P, Desc )
11
12 [...]
13 6. Let allowed be ? OrdinaryDefineOwnProperty(args, P, newArgDesc).
14 7. If allowed is false, return false.
15 flags: [noStrict]
16 ---*/
17
18 (function(a) {
19 Object.defineProperty(arguments, "0", {configurable: false});
20
21 assert.throws(TypeError, () => {
22 Object.defineProperty(arguments, "0", {configurable: true});
23 });
24
25 a = 2;
26 assert.sameValue(arguments[0], 2);
27
28
29 Object.defineProperty(arguments, "1", {
30 get: () => 3,
31 configurable: false,
32 });
33
34 assert.throws(TypeError, () => {
35 Object.defineProperty(arguments, "1", {value: "foo"});
36 });
37
38 assert.sameValue(arguments[1], 3);
39 assert.throws(TypeError, () => {
40 "use strict";
41 delete arguments[1];
42 });
43 })(0);
44
45 reportCompare(0, 0);