tor-browser

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

15.2.3.6-4-15.js (1329B)


      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 configurable properties, step 9c of
      8    [[DefineOwnProperty]] permits changing the kind of a property.
      9 es5id: 15.2.3.6-4-15
     10 description: >
     11    Object.defineProperty permits changing accessor property to data
     12    property for configurable properties
     13 ---*/
     14 
     15 var o = {};
     16 
     17 // define an accessor property
     18 // dummy getter
     19 var getter = function() {
     20  return 1;
     21 }
     22 var d1 = {
     23  get: getter,
     24  configurable: true
     25 };
     26 Object.defineProperty(o, "foo", d1);
     27 
     28 // changing "foo" to be a data valued property should succeed, since
     29 // [[Configurable]] on the original property will be true. Existing
     30 // values of [[Configurable]] and [[Enumerable]] need to be preserved
     31 // and the rest need to be set to their default values.
     32 var desc = {
     33  value: 101
     34 };
     35 Object.defineProperty(o, "foo", desc);
     36 var d2 = Object.getOwnPropertyDescriptor(o, "foo");
     37 
     38 assert.sameValue(d2.value, 101, 'd2.value');
     39 assert.sameValue(d2.writable, false, 'd2.writable');
     40 assert.sameValue(d2.enumerable, false, 'd2.enumerable');
     41 assert.sameValue(d2.configurable, true, 'd2.configurable');
     42 
     43 reportCompare(0, 0);