summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/basic/__proto__-not-prototype-mutation.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/jit-test/tests/basic/__proto__-not-prototype-mutation.js')
-rw-r--r--js/src/jit-test/tests/basic/__proto__-not-prototype-mutation.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/basic/__proto__-not-prototype-mutation.js b/js/src/jit-test/tests/basic/__proto__-not-prototype-mutation.js
new file mode 100644
index 0000000000..b940a229b2
--- /dev/null
+++ b/js/src/jit-test/tests/basic/__proto__-not-prototype-mutation.js
@@ -0,0 +1,29 @@
+/*
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/licenses/publicdomain/
+ */
+
+var __proto__ = "string value";
+
+var propdefs =
+ [{ c: "['__proto__']: null", t: "object" },
+ { c: "__proto__() {}", t: "function" },
+ { c: "['__proto__']() {}", t: "function" },
+ { c: "*__proto__() {}", t: "function" },
+ { c: "*['__proto__']() {}", t: "function" },
+ { c: "__proto__", t: "string" },
+ { c: "get __proto__() { return 42; }", t: "number" },
+ { c: "get ['__proto__']() { return undefined; }", t: "undefined" },
+ { c: "set __proto__(v) { }", t: "undefined" },
+ { c: "set ['__proto__'](v) { }", t: "undefined" }];
+
+for (var propdef of propdefs)
+{
+ var f = new Function("return { " + propdef.c + " };");
+ for (var i = 0; i < 100; i++)
+ {
+ var inst = f();
+ assertEq(typeof inst.__proto__, propdef.t);
+ assertEq(Object.getPrototypeOf(inst), Object.prototype);
+ }
+}