Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Proxy/defineProperty/targetdesc-not-compatible-descriptor-not-configurable-target.js

raw
1 // Copyright (C) 2015 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 es6id: 9.5.6
5 description: >
6 Throw a TypeError exception if Desc and target property descriptor are not
7 compatible and trap result is true.
8 info: |
9 [[DefineOwnProperty]] (P, Desc)
10
11 ...
12 20. Else targetDesc is not undefined,
13 a. If IsCompatiblePropertyDescriptor(extensibleTarget, Desc ,
14 targetDesc) is false, throw a TypeError exception.
15 ...
16 ---*/
17
18 var target = {};
19 var p = new Proxy(target, {
20 defineProperty: function(t, prop, desc) {
21 return true;
22 }
23 });
24
25 Object.defineProperty(target, "foo", {
26 value: 1,
27 configurable: false
28 });
29
30 assert.throws(TypeError, function() {
31 Object.defineProperty(p, "foo", {
32 value: 1,
33 configurable: true
34 });
35 });