Proxy.revocable

This commit is contained in:
Leonardo Balter 2015-06-02 16:53:51 -04:00
parent 9bbe7c6272
commit c3e71dcb0b
4 changed files with 73 additions and 0 deletions

View File

@ -0,0 +1,23 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 26.2.2.1
description: >
The returned object has a proxy property which is the created Proxy object
built with the given target and handler given parameters.
info: >
Proxy.revocable ( target, handler )
6. Perform CreateDataProperty(result, "proxy", p).
---*/
var target = {
attr: "foo"
};
var r = Proxy.revocable(target, {
get: function(t, prop) {
return t[prop] + "!";
}
});
assert.sameValue(r.proxy.attr, "foo!");

View File

@ -0,0 +1,19 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 26.2.2.1.1
description: >
Calling the revoked function again will return undefined
info: >
Proxy Revocation Functions
...
1. Let p be the value of Fs [[RevocableProxy]] internal slot.
2. If p is null, return undefined.
---*/
var r = Proxy.revocable({}, {});
r.revoke();
assert.sameValue(r.revoke(), undefined);

View File

@ -0,0 +1,16 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 26.2.2.1.1
description: >
Calling the revoked function returns undefined
info: >
Proxy Revocation Functions
...
7. Return undefined.
---*/
var r = Proxy.revocable({}, {});
assert.sameValue(r.revoke(), undefined);

View File

@ -0,0 +1,15 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 26.2.2.1
description: >
The returned object has a `revoked` property which is a function
info: >
Proxy.revocable ( target, handler )
7. Perform CreateDataProperty(result, "revoke", revoker).
---*/
var r = Proxy.revocable({}, {});
assert.sameValue(typeof r.revoke, "function");