nodejs/deps/v8/test/mjsunit/regress/regress-crbug-768080.js
Michaël Zasso e31f0a7d25
deps: update V8 to 7.7.299.4
PR-URL: https://github.com/nodejs/node/pull/28918
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-08-19 09:25:23 +02:00

69 lines
1.7 KiB
JavaScript

// 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.
// Flags: --allow-natives-syntax
(function TestReflectConstructBogusNewTarget1() {
class C {}
function g() {
Reflect.construct(C, arguments, 23);
}
function f() {
return new g();
};
%PrepareFunctionForOptimization(f);
new C(); // Warm-up!
assertThrows(f, TypeError);
assertThrows(f, TypeError);
%OptimizeFunctionOnNextCall(f);
assertThrows(f, TypeError);
})();
(function TestReflectConstructBogusNewTarget2() {
class C {}
// Note that {unescape} is an example of a non-constructable function. If that
// ever changes and this test needs to be adapted, make sure to choose another
// non-constructable {JSFunction} object instead.
function g() {
Reflect.construct(C, arguments, unescape);
}
function f() {
return new g();
};
%PrepareFunctionForOptimization(f);
new C(); // Warm-up!
assertThrows(f, TypeError);
assertThrows(f, TypeError);
%OptimizeFunctionOnNextCall(f);
assertThrows(f, TypeError);
})();
(function TestReflectConstructBogusTarget() {
function g() {
Reflect.construct(23, arguments);
}
function f() {
return new g();
};
%PrepareFunctionForOptimization(f);
assertThrows(f, TypeError);
assertThrows(f, TypeError);
%OptimizeFunctionOnNextCall(f);
assertThrows(f, TypeError);
})();
(function TestReflectApplyBogusTarget() {
function g() {
Reflect.apply(23, this, arguments);
}
function f() {
return g();
};
%PrepareFunctionForOptimization(f);
assertThrows(f, TypeError);
assertThrows(f, TypeError);
%OptimizeFunctionOnNextCall(f);
assertThrows(f, TypeError);
})();