tor-browser

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

ident-name-global-property-accessor.js (1116B)


      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: 7.6.1-4-16
      6 description: >
      7    Allow global constant properties as property names by accessor function within an object.
      8 ---*/
      9 
     10 var test;
     11 
     12 var tokenCodes = {
     13    set undefined(value) { test = 'undefined'; },
     14    get undefined() { return 'undefined'; },
     15    set NaN(value) { test = 'NaN'; },
     16    get NaN() { return 'NaN'; },
     17    set Infinity(value) { test = 'Infinity'; },
     18    get Infinity() { return 'Infinity'; },
     19 };
     20 
     21 var arr = [
     22    'undefined',
     23    'NaN',
     24    'Infinity',
     25 ];
     26 
     27 for (var i = 0; i < arr.length; ++i) {
     28    var propertyName = arr[i];
     29 
     30    assert(tokenCodes.hasOwnProperty(propertyName),
     31           'Property "' + propertyName + '" found');
     32 
     33    assert.sameValue(tokenCodes[propertyName], propertyName,
     34                     'Property "' + propertyName + '" has correct value');
     35 
     36    tokenCodes[propertyName] = 0;
     37    assert.sameValue(test, propertyName,
     38                     'Property "' + propertyName + '" sets correct value');
     39 }
     40 
     41 reportCompare(0, 0);