1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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();
|