2017-03-23 18:33:38 +00:00
|
|
|
// 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.
|
|
|
|
|
|
|
|
var global = this;
|
|
|
|
;(function () {
|
|
|
|
var calledDelete = false;
|
|
|
|
var calledGet = false;
|
|
|
|
var calledHas = false;
|
|
|
|
var calledSet = false;
|
2019-10-25 15:55:25 +00:00
|
|
|
var target = {getGlobal: 1};
|
2017-03-23 18:33:38 +00:00
|
|
|
var assertEquals = global.assertEquals;
|
|
|
|
var proxy = new Proxy(target, {
|
|
|
|
has(target, property) {
|
|
|
|
calledHas = true;
|
|
|
|
return Reflect.has(target, property);
|
|
|
|
},
|
|
|
|
get(target, property, receiver) {
|
|
|
|
calledGet = true;
|
|
|
|
return Reflect.get(target, property, receiver);
|
|
|
|
},
|
|
|
|
set(targer, property, value, receiver) {
|
|
|
|
calledSet = true;
|
|
|
|
return Reflect.set(target, property, value, receiver);
|
|
|
|
},
|
|
|
|
delete(target, property, receiver) {
|
|
|
|
calledDelete = true;
|
|
|
|
return Reflect.delete(target, property, receiver);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Object.setPrototypeOf(global, proxy);
|
|
|
|
getGlobal;
|
|
|
|
assertTrue(calledGet);
|
|
|
|
makeGlobal = 2;
|
|
|
|
assertTrue(calledSet);
|
|
|
|
"findGlobal" in global;
|
|
|
|
assertTrue(calledHas);
|
2019-10-25 15:55:25 +00:00
|
|
|
assertEquals("number", typeof(makeGlobal));
|
2017-03-23 18:33:38 +00:00
|
|
|
var deletedOwn = delete makeGlobal;
|
|
|
|
assertTrue(deletedOwn);
|
2019-10-25 15:55:25 +00:00
|
|
|
assertEquals("undefined", typeof(makeGlobal));
|
2017-03-23 18:33:38 +00:00
|
|
|
})();
|