summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/proxy/testDirectProxyGet10.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/jit-test/tests/proxy/testDirectProxyGet10.js')
-rw-r--r--js/src/jit-test/tests/proxy/testDirectProxyGet10.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/proxy/testDirectProxyGet10.js b/js/src/jit-test/tests/proxy/testDirectProxyGet10.js
new file mode 100644
index 0000000000..c6d73e1956
--- /dev/null
+++ b/js/src/jit-test/tests/proxy/testDirectProxyGet10.js
@@ -0,0 +1,43 @@
+load(libdir + "asserts.js");
+
+var target = {x:5};
+var magic = false;
+var returnValue = 42;
+var handler = {
+ get(t, p, a, b) {
+ assertEq(a, proxy);
+ assertEq(b, undefined);
+ assertEq(arguments.length, 3);
+ if (magic) {
+ Object.defineProperty(target, 'x', {
+ value: 42,
+ writable: false,
+ configurable: false
+ });
+ if (returnValue != 42) {
+ gc(testGet, "shrinking");
+ }
+ }
+ return returnValue;
+ }
+};
+var proxy = new Proxy(target, handler);
+
+// Use an array that sometimes has a proxy and sometimes not, to get to
+// the Ion IC path.
+var maybeProxies = [
+ {x: returnValue},
+ proxy,
+];
+
+function testGet(p) {
+ return p.x;
+}
+
+for (i = 0; i < 200; i++) {
+ assertEq(testGet(maybeProxies[i % maybeProxies.length]), returnValue);
+}
+magic = true;
+assertEq(testGet(proxy), returnValue);
+returnValue = 41;
+assertThrowsInstanceOf(function () { testGet(proxy) }, TypeError);