tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

15.2.3.6-4-12.js (1335B)


      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 to define the property. For non-configurable properties, step 9a of
      8    [[DefineOwnProperty]] rejects changing the kind of a property.
      9 es5id: 15.2.3.6-4-12
     10 description: >
     11    Object.defineProperty throws TypeError when changing
     12    non-configurable data properties to accessor properties
     13 ---*/
     14 
     15 var o = {};
     16 
     17 // create a data valued property; all other attributes default to false.
     18 var d1 = {
     19  value: 101,
     20  configurable: false
     21 };
     22 Object.defineProperty(o, "foo", d1);
     23 
     24 // changing "foo" to be an accessor should fail, since [[Configurable]]
     25 // on the original property will be false.
     26 
     27 // dummy getter
     28 var getter = function() {
     29  return 1;
     30 }
     31 
     32 var desc = {
     33  get: getter
     34 };
     35 assert.throws(TypeError, function() {
     36  Object.defineProperty(o, "foo", desc);
     37 });
     38 // the property should remain a data valued property.
     39 var d2 = Object.getOwnPropertyDescriptor(o, "foo");
     40 assert.sameValue(d2.value, 101, 'd2.value');
     41 assert.sameValue(d2.writable, false, 'd2.writable');
     42 assert.sameValue(d2.enumerable, false, 'd2.enumerable');
     43 assert.sameValue(d2.configurable, false, 'd2.configurable');
     44 
     45 reportCompare(0, 0);