Debian Codegraph @

js/src/tests/test262/language/statements/with/set-mutable-binding-binding-deleted-in-get-unscopables-strict-mode.js

raw
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-object-environment-records-setmutablebinding-n-v-s
6 description: >
7 Binding deleted when retrieving unscopables.
8 info: |
9 9.1.1.2.5 SetMutableBinding ( N, V, S )
10
11 1. Let bindingObject be envRec.[[BindingObject]].
12 2. Let stillExists be ? HasProperty(bindingObject, N).
13 3. If stillExists is false and S is true, throw a ReferenceError exception.
14 ...
15
16 flags: [noStrict]
17 features: [Symbol.unscopables]
18 ---*/
19
20 var unscopablesCalled = 0;
21
22 var env = {
23 binding: 0,
24 get [Symbol.unscopables]() {
25 unscopablesCalled++;
26 delete env.binding;
27 return null;
28 }
29 };
30
31 with (env) {
32 assert.throws(ReferenceError, function() {
33 "use strict";
34 binding = 123;
35 });
36 }
37
38 assert.sameValue(unscopablesCalled, 1, "get [Symbol.unscopables] called once");
39
40 assert.sameValue(Object.getOwnPropertyDescriptor(env, "binding"), undefined, "binding deleted");
41
42 reportCompare(0, 0);