tor-browser

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

verifyProperty-restore.js (756B)


      1 // Copyright (C) 2017 Leo Balter. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 description: >
      6  verifyProperty allows restoring the original descriptor
      7 includes: [propertyHelper.js]
      8 ---*/
      9 
     10 var obj;
     11 var prop = 'prop';
     12 var desc = { enumerable: true, configurable: true, writable: true, value: 42 };
     13 
     14 obj = {};
     15 Object.defineProperty(obj, prop, desc);
     16 
     17 verifyProperty(obj, prop, desc);
     18 
     19 assert.sameValue(
     20  Object.prototype.hasOwnProperty.call(obj, prop),
     21  false
     22 );
     23 
     24 obj = {};
     25 Object.defineProperty(obj, prop, desc);
     26 
     27 verifyProperty(obj, prop, desc, { restore: true });
     28 
     29 assert.sameValue(
     30  Object.prototype.hasOwnProperty.call(obj, prop),
     31  true
     32 );
     33 assert.sameValue(obj[prop], 42);
     34 
     35 reportCompare(0, 0);