Implement corectness tests for Proxies constructor

Bug: 
Change-Id: Iea628676cd81f6917e6118657cfd60247a666b5a
Reviewed-on: https://chromium-review.googlesource.com/559329
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: Camillo Bruni <cbruni@chromium.org>
Commit-Queue: Maya Lekova <mslekova@google.com>
Cr-Commit-Position: refs/heads/master@{#46402}
This commit is contained in:
Maya Lekova 2017-07-05 09:48:07 +02:00 committed by Commit Bot
parent e81af43045
commit f447e678a6

View File

@ -0,0 +1,49 @@
// Copyright 2017 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.
(function testNonObjectTargetTypes() {
assertThrows(function(){ new Proxy(undefined, {}); }, TypeError);
assertThrows(function(){ new Proxy(null, {}); }, TypeError);
assertThrows(function(){ new Proxy('', {}); }, TypeError);
assertThrows(function(){ new Proxy(0, {}); }, TypeError);
assertThrows(function(){ new Proxy(0.5, {}); }, TypeError);
assertThrows(function(){ new Proxy(false, {}); }, TypeError);
})();
(function testRevokedTarget() {
var revocable = Proxy.revocable({}, {});
revocable.revoke();
assertThrows(function(){ new Proxy(revocable.proxy, {}); }, TypeError);
})();
(function testNonObjectHandlerTypes() {
assertThrows(function(){ new Proxy({}, undefined); }, TypeError);
assertThrows(function(){ new Proxy({}, null); }, TypeError);
assertThrows(function(){ new Proxy({}, ''); }, TypeError);
assertThrows(function(){ new Proxy({}, 0); }, TypeError);
assertThrows(function(){ new Proxy({}, 0.5); }, TypeError);
assertThrows(function(){ new Proxy({}, false); }, TypeError);
})();
(function testRevokedHandler() {
var revocable = Proxy.revocable({}, {});
revocable.revoke();
assertThrows(function(){ new Proxy({}, revocable.proxy); }, TypeError);
})();