diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/Proxy/revocable')
20 files changed, 449 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Proxy/revocable/browser.js b/js/src/tests/test262/built-ins/Proxy/revocable/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Proxy/revocable/browser.js diff --git a/js/src/tests/test262/built-ins/Proxy/revocable/builtin.js b/js/src/tests/test262/built-ins/Proxy/revocable/builtin.js new file mode 100644 index 0000000000..90413beaa1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Proxy/revocable/builtin.js @@ -0,0 +1,30 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-proxy.revocable +description: > + Requirements for built-in functions, defined in introduction of chapter 17, + are satisfied. +features: [Proxy, Reflect.construct] +---*/ + +assert(Object.isExtensible(Proxy.revocable), 'Object.isExtensible(Proxy.revocable) must return true'); +assert.sameValue(typeof Proxy.revocable, 'function', 'The value of `typeof Proxy.revocable` is "function"'); +assert.sameValue( + Object.prototype.toString.call(Proxy.revocable), + '[object Function]', + 'Object.prototype.toString.call(Proxy.revocable) must return "[object Function]"' +); +assert.sameValue( + Object.getPrototypeOf(Proxy.revocable), + Function.prototype, + 'Object.getPrototypeOf(Proxy.revocable) must return the value of Function.prototype' +); + +assert.sameValue( + Proxy.revocable.hasOwnProperty('prototype'), + false, + 'Proxy.revocable.hasOwnProperty(\'prototype\') must return false' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Proxy/revocable/handler-is-revoked-proxy.js b/js/src/tests/test262/built-ins/Proxy/revocable/handler-is-revoked-proxy.js new file mode 100644 index 0000000000..c2bf8a2a1b --- /dev/null +++ b/js/src/tests/test262/built-ins/Proxy/revocable/handler-is-revoked-proxy.js @@ -0,0 +1,24 @@ +// Copyright (C) 2020 Alexey Shvayka. 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 [[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 revocableHandler = Proxy.revocable({}, {}); +revocableHandler.revoke(); + +var revocable = Proxy.revocable({}, revocableHandler.proxy); +assert.sameValue(typeof revocable.proxy, "object"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Proxy/revocable/length.js b/js/src/tests/test262/built-ins/Proxy/revocable/length.js new file mode 100644 index 0000000000..8c1b055371 --- /dev/null +++ b/js/src/tests/test262/built-ins/Proxy/revocable/length.js @@ -0,0 +1,32 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 26.2.2.1 +description: > + Proxy.revocable.length is 2. +info: | + Proxy.revocable ( target, handler ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this + value is equal to the largest number of named arguments shown in the + subclause headings for the function description, including optional + parameters. However, rest parameters shown using the form “...name” + are not included in the default argument count. + + Unless otherwise specified, the length property of a built-in Function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [Proxy] +---*/ + +assert.sameValue(Proxy.revocable.length, 2); + +verifyNotEnumerable(Proxy.revocable, "length"); +verifyNotWritable(Proxy.revocable, "length"); +verifyConfigurable(Proxy.revocable, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Proxy/revocable/name.js b/js/src/tests/test262/built-ins/Proxy/revocable/name.js new file mode 100644 index 0000000000..0e7ce54890 --- /dev/null +++ b/js/src/tests/test262/built-ins/Proxy/revocable/name.js @@ -0,0 +1,29 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 26.2.2.1 +description: > + Proxy.revocable.name is "revocable". +info: | + Proxy.revocable ( target, handler ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [Proxy] +---*/ + +assert.sameValue(Proxy.revocable.name, "revocable"); + +verifyNotEnumerable(Proxy.revocable, "name"); +verifyNotWritable(Proxy.revocable, "name"); +verifyConfigurable(Proxy.revocable, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Proxy/revocable/not-a-constructor.js b/js/src/tests/test262/built-ins/Proxy/revocable/not-a-constructor.js new file mode 100644 index 0000000000..0d1e9bdff5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Proxy/revocable/not-a-constructor.js @@ -0,0 +1,31 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Proxy.revocable does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, Reflect, arrow-function, Proxy] +---*/ + +assert.sameValue(isConstructor(Proxy.revocable), false, 'isConstructor(Proxy.revocable) must return false'); + +assert.throws(TypeError, () => { + new Proxy.revocable({}, {}); +}, '`new Proxy.revocable({}, {})` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Proxy/revocable/proxy.js b/js/src/tests/test262/built-ins/Proxy/revocable/proxy.js new file mode 100644 index 0000000000..2de6b80295 --- /dev/null +++ b/js/src/tests/test262/built-ins/Proxy/revocable/proxy.js @@ -0,0 +1,26 @@ +// 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). +features: [Proxy] +---*/ + +var target = { + attr: "foo" +}; +var r = Proxy.revocable(target, { + get: function(t, prop) { + return t[prop] + "!"; + } +}); + +assert.sameValue(r.proxy.attr, "foo!"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Proxy/revocable/revocation-function-extensible.js b/js/src/tests/test262/built-ins/Proxy/revocable/revocation-function-extensible.js new file mode 100644 index 0000000000..cf354bb1ee --- /dev/null +++ b/js/src/tests/test262/built-ins/Proxy/revocable/revocation-function-extensible.js @@ -0,0 +1,18 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 26.2.2.1.1 +description: The [[Extensible]] slot of Proxy Revocation functions +info: | + 17 ECMAScript Standard Built-in Objects: + Unless specified otherwise, the [[Extensible]] internal slot + of a built-in object initially has the value true. +features: [Proxy] +---*/ + +var revocationFunction = Proxy.revocable({}, {}).revoke; + +assert(Object.isExtensible(revocationFunction)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Proxy/revocable/revocation-function-length.js b/js/src/tests/test262/built-ins/Proxy/revocable/revocation-function-length.js new file mode 100644 index 0000000000..ac59134301 --- /dev/null +++ b/js/src/tests/test262/built-ins/Proxy/revocable/revocation-function-length.js @@ -0,0 +1,26 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 26.2.2.1.1 +description: The `length` property of Proxy Revocation functions +info: | + The length property of a Proxy revocation function is 0. + + 17 ECMAScript Standard Built-in Objects: + Unless otherwise specified, the length property of a built-in Function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [Proxy] +---*/ + +var revocationFunction = Proxy.revocable({}, {}).revoke; + +assert.sameValue(revocationFunction.length, 0); + +verifyNotEnumerable(revocationFunction, "length"); +verifyNotWritable(revocationFunction, "length"); +verifyConfigurable(revocationFunction, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Proxy/revocable/revocation-function-name.js b/js/src/tests/test262/built-ins/Proxy/revocable/revocation-function-name.js new file mode 100644 index 0000000000..5f066ff1bb --- /dev/null +++ b/js/src/tests/test262/built-ins/Proxy/revocable/revocation-function-name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 26.2.2.1.1 +description: The `name` property of Proxy Revocation functions +info: | + A Proxy revocation function is an anonymous function. + + 17 ECMAScript Standard Built-in Objects: + Every built-in function object, including constructors, has a `name` + property whose value is a String. Functions that are identified as + anonymous functions use the empty string as the value of the `name` + property. + Unless otherwise specified, the `name` property of a built-in function + object has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, + [[Configurable]]: *true* }. +includes: [propertyHelper.js] +features: [Proxy] +---*/ + +var revocationFunction = Proxy.revocable({}, {}).revoke; + +verifyProperty(revocationFunction, "name", { + value: "", writable: false, enumerable: false, configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Proxy/revocable/revocation-function-not-a-constructor.js b/js/src/tests/test262/built-ins/Proxy/revocable/revocation-function-not-a-constructor.js new file mode 100644 index 0000000000..643c7e57c2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Proxy/revocable/revocation-function-not-a-constructor.js @@ -0,0 +1,30 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-proxy.revocable +description: Proxy Revocation functions are not constructors +info: | + 17 ECMAScript Standard Built-in Objects: + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified + in the description of a particular function. +includes: [isConstructor.js] +features: [Proxy, Reflect.construct, arrow-function] +---*/ + +var revocationFunction = Proxy.revocable({}, {}).revoke; + +assert.sameValue( + Object.prototype.hasOwnProperty.call(revocationFunction, "prototype"), + false, + 'Object.prototype.hasOwnProperty.call(revocationFunction, "prototype") must return false' +); +assert.sameValue(isConstructor(revocationFunction), false, 'isConstructor(revocationFunction) must return false'); +assert.throws(TypeError, () => { + new revocationFunction(); +}, '`new revocationFunction()` throws TypeError'); + + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Proxy/revocable/revocation-function-property-order.js b/js/src/tests/test262/built-ins/Proxy/revocable/revocation-function-property-order.js new file mode 100644 index 0000000000..34af67cbc5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Proxy/revocable/revocation-function-property-order.js @@ -0,0 +1,19 @@ +// Copyright (C) 2020 ExE Boss. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-createbuiltinfunction +description: Proxy revocation function property order +info: | + Set order: "length", "name" +---*/ + +var revocationFunction = Proxy.revocable({}, {}).revoke; + +var propNames = Object.getOwnPropertyNames(revocationFunction); +var lengthIndex = propNames.indexOf("length"); +var nameIndex = propNames.indexOf("name"); + +assert(lengthIndex >= 0 && nameIndex === lengthIndex + 1, + "The `length` property comes before the `name` property on built-in functions"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Proxy/revocable/revocation-function-prototype.js b/js/src/tests/test262/built-ins/Proxy/revocable/revocation-function-prototype.js new file mode 100644 index 0000000000..2f245f35d4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Proxy/revocable/revocation-function-prototype.js @@ -0,0 +1,20 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 26.2.2.1.1 +description: The [[Prototype]] of Proxy Revocation functions +info: | + 17 ECMAScript Standard Built-in Objects: + Unless otherwise specified every built-in function and every built-in + constructor has the Function prototype object, which is the initial + value of the expression Function.prototype (19.2.3), as the value of + its [[Prototype]] internal slot. +features: [Proxy] +---*/ + +var revocationFunction = Proxy.revocable({}, {}).revoke; + +assert.sameValue(Object.getPrototypeOf(revocationFunction), Function.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Proxy/revocable/revoke-consecutive-call-returns-undefined.js b/js/src/tests/test262/built-ins/Proxy/revocable/revoke-consecutive-call-returns-undefined.js new file mode 100644 index 0000000000..f1d043fc18 --- /dev/null +++ b/js/src/tests/test262/built-ins/Proxy/revocable/revoke-consecutive-call-returns-undefined.js @@ -0,0 +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: 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 F’s [[RevocableProxy]] internal slot. + 2. If p is null, return undefined. +features: [Proxy] +---*/ + +var r = Proxy.revocable({}, {}); + +r.revoke(); + +assert.sameValue(r.revoke(), undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Proxy/revocable/revoke-returns-undefined.js b/js/src/tests/test262/built-ins/Proxy/revocable/revoke-returns-undefined.js new file mode 100644 index 0000000000..b1356b5e15 --- /dev/null +++ b/js/src/tests/test262/built-ins/Proxy/revocable/revoke-returns-undefined.js @@ -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 returns undefined +info: | + Proxy Revocation Functions + + ... + 7. Return undefined. +features: [Proxy] +---*/ + +var r = Proxy.revocable({}, {}); + +assert.sameValue(r.revoke(), undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Proxy/revocable/revoke.js b/js/src/tests/test262/built-ins/Proxy/revocable/revoke.js new file mode 100644 index 0000000000..8185c88ecc --- /dev/null +++ b/js/src/tests/test262/built-ins/Proxy/revocable/revoke.js @@ -0,0 +1,18 @@ +// 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). +features: [Proxy] +---*/ + +var r = Proxy.revocable({}, {}); + +assert.sameValue(typeof r.revoke, "function"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Proxy/revocable/shell.js b/js/src/tests/test262/built-ins/Proxy/revocable/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Proxy/revocable/shell.js diff --git a/js/src/tests/test262/built-ins/Proxy/revocable/target-is-revoked-function-proxy.js b/js/src/tests/test262/built-ins/Proxy/revocable/target-is-revoked-function-proxy.js new file mode 100644 index 0000000000..f4bdf1d5b8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Proxy/revocable/target-is-revoked-function-proxy.js @@ -0,0 +1,25 @@ +// Copyright (C) 2020 Alexey Shvayka. 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 revocableTarget = Proxy.revocable(function() {}, {}); +revocableTarget.revoke(); + +var revocable = Proxy.revocable(revocableTarget.proxy, {}); +assert.sameValue(typeof revocable.proxy, "function"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Proxy/revocable/target-is-revoked-proxy.js b/js/src/tests/test262/built-ins/Proxy/revocable/target-is-revoked-proxy.js new file mode 100644 index 0000000000..d83a11a0f3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Proxy/revocable/target-is-revoked-proxy.js @@ -0,0 +1,25 @@ +// Copyright (C) 2020 Alexey Shvayka. 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 Proxy. +info: | + ProxyCreate ( target, handler ) + + [...] + 3. Let P be ! MakeBasicObject(« [[ProxyHandler]], [[ProxyTarget]] »). + [...] + 6. Set P.[[ProxyTarget]] to target. + [...] + 8. Return P. +features: [Proxy] +---*/ + +var revocableTarget = Proxy.revocable({}, {}); +revocableTarget.revoke(); + +var revocable = Proxy.revocable(revocableTarget.proxy, {}); +assert.sameValue(typeof revocable.proxy, "object"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Proxy/revocable/tco-fn-realm-strict.js b/js/src/tests/test262/built-ins/Proxy/revocable/tco-fn-realm-strict.js new file mode 100644 index 0000000000..6714f09e63 --- /dev/null +++ b/js/src/tests/test262/built-ins/Proxy/revocable/tco-fn-realm-strict.js @@ -0,0 +1,27 @@ +// |reftest| skip -- tail-call-optimization is not supported +'use strict'; +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Realm of the TypeError from invoking a revoked Proxy during tail-call + optimization +esid: sec-tail-position-calls +flags: [onlyStrict] +features: [Proxy, tail-call-optimization] +---*/ + +var other = $262.createRealm(); +var F = other.evalScript(` + (function() { + var { proxy, revoke } = Proxy.revocable(function() {}, {}); + revoke(); + return proxy(); + }) +`); + +assert.throws(other.global.TypeError, function() { + F(); +}); + +reportCompare(0, 0); |