Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test ProxyCreate with revoked target and handler #2548

Merged
merged 4 commits into from
Mar 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions test/built-ins/Proxy/create-handler-is-revoked-proxy.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 9.5.15
esid: sec-proxycreate
description: >
Proxy ( target, handler )
...
4. If handler is a Proxy exotic object and the value of the
[[ProxyHandler]] internal slot of handler is null, throw a
TypeError exception.
...
A Proxy is created with its [[ProxyHandler]] as revoked Proxy.
info: |
ProxyCreate ( target, handler )

[...]
3. Let P be ! MakeBasicObject(« [[ProxyHandler]], [[ProxyTarget]] »).
[...]
7. Set P.[[ProxyHandler]] to handler.
8. Return P.
features: [Proxy]
---*/

var revocable = Proxy.revocable({}, {});

revocable.revoke();

assert.throws(TypeError, function() {
new Proxy({}, revocable.proxy);
});
var proxy = new Proxy({}, revocable.proxy);
assert.sameValue(typeof proxy, "object");
4 changes: 2 additions & 2 deletions test/built-ins/Proxy/create-target-is-not-callable.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 9.5.15
esid: sec-proxycreate
description: >
A Proxy exotic object is only callable if the given target is callable.
info: |
Expand All @@ -22,5 +22,5 @@ features: [Proxy]
var p = new Proxy({}, {});

assert.throws(TypeError, function() {
p.call();
p();
});
23 changes: 23 additions & 0 deletions test/built-ins/Proxy/create-target-is-revoked-function-proxy.js
Original file line number Diff line number Diff line change
@@ -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.
/*---
esid: sec-proxycreate
description: >
A Proxy is created with its [[ProxyTarget]] as revoked function Proxy.
info: |
ProxyCreate ( target, handler )

[...]
3. Let P be ! MakeBasicObject(« [[ProxyHandler]], [[ProxyTarget]] »).
[...]
6. Set P.[[ProxyTarget]] to target.
[...]
8. Return P.
features: [Proxy]
---*/

var revocable = Proxy.revocable(function() {}, {});
revocable.revoke();

var proxy = new Proxy(revocable.proxy, {});
assert.sameValue(typeof proxy, "function");
24 changes: 13 additions & 11 deletions test/built-ins/Proxy/create-target-is-revoked-proxy.js
Original file line number Diff line number Diff line change
@@ -1,21 +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: 9.5.15
esid: sec-proxycreate
description: >
Proxy ( target, handler )
...
2. If target is a Proxy exotic object and the value of the
[[ProxyHandler]] internal slot of target is null, throw a
TypeError exception.
...
A Proxy is created with its [[ProxyTarget]] as revoked Proxy.
info: |
ProxyCreate ( target, handler )

[...]
3. Let P be ! MakeBasicObject(« [[ProxyHandler]], [[ProxyTarget]] »).
[...]
6. Set P.[[ProxyTarget]] to target.
[...]
8. Return P.
features: [Proxy]
---*/

var revocable = Proxy.revocable({}, {});

revocable.revoke();

assert.throws(TypeError, function() {
new Proxy(revocable.proxy, {});
});
var proxy = new Proxy(revocable.proxy, {});
assert.sameValue(typeof proxy, "object");