Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Object/defineProperty/15.2.3.6-4-1.js

raw
1 // Copyright (c) 2012 Ecma International. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 info: |
6 Step 4 of defineProperty calls the [[DefineOwnProperty]] internal method
7 of O passing 'true' for the Throw flag. In this case, step 3 of
8 [[DefineOwnProperty]] requires that it throw a TypeError exception when
9 current is undefined and extensible is false. The value of desc does not
10 matter.
11 es5id: 15.2.3.6-4-1
12 description: >
13 Object.defineProperty throws TypeError when adding properties to
14 non-extensible objects(8.12.9 step 3)
15 ---*/
16
17 var o = {};
18 Object.preventExtensions(o);
19 assert.throws(TypeError, function() {
20 var desc = {
21 value: 1
22 };
23 Object.defineProperty(o, "foo", desc);
24 });
25 assert.sameValue(o.hasOwnProperty("foo"), false, 'o.hasOwnProperty("foo")');