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// TODO: Update these tests when the internal routine has been implemented 16 17var target = function () {}; 18var handler = { get (name) { 19 return 5; 20}}; 21 22var revocable = Proxy.revocable(target, handler); 23 24var proxy = revocable.proxy; 25 26assert(proxy.a === 5); 27 28revocable.revoke(); 29 30try { 31 proxy.a; 32 assert(false); 33} catch (e) { 34 assert(e instanceof TypeError); 35} 36 37try { 38 Proxy.revocable(); 39 assert(false); 40} catch (e) { 41 assert(e instanceof TypeError); 42} 43 44try { 45 Proxy.revocable(proxy); 46 assert(false); 47} catch (e) { 48 assert(e instanceof TypeError); 49} 50 51try { 52 Proxy.revocable({}, proxy); 53 assert(false); 54} catch (e) { 55 assert(e instanceof TypeError); 56} 57 58try { 59 Proxy.revocable(proxy, {}); 60 assert(false); 61} catch (e) { 62 assert(e instanceof TypeError); 63} 64 65