tor-browser

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

15.2.3.9-2-c-4.js (1312B)


      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 es5id: 15.2.3.9-2-c-4
      6 description: >
      7    Object.freeze - all own properties of 'O' are not writable and not
      8    configurable
      9 includes: [propertyHelper.js]
     10 ---*/
     11 
     12 var obj = {};
     13 var resultSetFun = false;
     14 
     15 Object.defineProperty(obj, "foo1", {
     16  value: 10,
     17  writable: false,
     18  enumerable: true,
     19  configurable: false
     20 });
     21 
     22 function get_func() {
     23  return 10;
     24 }
     25 
     26 function set_func() {
     27  resultSetFun = true;
     28 }
     29 
     30 Object.defineProperty(obj, "foo2", {
     31  get: get_func,
     32  set: set_func,
     33  enumerable: true,
     34  configurable: true
     35 });
     36 
     37 Object.freeze(obj);
     38 
     39 verifyEqualTo(obj, "foo2", 10);
     40 
     41 verifyProperty(obj, "foo2", {
     42  configurable: false,
     43 });
     44 
     45 obj.foo2 = 12;
     46 if (!resultSetFun) {
     47  throw new Test262Error('Expected obj["foo2"] set() to be called, but was not.');
     48 }
     49 
     50 verifyProperty(obj, "foo2", {
     51  enumerable: true,
     52  configurable: false,
     53 });
     54 
     55 var desc2 = Object.getOwnPropertyDescriptor(obj, "foo2");
     56 if (desc2.writable) {
     57  throw new Test262Error('Expected obj["foo2"] to be non-writable, non-configurable; actually ' + JSON.stringify(desc2));
     58 }
     59 
     60 verifyProperty(obj, "foo1", {
     61  value: 10,
     62  writable: false,
     63  enumerable: true,
     64  configurable: false,
     65 });
     66 
     67 reportCompare(0, 0);