Skip to content
Snippets Groups Projects
Commit 9bbe7c62 authored by Leonardo Balter's avatar Leonardo Balter
Browse files

Proxy: Core

parent a1437652
No related branches found
No related tags found
No related merge requests found
Showing
with 321 additions and 0 deletions
// 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.1
description: >
The Proxy constructor is the %Proxy% intrinsic object and the
initial value of the Proxy property of the global object.
---*/
assert.sameValue(typeof Proxy, "function", "`typeof Proxy` is `'function'`");
// 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
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.
...
---*/
var revocable = Proxy.revocable({}, {});
revocable.revoke();
assert.throws(TypeError, function() {
new Proxy({}, revocable.proxy);
});
// 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
description: >
Proxy ( target, handler )
...
3. If Type(handler) is not Object, throw a TypeError exception.
...
---*/
assert.throws(TypeError, function() {
new Proxy({}, false);
});
// 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
description: >
Proxy ( target, handler )
...
3. If Type(handler) is not Object, throw a TypeError exception.
...
---*/
assert.throws(TypeError, function() {
new Proxy({}, null);
});
// 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
description: >
Proxy ( target, handler )
...
3. If Type(handler) is not Object, throw a TypeError exception.
...
---*/
assert.throws(TypeError, function() {
new Proxy({}, 0);
});
// 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
description: >
Proxy ( target, handler )
...
3. If Type(handler) is not Object, throw a TypeError exception.
...
---*/
assert.throws(TypeError, function() {
new Proxy({}, "");
});
// 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
description: >
Proxy ( target, handler )
...
3. If Type(handler) is not Object, throw a TypeError exception.
...
features: [Symbol]
---*/
assert.throws(TypeError, function() {
new Proxy({}, Symbol());
});
// 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
description: >
Proxy ( target, handler )
...
3. If Type(handler) is not Object, throw a TypeError exception.
...
---*/
assert.throws(TypeError, function() {
new Proxy({}, undefined);
});
// 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
description: >
A Proxy exotic object is only callable if the given target is callable.
info: >
Proxy ( target, handler )
7. If IsCallable(target) is true, then
a. Set the [[Call]] internal method of P as specified in 9.5.13.
...
12.3.4.3 Runtime Semantics: EvaluateDirectCall( func, thisValue, arguments,
tailPosition )
4. If IsCallable(func) is false, throw a TypeError exception.
---*/
var p = new Proxy({}, {});
assert.throws(TypeError, function() {
p.call();
});
// 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
description: >
A Proxy exotic object only accepts a constructor call if target is
constructor.
info: >
Proxy ( target, handler )
7. If IsCallable(target) is true, then
b. If target has a [[Construct]] internal method, then
i. Set the [[Construct]] internal method of P as specified in
9.5.14.
...
12.3.3.1.1 Runtime Semantics: EvaluateNew(constructProduction, arguments)
8. If IsConstructor (constructor) is false, throw a TypeError exception.
---*/
var p = new Proxy(eval, {});
p(); // the Proxy object is callable
assert.throws(TypeError, function() {
new p();
});
// 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
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.
...
---*/
var revocable = Proxy.revocable({}, {});
revocable.revoke();
assert.throws(TypeError, function() {
new Proxy(revocable.proxy, {});
});
// 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
description: >
Proxy ( target, handler )
...
1. If Type(target) is not Object, throw a TypeError exception.
...
---*/
assert.throws(TypeError, function() {
new Proxy(false, {});
});
// 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
description: >
Proxy ( target, handler )
...
1. If Type(target) is not Object, throw a TypeError exception.
...
---*/
assert.throws(TypeError, function() {
new Proxy(null, {});
});
// 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
description: >
Proxy ( target, handler )
...
1. If Type(target) is not Object, throw a TypeError exception.
...
---*/
assert.throws(TypeError, function() {
new Proxy(0, {});
});
// 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
description: >
Proxy ( target, handler )
...
1. If Type(target) is not Object, throw a TypeError exception.
...
---*/
assert.throws(TypeError, function() {
new Proxy("", {});
});
// 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
description: >
Proxy ( target, handler )
...
1. If Type(target) is not Object, throw a TypeError exception.
...
features: [Symbol]
---*/
assert.throws(TypeError, function() {
new Proxy(Symbol(), {});
});
// 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
description: >
Proxy ( target, handler )
...
1. If Type(target) is not Object, throw a TypeError exception.
...
---*/
assert.throws(TypeError, function() {
new Proxy(undefined, {});
});
// 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
description: >
The value of the [[Prototype]] internal slot of the Proxy
constructor is the intrinsic object %FunctionPrototype% (19.2.3).
---*/
assert.sameValue(
Object.getPrototypeOf(Proxy),
Function.prototype,
"`Object.getPrototypeOf(Proxy)` returns `Function.prototype`"
);
// 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
description: >
Properties of the Proxy Constructor
Besides the length property (whose value is 2)
includes: [propertyHelper.js]
---*/
assert.sameValue(Proxy.length, 2, "The value of `Proxy.length` is `2`");
verifyNotEnumerable(Proxy, "length");
verifyNotWritable(Proxy, "length");
verifyConfigurable(Proxy, "length");
// 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.1.1
description: >
Proxy ( target, handler )
17 ECMAScript Standard Built-in Objects
includes: [propertyHelper.js]
---*/
assert.sameValue(Proxy.name, "Proxy", "The value of `Proxy.name` is `'Proxy'`");
verifyNotEnumerable(Proxy, "name");
verifyNotWritable(Proxy, "name");
verifyConfigurable(Proxy, "name");
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment