summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Proxy/setPrototypeOf/internals-call-order.js
diff options
context:
space:
mode:
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.js50
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);