tor-browser

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

trap-is-null-target-is-proxy.js (1122B)


      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-proxy-object-internal-methods-and-internal-slots-delete-p
      6 description: >
      7  If "deleteProperty" trap is null or undefined, [[Delete]] call is
      8  properly forwarded to [[ProxyTarget]] (which is also a Proxy object).
      9 info: |
     10  [[Delete]] ( P )
     11 
     12  [...]
     13  5. Let target be O.[[ProxyTarget]].
     14  6. Let trap be ? GetMethod(handler, "deleteProperty").
     15  7. If trap is undefined, then
     16    a. Return ? target.[[Delete]](P).
     17 features: [Proxy, Reflect]
     18 ---*/
     19 
     20 var stringTarget = new Proxy(new String("str"), {});
     21 var stringProxy = new Proxy(stringTarget, {
     22  deleteProperty: null,
     23 });
     24 
     25 assert(!Reflect.deleteProperty(stringProxy, "length"));
     26 assert.throws(TypeError, function() {
     27  "use strict";
     28  delete stringProxy[0];
     29 });
     30 
     31 
     32 var regExpTarget = new Proxy(/(?:)/g, {});
     33 var regExpProxy = new Proxy(regExpTarget, {
     34  deleteProperty: null,
     35 });
     36 
     37 assert(delete regExpProxy.foo);
     38 assert.throws(TypeError, function() {
     39  "use strict";
     40  delete regExpProxy.lastIndex;
     41 });
     42 
     43 reportCompare(0, 0);