tor-browser

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

resultdesc-is-not-configurable-targetdesc-is-configurable.js (969B)


      1 // Copyright (C) 2015 the V8 project authors. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 /*---
      4 es6id: 9.5.5
      5 description: >
      6    Throws a TypeError exception if trap result is not configurable but target
      7    property descriptor is configurable.
      8 info: |
      9    [[GetOwnProperty]] (P)
     10 
     11    ...
     12    22. If resultDesc.[[Configurable]] is false, then
     13        a. If targetDesc is undefined or targetDesc.[[Configurable]] is true,
     14        then
     15            i. Throw a TypeError exception.
     16    ...
     17 features: [Proxy]
     18 ---*/
     19 
     20 var target = {
     21  bar: 1
     22 };
     23 
     24 var p = new Proxy(target, {
     25  getOwnPropertyDescriptor: function(t, prop) {
     26    var foo = {};
     27 
     28    Object.defineProperty(foo, "bar", {
     29      configurable: false,
     30      enumerable: true,
     31      value: 1
     32    });
     33 
     34    return Object.getOwnPropertyDescriptor(foo, prop);
     35  }
     36 });
     37 
     38 assert.throws(TypeError, function() {
     39  Object.getOwnPropertyDescriptor(p, "bar");
     40 });
     41 
     42 reportCompare(0, 0);