Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/JSON/parse/revived-proxy-revoked.js

raw
1 // Copyright (C) 2016 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 esid: sec-json.parse
5 es6id: 24.3.1
6 description: Behavior when revived value is a revoked Proxy exotic object
7 info: |
8 [...]
9 7. If IsCallable(reviver) is true, then
10 a. Let root be ObjectCreate(%ObjectPrototype%).
11 b. Let rootName be the empty String.
12 c. Let status be CreateDataProperty(root, rootName, unfiltered).
13 d. Assert: status is true.
14 e. Return ? InternalizeJSONProperty(root, rootName).
15
16 24.3.1.1 Runtime Semantics: InternalizeJSONProperty
17
18 [...]
19 2. If Type(val) is Object, then
20 a. Let isArray be ? IsArray(val).
21
22 7.2.2 IsArray
23
24 [...]
25 3. If argument is a Proxy exotic object, then
26 a. If the value of the [[ProxyHandler]] internal slot of argument is null,
27 throw a TypeError exception.
28 b. Let target be the value of the [[ProxyTarget]] internal slot of
29 argument.
30 c. Return ? IsArray(target).
31 features: [Proxy]
32 ---*/
33
34 var handle = Proxy.revocable([], {});
35 var returnCount = 0;
36
37 handle.revoke();
38
39 assert.throws(TypeError, function() {
40 JSON.parse('[null, null]', function() {
41 this[1] = handle.proxy;
42 returnCount += 1;
43 });
44 });
45
46 assert.sameValue(returnCount, 1, 'invocation returns normally');