tor-browser

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

primitive-string.js (1442B)


      1 // Copyright (C) 2020 Alexey Shvayka. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 esid: sec-object.getownpropertydescriptor
      6 description: >
      7  String primitive as first argument is coerced to object.
      8 info: |
      9  Object.getOwnPropertyDescriptor ( O, P )
     10 
     11  1. Let obj be ? ToObject(O).
     12  [...]
     13  3. Let desc be ? obj.[[GetOwnProperty]](key).
     14  4. Return FromPropertyDescriptor(desc).
     15 
     16  String Exotic Objects
     17 
     18  String exotic objects always have a data property named "length" whose value is the number
     19  of code unit elements in the encapsulated String value. Both the code unit data properties
     20  and the "length" property are non-writable and non-configurable.
     21 ---*/
     22 
     23 assert.sameValue(Object.getOwnPropertyDescriptor('', '0'), undefined);
     24 
     25 var indexDesc = Object.getOwnPropertyDescriptor('foo', '0');
     26 
     27 assert.sameValue(indexDesc.value, 'f', '[[Value]]');
     28 assert.sameValue(indexDesc.writable, false, '[[Writable]]');
     29 assert.sameValue(indexDesc.enumerable, true, '[[Enumerable]]');
     30 assert.sameValue(indexDesc.configurable, false, '[[Configurable]]');
     31 
     32 var lengthDesc = Object.getOwnPropertyDescriptor('foo', 'length');
     33 
     34 assert.sameValue(lengthDesc.value, 3, '[[Value]]');
     35 assert.sameValue(lengthDesc.writable, false, '[[Writable]]');
     36 assert.sameValue(lengthDesc.enumerable, false, '[[Enumerable]]');
     37 assert.sameValue(lengthDesc.configurable, false, '[[Configurable]]');
     38 
     39 reportCompare(0, 0);