summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/Object-isSameNativeWithJitInfo.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/jit-test/tests/debug/Object-isSameNativeWithJitInfo.js')
-rw-r--r--js/src/jit-test/tests/debug/Object-isSameNativeWithJitInfo.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/debug/Object-isSameNativeWithJitInfo.js b/js/src/jit-test/tests/debug/Object-isSameNativeWithJitInfo.js
new file mode 100644
index 0000000000..648847ae49
--- /dev/null
+++ b/js/src/jit-test/tests/debug/Object-isSameNativeWithJitInfo.js
@@ -0,0 +1,32 @@
+var g = newGlobal({newCompartment: true});
+var dbg = Debugger(g);
+var gdbg = dbg.addDebuggee(g);
+
+assertEq(gdbg.getProperty("print").return.isSameNativeWithJitInfo(print), true);
+assertEq(gdbg.getProperty("print").return.isSameNativeWithJitInfo(newGlobal), false);
+
+// FakeDOMObject's accessor shares the single native functions, with
+// different JSJitInfo for each.
+
+gdbg.executeInGlobal(`
+var fun1 = Object.getOwnPropertyDescriptor(FakeDOMObject.prototype, "x").get;
+var fun2 = Object.getOwnPropertyDescriptor(FakeDOMObject.prototype, "slot").get;
+`);
+
+var g_fun1 = gdbg.executeInGlobal("fun1").return;
+var g_fun2 = gdbg.executeInGlobal("fun2").return;
+
+var fun1 = Object.getOwnPropertyDescriptor(FakeDOMObject.prototype, "x").get;
+var fun2 = Object.getOwnPropertyDescriptor(FakeDOMObject.prototype, "slot").get;
+
+// isSameNative doesn't distinguish between fun1 and fun2.
+assertEq(g_fun1.isSameNative(fun1), true);
+assertEq(g_fun1.isSameNative(fun2), true);
+assertEq(g_fun2.isSameNative(fun1), true);
+assertEq(g_fun2.isSameNative(fun2), true);
+
+// isSameNativeWithJitInfo can distinguish between fun1 and fun2.
+assertEq(g_fun1.isSameNativeWithJitInfo(fun1), true);
+assertEq(g_fun1.isSameNativeWithJitInfo(fun2), false);
+assertEq(g_fun2.isSameNativeWithJitInfo(fun1), false);
+assertEq(g_fun2.isSameNativeWithJitInfo(fun2), true);