summaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit/harmony/proxies-with-unscopables.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/test/mjsunit/harmony/proxies-with-unscopables.js')
-rw-r--r--deps/v8/test/mjsunit/harmony/proxies-with-unscopables.js77
1 files changed, 34 insertions, 43 deletions
diff --git a/deps/v8/test/mjsunit/harmony/proxies-with-unscopables.js b/deps/v8/test/mjsunit/harmony/proxies-with-unscopables.js
index 8a03ef481e..c87492c61d 100644
--- a/deps/v8/test/mjsunit/harmony/proxies-with-unscopables.js
+++ b/deps/v8/test/mjsunit/harmony/proxies-with-unscopables.js
@@ -5,22 +5,18 @@
// Flags: --harmony-proxies
-// TODO(arv): Once proxies can intercept symbols, add more tests.
-
-
function TestBasics() {
var log = [];
- var proxy = Proxy.create({
- getPropertyDescriptor: function(key) {
- log.push(key);
- if (key === 'x') {
- return {
- value: 1,
- configurable: true
- };
- }
- return undefined;
+ var proxy = new Proxy({}, {
+ get: function(target, key) {
+ log.push("get " + String(key));
+ if (key === 'x') return 1;
+ },
+ has: function(target, key) {
+ log.push("has " + String(key));
+ if (key === 'x') return true;
+ return false;
}
});
@@ -30,27 +26,24 @@ function TestBasics() {
assertEquals(1, x);
}
- // One 'x' for HasBinding and one for GetBindingValue
- assertEquals(['assertEquals', 'x', 'x'], log);
+ assertEquals(['has assertEquals', 'has x', 'get Symbol(Symbol.unscopables)',
+ 'get x'], log);
}
TestBasics();
function TestInconsistent() {
var log = [];
- var calls = 0;
- var proxy = Proxy.create({
- getPropertyDescriptor: function(key) {
- log.push(key);
- if (key === 'x' && calls < 1) {
- calls++;
- return {
- value: 1,
- configurable: true
- };
- }
+ var proxy = new Proxy({}, {
+ get: function(target, key) {
+ log.push("get " + String(key));
return undefined;
+ },
+ has: function(target, key) {
+ log.push("has " + String(key));
+ if (key === 'x') return true;
+ return false;
}
});
@@ -60,8 +53,8 @@ function TestInconsistent() {
assertEquals(void 0, x);
}
- // One 'x' for HasBinding and one for GetBindingValue
- assertEquals(['assertEquals', 'x', 'x'], log);
+ assertEquals(['has assertEquals', 'has x', 'get Symbol(Symbol.unscopables)',
+ 'get x'], log);
}
TestInconsistent();
@@ -72,19 +65,14 @@ function TestUseProxyAsUnscopables() {
x: 2
};
var calls = 0;
- var proxy = Proxy.create({
- has: function(key) {
+ var proxy = new Proxy({}, {
+ has: function() {
assertUnreachable();
},
- getPropertyDescriptor: function(key) {
- calls++;
+ get: function(target, key) {
assertEquals('x', key);
- return {
- value: calls === 2 ? true : undefined,
- configurable: true,
- enumerable: true,
- writable: true,
- };
+ calls++;
+ return calls === 2 ? true : undefined;
}
});
@@ -110,11 +98,11 @@ function TestThrowInHasUnscopables() {
function CustomError() {}
var calls = 0;
- var proxy = Proxy.create({
- has: function(key) {
+ var proxy = new Proxy({}, {
+ has: function() {
assertUnreachable();
},
- getPropertyDescriptor: function(key) {
+ get: function(target, key) {
if (calls++ === 0) {
throw new CustomError();
}
@@ -136,8 +124,11 @@ TestThrowInHasUnscopables();
var global = this;
function TestGlobalShouldIgnoreUnscopables() {
global.x = 1;
- var proxy = Proxy.create({
- getPropertyDescriptor: function() {
+ var proxy = new Proxy({}, {
+ get: function() {
+ assertUnreachable();
+ },
+ has: function() {
assertUnreachable();
}
});