diff --git a/test/built-ins/Proxy/apply/call-parameters.js b/test/built-ins/Proxy/apply/call-parameters.js index f45af9cdff..38802c2c1f 100644 --- a/test/built-ins/Proxy/apply/call-parameters.js +++ b/test/built-ins/Proxy/apply/call-parameters.js @@ -1,6 +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. /*--- +esid: sec-proxy-object-internal-methods-and-internal-slots-call-thisargument-argumentslist es6id: 9.5.13 description: > trap is called with handler object as its context, and parameters are: @@ -13,8 +14,8 @@ features: [Proxy] ---*/ var _target, _args, _handler, _context; -var target = function(a, b) { - return a + b; +var target = function() { + throw new Test262Error('target should not be called'); }; var handler = { apply: function(t, c, args) { diff --git a/test/built-ins/Proxy/apply/call-result.js b/test/built-ins/Proxy/apply/call-result.js index 451d3c18cd..ffb84408a9 100644 --- a/test/built-ins/Proxy/apply/call-result.js +++ b/test/built-ins/Proxy/apply/call-result.js @@ -1,6 +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. /*--- +esid: sec-proxy-object-internal-methods-and-internal-slots-call-thisargument-argumentslist es6id: 9.5.13 description: > Return the result from the trap method. @@ -11,15 +12,13 @@ info: | features: [Proxy] ---*/ -var target = function(a, b) { - return a + b; -}; var result = {}; -var handler = { +var p = new Proxy(function() { + throw new Test262Error('target should not be called'); +}, { apply: function(t, c, args) { return result; - } -}; -var p = new Proxy(target, handler); + }, +}); assert.sameValue(p.call(), result); diff --git a/test/built-ins/Proxy/apply/null-handler-realm.js b/test/built-ins/Proxy/apply/null-handler-realm.js new file mode 100644 index 0000000000..45d4ec0187 --- /dev/null +++ b/test/built-ins/Proxy/apply/null-handler-realm.js @@ -0,0 +1,23 @@ +// Copyright (C) 2019 Aleksey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-proxy-object-internal-methods-and-internal-slots-call-thisargument-argumentslist +description: > + Throws a TypeError exception if handler is null (honoring the realm of the + current execution context). +info: | + [[Call]] (thisArgument, argumentsList) + + 1. Let handler be O.[[ProxyHandler]]. + 2. If handler is null, throw a TypeError exception. +features: [cross-realm, Proxy] +---*/ + +var OProxy = $262.createRealm().global.Proxy; +var p = OProxy.revocable(function() {}, {}); + +p.revoke(); + +assert.throws(TypeError, function() { + p.proxy(); +}); diff --git a/test/built-ins/Proxy/apply/null-handler.js b/test/built-ins/Proxy/apply/null-handler.js index 6e0016ec8b..34ae5e25f7 100644 --- a/test/built-ins/Proxy/apply/null-handler.js +++ b/test/built-ins/Proxy/apply/null-handler.js @@ -1,6 +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. /*--- +esid: sec-proxy-object-internal-methods-and-internal-slots-call-thisargument-argumentslist es6id: 9.5.13 description: > [[Call]] (thisArgument, argumentsList) diff --git a/test/built-ins/Proxy/apply/return-abrupt.js b/test/built-ins/Proxy/apply/return-abrupt.js index 494973defb..4ff83d40af 100644 --- a/test/built-ins/Proxy/apply/return-abrupt.js +++ b/test/built-ins/Proxy/apply/return-abrupt.js @@ -1,16 +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. /*--- +esid: sec-proxy-object-internal-methods-and-internal-slots-call-thisargument-argumentslist es6id: 9.5.13 description: > Return is an abrupt completion features: [Proxy] ---*/ -var target = function(a, b) { - return a + b; -}; -var p = new Proxy(target, { +var p = new Proxy(function() { + throw 'not the Test262Error you are looking for'; +}, { apply: function(t, c, args) { throw new Test262Error(); } diff --git a/test/built-ins/Proxy/apply/trap-is-not-callable.js b/test/built-ins/Proxy/apply/trap-is-not-callable.js index 14e84966b2..39393a5c3d 100644 --- a/test/built-ins/Proxy/apply/trap-is-not-callable.js +++ b/test/built-ins/Proxy/apply/trap-is-not-callable.js @@ -1,6 +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. /*--- +esid: sec-proxy-object-internal-methods-and-internal-slots-call-thisargument-argumentslist es6id: 9.5.13 description: > Throws if trap is not callable. diff --git a/test/built-ins/Proxy/apply/trap-is-null.js b/test/built-ins/Proxy/apply/trap-is-null.js index 0584a3ddb6..1001355aab 100644 --- a/test/built-ins/Proxy/apply/trap-is-null.js +++ b/test/built-ins/Proxy/apply/trap-is-null.js @@ -24,17 +24,23 @@ features: [Proxy] ---*/ var calls = 0; +var _context; -function target(a, b) { - assert.sameValue(this, ctx); - calls += 1; - return a + b; -} +var target = new Proxy(function() {}, { + apply: function(_target, context, args) { + calls++; + _context = context; + return args[0] + args[1]; + } +}) -var ctx = {}; var p = new Proxy(target, { apply: null }); -var res = p.call(ctx, 1, 2); -assert.sameValue(res, 3, "`apply` trap is `null`"); -assert.sameValue(calls, 1, "target is called once"); + +var context = {}; +var res = p.call(context, 1, 2); + +assert.sameValue(calls, 1, "apply is null: [[Call]] is invoked once"); +assert.sameValue(_context, context, "apply is null: context is passed to [[Call]]"); +assert.sameValue(res, 3, "apply is null: result of [[Call]] is returned"); diff --git a/test/built-ins/Proxy/apply/trap-is-undefined-no-property.js b/test/built-ins/Proxy/apply/trap-is-undefined-no-property.js index 45e2ef5f77..71277f85b9 100644 --- a/test/built-ins/Proxy/apply/trap-is-undefined-no-property.js +++ b/test/built-ins/Proxy/apply/trap-is-undefined-no-property.js @@ -24,15 +24,20 @@ features: [Proxy] ---*/ var calls = 0; +var _context; -function target(a, b) { - assert.sameValue(this, ctx); - calls += 1; - return a + b; -} +var target = new Proxy(function() {}, { + apply: function(_target, context, args) { + calls++; + _context = context; + return args[0] + args[1]; + } +}) -var ctx = {}; var p = new Proxy(target, {}); -var res = p.call(ctx, 1, 2); -assert.sameValue(res, 3, "`apply` trap is missing"); -assert.sameValue(calls, 1, "target is called once"); +var context = {}; +var res = p.call(context, 1, 2); + +assert.sameValue(calls, 1, "apply is missing: [[Call]] is invoked once"); +assert.sameValue(_context, context, "apply is missing: context is passed to [[Call]]"); +assert.sameValue(res, 3, "apply is missing: result of [[Call]] is returned"); diff --git a/test/built-ins/Proxy/apply/trap-is-undefined.js b/test/built-ins/Proxy/apply/trap-is-undefined.js index 5a2b9e5e77..9d9e5edfbf 100644 --- a/test/built-ins/Proxy/apply/trap-is-undefined.js +++ b/test/built-ins/Proxy/apply/trap-is-undefined.js @@ -24,17 +24,23 @@ features: [Proxy] ---*/ var calls = 0; +var _context; -function target(a, b) { - assert.sameValue(this, ctx); - calls += 1; - return a + b; -} +var target = new Proxy(function() {}, { + apply: function(_target, context, args) { + calls++; + _context = context; + return args[0] + args[1]; + } +}) -var ctx = {}; var p = new Proxy(target, { apply: undefined }); -var res = p.call(ctx, 1, 2); -assert.sameValue(res, 3, "`apply` trap is `null`"); -assert.sameValue(calls, 1, "target is called once"); + +var context = {}; +var res = p.call(context, 1, 2); + +assert.sameValue(calls, 1, "apply is undefined: [[Call]] is invoked once"); +assert.sameValue(_context, context, "apply is undefined: context is passed to [[Call]]"); +assert.sameValue(res, 3, "apply is undefined: result of [[Call]] is returned");