0fbf170821
Spec: https://tc39.github.io/ecma262/#sec-proxy-constructor Bug: v8:6664 Change-Id: Ia8b5ed75841d813babd1db4743c3bb9d25658b51 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1553007 Reviewed-by: Jakob Gruber <jgruber@chromium.org> Reviewed-by: Maya Lekova <mslekova@chromium.org> Commit-Queue: Z Nguyen-Huu <duongn@microsoft.com> Cr-Commit-Position: refs/heads/master@{#60892}
30 lines
977 B
JavaScript
30 lines
977 B
JavaScript
// Copyright 2015 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
|
|
traps = [
|
|
"getPrototypeOf", "setPrototypeOf", "isExtensible", "preventExtensions",
|
|
"getOwnPropertyDescriptor", "has", "get", "set", "deleteProperty",
|
|
"defineProperty", "ownKeys", "apply", "construct"
|
|
];
|
|
|
|
var {proxy, revoke} = Proxy.revocable({}, {});
|
|
assertEquals(0, revoke.length);
|
|
|
|
assertEquals(undefined, revoke());
|
|
for (var trap of traps) {
|
|
assertThrows(() => Reflect[trap](proxy), TypeError);
|
|
}
|
|
|
|
assertEquals(undefined, revoke());
|
|
for (var trap of traps) {
|
|
assertThrows(() => Reflect[trap](proxy), TypeError);
|
|
}
|
|
|
|
// Throw TypeError if target or handler is revoked proxy
|
|
var revocable = Proxy.revocable({}, {});
|
|
revocable.revoke();
|
|
assertThrows(function(){ Proxy.revocable(revocable.proxy, {}); }, TypeError);
|
|
assertThrows(function(){ Proxy.revocable({}, revocable.proxy); }, TypeError);
|