summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Proxy/setPrototypeOf/not-extensible-target-not-same-target-prototype.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/built-ins/Proxy/setPrototypeOf/not-extensible-target-not-same-target-prototype.js
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.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/not-extensible-target-not-same-target-prototype.js')
-rw-r--r--js/src/tests/test262/built-ins/Proxy/setPrototypeOf/not-extensible-target-not-same-target-prototype.js55
1 files changed, 55 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Proxy/setPrototypeOf/not-extensible-target-not-same-target-prototype.js b/js/src/tests/test262/built-ins/Proxy/setPrototypeOf/not-extensible-target-not-same-target-prototype.js
new file mode 100644
index 0000000000..3c59f9a50e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Proxy/setPrototypeOf/not-extensible-target-not-same-target-prototype.js
@@ -0,0 +1,55 @@
+// 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.2
+description: >
+ Throws a TypeError exception if boolean trap result is true, target is
+ not extensible, and the given parameter is not the same object as the target
+ prototype.
+info: |
+ [[SetPrototypeOf]] (V)
+
+ ...
+ 2. Let handler be the value of the [[ProxyHandler]] internal slot of O.
+ ...
+ 5. Let target be the value of the [[ProxyTarget]] internal slot of O.
+ 6. Let trap be GetMethod(handler, "setPrototypeOf").
+ ...
+ 9. Let booleanTrapResult be ToBoolean(Call(trap, handler, «target, V»)).
+ 14. Let targetProto be target.[[GetPrototypeOf]]().
+ 15. ReturnIfAbrupt(targetProto).
+ 16. If booleanTrapResult is true and SameValue(V, targetProto) is false,
+ throw a TypeError exception.
+ ...
+features: [Proxy, Reflect, Reflect.setPrototypeOf]
+---*/
+
+var target, proxy;
+target = {};
+proxy = new Proxy(target, {
+ setPrototypeOf: function() {
+ return true;
+ }
+});
+
+Object.preventExtensions(target);
+
+assert.throws(TypeError, function() {
+ Reflect.setPrototypeOf(proxy, {});
+}, "target prototype is different");
+
+var proto = {};
+target = Object.setPrototypeOf({}, proto);
+proxy = new Proxy(target, {
+ setPrototypeOf: function() {
+ Object.setPrototypeOf(target, {});
+ Object.preventExtensions(target);
+ return true;
+ }
+});
+
+assert.throws(TypeError, function() {
+ Reflect.setPrototypeOf(proxy, proto);
+}, "target prototype is changed inside trap handler");
+
+reportCompare(0, 0);