1/* Copyright JS Foundation and other contributors, http://js.foundation 2 * 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16var o = new Proxy (function f () {}, { get(t,p,r) { if (p == "prototype") { throw 42.1 } Reflect.get(...arguments) }}) 17 18try { 19 Reflect.construct (Map, [], o); 20 assert (false); 21} catch (e) { 22 assert(e == 42.1) 23} 24 25try { 26 Reflect.construct (Set, [], o); 27 assert (false); 28} catch (e) { 29 assert(e == 42.1) 30} 31 32try { 33 Reflect.construct (WeakMap, [], o); 34 assert (false); 35} catch (e) { 36 assert(e == 42.1) 37} 38 39try { 40 Reflect.construct (WeakSet, [], o); 41 assert (false); 42} catch (e) { 43 assert(e == 42.1) 44} 45 46try { 47 Reflect.construct (Map); 48 assert (false); 49} catch (e) { 50 assert (e instanceof TypeError); 51} 52 53try { 54 Reflect.construct (Set); 55 assert (false); 56} catch (e) { 57 assert (e instanceof TypeError); 58} 59 60try { 61 Reflect.construct (WeakMap); 62 assert (false); 63} catch (e) { 64 assert (e instanceof TypeError); 65} 66 67try { 68 Reflect.construct (WeakSet); 69 assert (false); 70} catch (e) { 71 assert (e instanceof TypeError); 72} 73 74class MyMap extends Map {}; 75class MySet extends Set {}; 76class MyWeakMap extends WeakMap {}; 77class MyWeakSet extends WeakSet {}; 78var m1= new MyMap(); 79var s1= new MySet(); 80var wm1= new MyWeakMap(); 81var ws1= new MyWeakSet(); 82 83assert(Object.getPrototypeOf(m1) == MyMap.prototype) 84assert(Object.getPrototypeOf(s1) == MySet.prototype) 85assert(Object.getPrototypeOf(wm1) == MyWeakMap.prototype) 86assert(Object.getPrototypeOf(ws1) == MyWeakSet.prototype) 87