tor-browser

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

script-decl-func-err-non-configurable.js (3266B)


      1 // Copyright (C) 2016 the V8 project authors. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 /*---
      4 esid: sec-globaldeclarationinstantiation
      5 es6id: 15.1.8
      6 description: >
      7  Declaration of function when there is a corresponding global property that is
      8  non-configurable but *not* a writable and configurable data property.
      9 info: |
     10  [...]
     11  9. Let declaredFunctionNames be a new empty List.
     12  10. For each d in varDeclarations, in reverse list order do
     13      a. If d is neither a VariableDeclaration or a ForBinding, then
     14         i. Assert: d is either a FunctionDeclaration or a
     15            GeneratorDeclaration.
     16         ii. NOTE If there are multiple FunctionDeclarations for the same name,
     17             the last declaration is used.
     18         iii. Let fn be the sole element of the BoundNames of d.
     19         iv. If fn is not an element of declaredFunctionNames, then
     20             1. Let fnDefinable be ? envRec.CanDeclareGlobalFunction(fn).
     21             2. If fnDefinable is false, throw a TypeError exception.
     22 
     23  8.1.1.4.16 CanDeclareGlobalFunction
     24 
     25  [...]
     26  6. If existingProp.[[Configurable]] is true, return true.
     27  7. If IsDataDescriptor(existingProp) is true and existingProp has attribute
     28     values {[[Writable]]: true, [[Enumerable]]: true}, return true.
     29  8. Return false. 
     30 ---*/
     31 
     32 Object.defineProperty(
     33  this,
     34  'data1',
     35  { configurable: false, value: 0, writable: true, enumerable: false }
     36 );
     37 
     38 Object.defineProperty(
     39  this,
     40  'data2',
     41  { configurable: false, value: 0, writable: false, enumerable: true }
     42 );
     43 
     44 Object.defineProperty(
     45  this,
     46  'data3',
     47  { configurable: false, value: 0, writable: false, enumerable: false }
     48 );
     49 
     50 Object.defineProperty(
     51  this,
     52  'accessor1',
     53  { 
     54    configurable: false,
     55    get: function() {},
     56    set: function() {},
     57    enumerable: true
     58  }
     59 );
     60 
     61 Object.defineProperty(
     62  this,
     63  'accessor2',
     64  { 
     65    configurable: false,
     66    get: function() {},
     67    set: function() {},
     68    enumerable: true
     69  }
     70 );
     71 
     72 assert.throws(TypeError, function() {
     73  $262.evalScript('var x; function data1() {}');
     74 }, 'writable, non-enumerable data property');
     75 assert.throws(ReferenceError, function() {
     76  x;
     77 }, 'bindings not created for writable, non-enumerable data property');
     78 
     79 assert.throws(TypeError, function() {
     80  $262.evalScript('var x; function data2() {}');
     81 }, 'non-writable, enumerable data property');
     82 assert.throws(ReferenceError, function() {
     83  x;
     84 }, 'bindings not created for non-writable, enumerable data property');
     85 
     86 assert.throws(TypeError, function() {
     87  $262.evalScript('var x; function data3() {}');
     88 }, 'non-writable, non-enumerable data property');
     89 assert.throws(ReferenceError, function() {
     90  x;
     91 }, 'bindings not created for non-writable, non-enumerable data property');
     92 
     93 assert.throws(TypeError, function() {
     94  $262.evalScript('var x; function accessor1() {}');
     95 }, 'enumerable accessor property');
     96 assert.throws(ReferenceError, function() {
     97  x;
     98 }, 'bindings not created for enumerableaccessor property');
     99 
    100 assert.throws(TypeError, function() {
    101  $262.evalScript('var x; function accessor2() {}');
    102 }, 'non-enumerable accessor property');
    103 assert.throws(ReferenceError, function() {
    104  x;
    105 }, 'bindings not created for non-enumerableaccessor property');
    106 
    107 reportCompare(0, 0);