Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Proxy/set/target-property-is-not-configurable-not-writable-not-equal-to-v.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.9
5 description: >
6 [[Set]] ( P, V, Receiver)
7
8 Throws a TypeError when target property is not configurable neither writable
9 and its value is not strictly equal to V.
10 info: |
11 14. If targetDesc is not undefined, then
12 a. If IsDataDescriptor(targetDesc) and targetDesc.[[Configurable]] is
13 false and targetDesc.[[Writable]] is false, then
14 i. If SameValue(V, targetDesc.[[Value]]) is false, throw a TypeError
15 exception.
16 ---*/
17
18 var target = {};
19 var handler = {
20 set: function(t, prop, value, receiver) {
21 return true;
22 }
23 };
24 var p = new Proxy(target, handler);
25
26 Object.defineProperty(target, 'attr', {
27 configurable: false,
28 writable: false,
29 value: 'foo'
30 });
31
32 assert.throws(TypeError, function() {
33 p.attr = 'bar';
34 });
35
36 assert.throws(TypeError, function() {
37 p['attr'] = 'bar';
38 });