Passing tests for bug 1062349, which was independently fixed by Jeff Walden in bug 888969. no_r=test.
authorJason Orendorff <jorendorff@mozilla.com>
Fri, 24 Jun 2016 17:19:21 -0500
changeset 308243 9b259728f280b92c1311c9c444f76a3f6e1da353
parent 308242 21f1e0017ba67e1017f487f9e750d87c92ac9d4a
child 308244 9193c55ec783c7d2bf7049d6c28944e60b5fe612
push id31092
push usercbook@mozilla.com
push dateFri, 05 Aug 2016 10:16:59 +0000
treeherderautoland@b97dd7dd3cb9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1062349, 888969
milestone51.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Passing tests for bug 1062349, which was independently fixed by Jeff Walden in bug 888969. no_r=test. MozReview-Commit-ID: EjCXBLT9Xqa
js/src/tests/ecma_6/Object/setPrototypeOf-cross-realm-cycle.js
js/src/tests/ecma_6/Object/setPrototypeOf-cycle.js
js/src/tests/ecma_6/Proxy/regress-bug1062349.js
new file mode 100644
--- /dev/null
+++ b/js/src/tests/ecma_6/Object/setPrototypeOf-cross-realm-cycle.js
@@ -0,0 +1,11 @@
+// The cycle check in 9.1.2 [[SetPrototypeOf]] prevents cross-realm cycles
+// involving only ordinary objects.
+
+var gw = newGlobal();
+
+var obj = {};
+var w = gw.Object.create(obj);
+assertThrowsInstanceOf(() => Object.setPrototypeOf(obj, w), TypeError);
+assertThrowsInstanceOf(() => gw.Object.setPrototypeOf(obj, w), gw.TypeError);
+
+reportCompare(0, 0);
new file mode 100644
--- /dev/null
+++ b/js/src/tests/ecma_6/Object/setPrototypeOf-cycle.js
@@ -0,0 +1,16 @@
+// The cycle check in 9.1.2 [[SetPrototypeOf]] does not walk proxies.
+// Therefore it's very easy to create prototype chain cycles involving proxies,
+// and the spec requires us to accept this.
+
+var t = {};
+var p = new Proxy(t, {});
+Object.setPrototypeOf(t, p);  // 🙈
+
+// Actually doing anything that searches this object's prototype chain
+// technically should not terminate. We instead throw "too much recursion".
+for (var obj of [t, p]) {
+    assertThrowsInstanceOf(() => "x" in obj, InternalError);
+    assertThrowsInstanceOf(() => obj.x, InternalError);
+    assertThrowsInstanceOf(() => { obj.x = 1; }, InternalError);
+}
+reportCompare(0, 0);
new file mode 100644
--- /dev/null
+++ b/js/src/tests/ecma_6/Proxy/regress-bug1062349.js
@@ -0,0 +1,31 @@
+// Adapted from a test case contributed by André Bargull in bug 1062349.
+
+var log = [];
+var hh = {
+    get(t, pk) {
+        log.push("trap: " + pk);
+        return t[pk];
+    }
+};
+var h = new Proxy({
+    get set() {
+        log.push("called set()");
+        Object.defineProperty(o, "prop", {value: 0});
+        log.push("o.prop:", Object.getOwnPropertyDescriptor(o, "prop"));
+    }
+}, hh);
+var p = new Proxy({}, h);
+var o = {__proto__: p};
+
+o.prop = 1;
+
+var expectedDesc = {value: 0, writable: false, enumerable: false, configurable: false};
+assertDeepEq(log, [
+    "trap: set",
+    "called set()",
+    "o.prop:",
+    expectedDesc
+]);
+assertDeepEq(Object.getOwnPropertyDescriptor(o, "prop"), expectedDesc);
+
+reportCompare(0, 0);