diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/built-ins/Proxy/setPrototypeOf/internals-call-order.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/Proxy/setPrototypeOf/internals-call-order.js')
-rw-r--r-- | js/src/tests/test262/built-ins/Proxy/setPrototypeOf/internals-call-order.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Proxy/setPrototypeOf/internals-call-order.js b/js/src/tests/test262/built-ins/Proxy/setPrototypeOf/internals-call-order.js new file mode 100644 index 0000000000..e6f3e20551 --- /dev/null +++ b/js/src/tests/test262/built-ins/Proxy/setPrototypeOf/internals-call-order.js @@ -0,0 +1,50 @@ +// Copyright (C) 2016 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-setprototypeof-v +description: > + Calls target.[[GetPrototypeOf]] after trap result as false and not extensible + target +info: | + [[SetPrototypeOf]] (V) + + 8. Let booleanTrapResult be ToBoolean(? Call(trap, handler, « target, V »)). + 9. If booleanTrapResult is false, return false. + 10. Let extensibleTarget be ? IsExtensible(target). + 11. If extensibleTarget is true, return true. + 12. Let targetProto be ? target.[[GetPrototypeOf]](). +features: [Proxy, Reflect, Reflect.setPrototypeOf] +---*/ + +var calls = []; +var proto = {}; + +var target = new Proxy(Object.create(proto), { + isExtensible: function() { + calls.push("target.[[IsExtensible]]"); + return false; + }, + getPrototypeOf: function() { + calls.push("target.[[GetPrototypeOf]]"); + return proto; + } +}); + +// Proxy must report same extensiblitity as target +Object.preventExtensions(target); + +var proxy = new Proxy(target, { + setPrototypeOf: function() { + calls.push("proxy.[[setPrototypeOf]]"); + return true; + } +}); + +assert.sameValue(Reflect.setPrototypeOf(proxy, proto), true); +assert.sameValue(calls.length, 3); +assert.sameValue(calls[0], "proxy.[[setPrototypeOf]]"); +assert.sameValue(calls[1], "target.[[IsExtensible]]"); +assert.sameValue(calls[2], "target.[[GetPrototypeOf]]"); + +reportCompare(0, 0); |