2016-06-09 06:22:07 +00:00
|
|
|
// Copyright 2016 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
|
|
|
|
|
2019-06-12 14:00:50 +00:00
|
|
|
g = async function() {
|
2018-07-26 11:32:20 +00:00
|
|
|
await 10;
|
2019-06-12 14:00:50 +00:00
|
|
|
};
|
|
|
|
assertEquals(undefined, g.prototype);
|
2018-07-26 11:32:20 +00:00
|
|
|
g();
|
2019-06-12 14:00:50 +00:00
|
|
|
assertEquals(undefined, g.prototype);
|
2018-07-26 11:32:20 +00:00
|
|
|
|
2019-06-12 14:00:50 +00:00
|
|
|
gen = function*() {
|
2018-07-26 11:32:20 +00:00
|
|
|
yield 10;
|
2019-06-12 14:00:50 +00:00
|
|
|
};
|
|
|
|
assertTrue(gen.prototype != undefined && gen.prototype != null);
|
|
|
|
gen();
|
|
|
|
assertTrue(gen.prototype != undefined && gen.prototype != null);
|
2018-07-26 11:32:20 +00:00
|
|
|
|
2019-06-12 14:00:50 +00:00
|
|
|
async_gen = async function*() {
|
2018-07-26 11:32:20 +00:00
|
|
|
yield 10;
|
2019-06-12 14:00:50 +00:00
|
|
|
};
|
|
|
|
assertTrue(async_gen.prototype != undefined && async_gen.prototype != null);
|
|
|
|
async_gen();
|
|
|
|
assertTrue(async_gen.prototype != undefined && async_gen.prototype != null);
|
2018-07-26 11:32:20 +00:00
|
|
|
|
2016-06-09 06:22:07 +00:00
|
|
|
function foo(x) {
|
|
|
|
return x instanceof Proxy;
|
2019-06-12 14:00:50 +00:00
|
|
|
};
|
|
|
|
%PrepareFunctionForOptimization(foo);
|
2018-07-26 11:32:20 +00:00
|
|
|
function test_for_exception() {
|
|
|
|
caught_exception = false;
|
|
|
|
try {
|
|
|
|
foo({});
|
|
|
|
} catch (e) {
|
|
|
|
caught_exception = true;
|
|
|
|
assertEquals(
|
|
|
|
'Function has non-object prototype \'undefined\' in instanceof check',
|
|
|
|
e.message);
|
|
|
|
} finally {
|
2019-06-12 14:00:50 +00:00
|
|
|
assertTrue(caught_exception);
|
2018-07-26 11:32:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
test_for_exception();
|
|
|
|
test_for_exception();
|
2016-06-09 06:22:07 +00:00
|
|
|
%OptimizeFunctionOnNextCall(foo);
|
2018-07-26 11:32:20 +00:00
|
|
|
test_for_exception();
|
|
|
|
|
|
|
|
Proxy.__proto__.prototype = Function.prototype;
|
|
|
|
assertTrue((() => {}) instanceof Proxy);
|
|
|
|
|
|
|
|
assertEquals(
|
|
|
|
new Proxy({}, {
|
|
|
|
get(o, s) {
|
2019-06-12 14:00:50 +00:00
|
|
|
return s;
|
2018-07-26 11:32:20 +00:00
|
|
|
}
|
|
|
|
}).test,
|
|
|
|
'test');
|
|
|
|
|
|
|
|
Proxy.__proto__ = {
|
|
|
|
prototype: {b: 2},
|
|
|
|
a: 1
|
|
|
|
};
|
2019-06-12 14:00:50 +00:00
|
|
|
|
2018-07-26 11:32:20 +00:00
|
|
|
assertEquals(Proxy.prototype, {b: 2});
|
2018-08-02 08:22:11 +00:00
|
|
|
|
|
|
|
(function testProxyCreationContext() {
|
|
|
|
let realm = Realm.create();
|
|
|
|
let p1 = new Proxy({}, {});
|
|
|
|
let p2 = Realm.eval(realm, "new Proxy({}, {})");
|
|
|
|
assertEquals(0, Realm.owner(p1));
|
|
|
|
assertEquals(1, Realm.owner(p2));
|
|
|
|
})();
|