tor-browser

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

resultdesc-is-not-configurable-not-writable-targetdesc-is-writable.js (1123B)


      1 // Copyright (C) 2019 Aleksey Shvayka. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 /*---
      4 esid: sec-proxy-object-internal-methods-and-internal-slots-getownproperty-p
      5 description: >
      6    Throws a TypeError exception if resultDesc is both non-configurable and
      7    non-writable, while targetDesc is writable.
      8 info: |
      9    [[GetOwnProperty]] (P)
     10 
     11    ...
     12    17. If resultDesc.[[Configurable]] is false, then
     13        ...
     14        b. If resultDesc has a [[Writable]] field and resultDesc.[[Writable]] is
     15        false, then
     16            i. If targetDesc.[[Writable]] is true, throw a TypeError exception.
     17    ...
     18 features: [Proxy, proxy-missing-checks]
     19 ---*/
     20 
     21 var trapCalls = 0;
     22 var p = new Proxy({}, {
     23  getOwnPropertyDescriptor: function(t, prop) {
     24    Object.defineProperty(t, prop, {
     25      configurable: false,
     26      writable: true,
     27    });
     28 
     29    trapCalls++;
     30    return {
     31      configurable: false,
     32      writable: false,
     33    };
     34  },
     35 });
     36 
     37 assert.throws(TypeError, function() {
     38  Object.getOwnPropertyDescriptor(p, "prop");
     39 });
     40 assert.sameValue(trapCalls, 1);
     41 
     42 reportCompare(0, 0);