Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/JSON/parse/reviver-array-length-get-err.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-internalizejsonproperty
5 es6id: 24.3.1.1
6 description: >
7 Abrupt completion from array "length" property access while reviving
8 info: |
9 JSON.parse ( text [ , reviver ] )
10
11 [...]
12 7. If IsCallable(reviver) is true, then
13 [...]
14 e. Return ? InternalizeJSONProperty(root, rootName).
15
16 Runtime Semantics: InternalizeJSONProperty ( holder, name)
17
18 1. Let val be ? Get(holder, name).
19 2. If Type(val) is Object, then
20 a. Let isArray be ? IsArray(val).
21 b. If isArray is true, then
22 i. Set I to 0.
23 ii. Let len be ? ToLength(? Get(val, "length")).
24 features: [Proxy]
25 ---*/
26
27 var badLength = new Proxy([], {
28 get: function(_, name) {
29 if (name === 'length') {
30 throw new Test262Error();
31 }
32 }
33 });
34
35 assert.throws(Test262Error, function() {
36 JSON.parse('[0,0]', function() {
37 this[1] = badLength;
38 });
39 });