tor-browser

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

15.2.3.6-4-10.js (1356B)


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