mirror of https://github.com/tc39/test262.git
Proxy: isExtensible
This commit is contained in:
parent
54f3f23f72
commit
15a9a15815
|
@ -0,0 +1,31 @@
|
||||||
|
// 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.3
|
||||||
|
description: >
|
||||||
|
The trap is called with handler on its context and the target object as the
|
||||||
|
first parabeter
|
||||||
|
info: >
|
||||||
|
[[IsExtensible]] ( )
|
||||||
|
|
||||||
|
...
|
||||||
|
8. Let booleanTrapResult be ToBoolean(Call(trap, handler, «target»)).
|
||||||
|
...
|
||||||
|
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var _target, _handler;
|
||||||
|
var target = {};
|
||||||
|
var handler = {
|
||||||
|
isExtensible: function(t) {
|
||||||
|
_handler = this;
|
||||||
|
_target = t;
|
||||||
|
return Object.isExtensible(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var p = new Proxy(target, handler);
|
||||||
|
|
||||||
|
Object.isExtensible(p);
|
||||||
|
|
||||||
|
assert.sameValue(_handler, handler);
|
||||||
|
assert.sameValue(_target, target);
|
|
@ -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: 9.5.3
|
||||||
|
description: >
|
||||||
|
Throws a TypeError exception if handler is null
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var p = Proxy.revocable({}, {});
|
||||||
|
|
||||||
|
p.revoke();
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Object.isExtensible(p.proxy);
|
||||||
|
});
|
|
@ -0,0 +1,25 @@
|
||||||
|
// 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.3
|
||||||
|
description: >
|
||||||
|
Trap returns abrupt.
|
||||||
|
info: >
|
||||||
|
[[IsExtensible]] ( )
|
||||||
|
|
||||||
|
...
|
||||||
|
8. Let booleanTrapResult be ToBoolean(Call(trap, handler, «target»)).
|
||||||
|
9. ReturnIfAbrupt(booleanTrapResult).
|
||||||
|
...
|
||||||
|
includes: [Test262Error.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var p = new Proxy({}, {
|
||||||
|
isExtensible: function(t) {
|
||||||
|
throw new Test262Error();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
Object.isExtensible(p);
|
||||||
|
});
|
|
@ -0,0 +1,24 @@
|
||||||
|
// 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.3
|
||||||
|
description: >
|
||||||
|
The trap returns a boolean result.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var target = {};
|
||||||
|
var p = new Proxy(target, {
|
||||||
|
isExtensible: function(t) {
|
||||||
|
if ( Object.isExtensible(t) ) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.sameValue(Object.isExtensible(p), true);
|
||||||
|
|
||||||
|
Object.preventExtensions(target);
|
||||||
|
|
||||||
|
assert.sameValue(Object.isExtensible(p), false);
|
|
@ -0,0 +1,25 @@
|
||||||
|
// 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.3
|
||||||
|
description: >
|
||||||
|
Throws a TypeError exception if boolean trap result is not the same as
|
||||||
|
target.[[IsExtensible]]() result
|
||||||
|
info: >
|
||||||
|
[[IsExtensible]] ( )
|
||||||
|
|
||||||
|
...
|
||||||
|
12. If SameValue(booleanTrapResult, targetResult) is false, throw a
|
||||||
|
TypeError exception.
|
||||||
|
...
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var p = new Proxy({}, {
|
||||||
|
isExtensible: function(t) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Object.isExtensible(p);
|
||||||
|
});
|
|
@ -0,0 +1,20 @@
|
||||||
|
// 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.3
|
||||||
|
description: >
|
||||||
|
Return trap result.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var target = {};
|
||||||
|
var p = new Proxy(target, {
|
||||||
|
isExtensible: function(t) {
|
||||||
|
return Object.isExtensible(t);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.sameValue(Object.isExtensible(p), true);
|
||||||
|
|
||||||
|
Object.preventExtensions(target);
|
||||||
|
|
||||||
|
assert.sameValue(Object.isExtensible(p), false);
|
|
@ -0,0 +1,30 @@
|
||||||
|
// 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.3
|
||||||
|
description: >
|
||||||
|
Throws a TypeError exception if trap is not callable.
|
||||||
|
info: >
|
||||||
|
[[IsExtensible]] ( )
|
||||||
|
|
||||||
|
...
|
||||||
|
1. Let handler be the value of the [[ProxyHandler]] internal slot of O.
|
||||||
|
...
|
||||||
|
5. Let trap be GetMethod(handler, "isExtensible").
|
||||||
|
...
|
||||||
|
7.3.9 GetMethod (O, P)
|
||||||
|
...
|
||||||
|
2. Let func be GetV(O, P).
|
||||||
|
5. If IsCallable(func) is false, throw a TypeError exception.
|
||||||
|
...
|
||||||
|
---*/
|
||||||
|
|
||||||
|
|
||||||
|
var target = {};
|
||||||
|
var p = new Proxy(target, {
|
||||||
|
isExtensible: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Object.isExtensible(p);
|
||||||
|
});
|
|
@ -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: 9.5.3
|
||||||
|
description: >
|
||||||
|
Return target.[[IsExtensible]]() if trap is undefined.
|
||||||
|
info: >
|
||||||
|
[[IsExtensible]] ( )
|
||||||
|
|
||||||
|
...
|
||||||
|
7. If trap is undefined, then
|
||||||
|
a. Return target.[[IsExtensible]]().
|
||||||
|
...
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var target = {};
|
||||||
|
var p = new Proxy(target, {});
|
||||||
|
|
||||||
|
assert.sameValue(Object.isExtensible(p), true);
|
||||||
|
|
||||||
|
Object.preventExtensions(target);
|
||||||
|
|
||||||
|
assert.sameValue(Object.isExtensible(p), false);
|
Loading…
Reference in New Issue