summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/fields/private-proxy-oom.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/jit-test/tests/fields/private-proxy-oom.js')
-rw-r--r--js/src/jit-test/tests/fields/private-proxy-oom.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/fields/private-proxy-oom.js b/js/src/jit-test/tests/fields/private-proxy-oom.js
new file mode 100644
index 0000000000..dd5200d9a6
--- /dev/null
+++ b/js/src/jit-test/tests/fields/private-proxy-oom.js
@@ -0,0 +1,48 @@
+// |jit-test| skip-if: !('oomTest' in this);
+// Check for proxy expando OOM issues.
+
+function assertThrowsTypeError(f) {
+ assertThrowsInstanceOf(f, TypeError);
+}
+
+
+function testing() {
+ var target = {};
+ var p1 = new Proxy(target, {});
+ var p2 = new Proxy(target, {});
+
+ class A extends class {
+ constructor(o) {
+ return o;
+ }
+ }
+ {
+ #field = 10;
+ static gf(o) {
+ return o.#field;
+ }
+ static sf(o) {
+ o.#field = 15;
+ }
+ }
+
+ // Verify field handling on the proxy we install it on.
+ new A(p1);
+ assertEq(A.gf(p1), 10);
+ A.sf(p1)
+ assertEq(A.gf(p1), 15);
+
+ // Should't be on the target
+ assertThrowsTypeError(() => A.gf(target));
+
+ // Can't set the field, doesn't exist
+ assertThrowsTypeError(() => A.sf(p2));
+
+ // Definitely can't get the field, doesn't exist.
+ assertThrowsTypeError(() => A.gf(p2));
+
+ // Still should't be on the target.
+ assertThrowsTypeError(() => A.gf(target));
+}
+
+oomTest(testing); \ No newline at end of file