summaryrefslogtreecommitdiffstats
path: root/js/src/tests/ecma_6/Proxy/ownkeys-linear.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /js/src/tests/ecma_6/Proxy/ownkeys-linear.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/tests/ecma_6/Proxy/ownkeys-linear.js')
-rw-r--r--js/src/tests/ecma_6/Proxy/ownkeys-linear.js70
1 files changed, 70 insertions, 0 deletions
diff --git a/js/src/tests/ecma_6/Proxy/ownkeys-linear.js b/js/src/tests/ecma_6/Proxy/ownkeys-linear.js
new file mode 100644
index 000000000..7b05a9384
--- /dev/null
+++ b/js/src/tests/ecma_6/Proxy/ownkeys-linear.js
@@ -0,0 +1,70 @@
+/*
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/licenses/publicdomain/
+ */
+
+var gTestfile = 'ownkeys-linear.js';
+var BUGNUMBER = 1257779;
+var summary =
+ "Scripted proxies' [[OwnPropertyKeys]] should have linear complexity";
+
+print(BUGNUMBER + ": " + summary);
+
+/**************
+ * BEGIN TEST *
+ **************/
+
+// Making this 50k makes cgc builds time out on tbpl. 5k takes 28s locally.
+// 10k takes 84s locally. So pick an intermediate number, with a generous
+// constant factor in case cgc-on-tbpl is much slower.
+const HALF_COUNT = 7500;
+
+var configurables = [];
+for (var i = 0; i < HALF_COUNT; i++)
+ configurables.push("conf" + i);
+
+var nonconfigurables = [];
+for (var i = 0; i < HALF_COUNT; i++)
+ nonconfigurables.push("nonconf" + i);
+
+var target = {};
+for (var name of configurables)
+ Object.defineProperty(target, name, { configurable: false, value: 0 });
+for (var name of nonconfigurables)
+ Object.defineProperty(target, name, { configurable: true, value: 0 });
+
+var handler = {
+ ownKeys(t) {
+ assertEq(t, target, "target mismatch!");
+
+ var trapResult = [];
+
+ // Append all nonconfigurables in reverse order of presence.
+ for (var i = nonconfigurables.length; i > 0; i--)
+ trapResult.push(nonconfigurables[i - 1]);
+
+ // Then the same for all configurables.
+ for (var i = configurables.length; i > 0; i--)
+ trapResult.push(configurables[i - 1]);
+
+ // The end consequence is that this ordering is exactly opposite the
+ // ordering they'll have on the target, and so worst-case performance will
+ // occur if the spec's |uncheckedResultKeys| structure is a vector having
+ // the same order as |trapResult|, searched from beginning to end in the
+ // presence-checks in the last few steps of the [[OwnPropertyKeys]]
+ // algorithm.
+ return trapResult;
+ }
+};
+
+var p = new Proxy(target, handler);
+
+// The test passes if it doesn't time out.
+assertEq(Object.getOwnPropertyNames(p).length, HALF_COUNT * 2);
+
+/******************************************************************************/
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);
+
+print("Tests complete");