summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/basic/shape-snapshots.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/jit-test/tests/basic/shape-snapshots.js')
-rw-r--r--js/src/jit-test/tests/basic/shape-snapshots.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/basic/shape-snapshots.js b/js/src/jit-test/tests/basic/shape-snapshots.js
new file mode 100644
index 0000000000..866298caeb
--- /dev/null
+++ b/js/src/jit-test/tests/basic/shape-snapshots.js
@@ -0,0 +1,37 @@
+function test1() {
+ var o = {x: 1, y: 2};
+ var snapshot = createShapeSnapshot(o);
+ checkShapeSnapshot(snapshot);
+ Object.defineProperty(o, "z", {get: function() {}});
+ checkShapeSnapshot(snapshot);
+
+ snapshot = createShapeSnapshot(o);
+ checkShapeSnapshot(snapshot);
+ o[12345678] = 1;
+ checkShapeSnapshot(snapshot);
+
+ snapshot = createShapeSnapshot(o);
+ Object.defineProperty(o, "a", {configurable: true, set: function(){}});
+ checkShapeSnapshot(snapshot);
+
+ snapshot = createShapeSnapshot(o);
+ checkShapeSnapshot(snapshot);
+ delete o.a;
+ checkShapeSnapshot(snapshot);
+}
+test1();
+
+function test2() {
+ var dictObject = {x: 1, y: 2, z: 3};
+ delete dictObject.x;
+ var objects = [this, {}, {x: 1}, {x: 2}, dictObject, function() {}, [1, 2],
+ Object.prototype, new Proxy({}, {})];
+ var snapshots = objects.map(o => createShapeSnapshot(o));
+ gc();
+ snapshots.forEach(function(snapshot) {
+ objects.forEach(function(obj) {
+ checkShapeSnapshot(snapshot, obj);
+ });
+ });
+}
+test2();