From 22978d381c3e5d19f7ce0a8cb85149d5a79773ee Mon Sep 17 00:00:00 2001 From: Gus Caplan Date: Mon, 2 Dec 2019 07:42:08 -0800 Subject: [PATCH] add test for typeof proxy (#2438) --- test/language/expressions/typeof/proxy.js | 41 +++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 test/language/expressions/typeof/proxy.js diff --git a/test/language/expressions/typeof/proxy.js b/test/language/expressions/typeof/proxy.js new file mode 100644 index 0000000000..8f85eb0664 --- /dev/null +++ b/test/language/expressions/typeof/proxy.js @@ -0,0 +1,41 @@ +// Copyright (C) 2019 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: | + The typeof operator on an proxy should match the typeof value the proxy wraps, + even if the proxy is later revoked. +esid: sec-typeof-operator +info: | + The typeof Operator + + Runtime Semantics: Evaluation + + ... + Return a String according to Table 35. + + #table-35 + + Object (does not implement [[Call]]) "object" + Object (implements [[Call]]) "function" + + + ProxyCreate ( target, handler ) + ... + 7. If IsCallable(target) is true, then + a. Set P.[[Call]] as specified in 9.5.12. + ... +features: [Proxy] +---*/ + +assert.sameValue(typeof new Proxy({}, {}), 'object'); + +assert.sameValue(typeof new Proxy(function() {}, {}), 'function'); + +const rp1 = Proxy.revocable({}, {}); +rp1.revoke(); +assert.sameValue(typeof rp1.proxy, 'object'); + +const rp2 = Proxy.revocable(function() {}, {}); +rp2.revoke(); +assert.sameValue(typeof rp2.proxy, 'function');