private-fields-proxy-default-handler-throws.js (685B)
1 // Copyright (C) 2018 Rick Waldron. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 esid: sec-privatefieldget 6 description: Private fields not accessible via default Proxy handler 7 info: | 8 1. Assert: P is a Private Name value. 9 2. If O is not an object, throw a TypeError exception. 10 3. Let entry be PrivateFieldFind(P, O). 11 4. If entry is empty, throw a TypeError exception. 12 13 features: [class, class-fields-private] 14 ---*/ 15 16 17 var C = class { 18 #x = 1; 19 x() { 20 return this.#x; 21 } 22 } 23 24 var c = new C(); 25 var p = new Proxy(c, {}); 26 27 assert.sameValue(c.x(), 1); 28 assert.throws(TypeError, function() { 29 p.x(); 30 }); 31 32 reportCompare(0, 0);