summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/statements/for-in-with-gc-and-unvisited-deletion.js
blob: 34e1eba1ecab2a5cd52a52f63b09bb03716e4468 (plain)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Any copyright is dedicated to the Public Domain.
// http://creativecommons.org/licenses/publicdomain/

//-----------------------------------------------------------------------------
var gTestfile = "for-in-with-gc-and-unvisited-deletion.js";
var BUGNUMBER = 1462939;
var summary =
  "Don't mishandle deletion of a property from the internal iterator " +
  "created for a for-in loop, when a gc occurs just after it";

print(BUGNUMBER + ": " + summary);

/**************
 * BEGIN TEST *
 **************/

function testOneDeletion()
{
  var o = {
    p: 1,
    r: 3,
    s: 4,
  };

  for (var i in o)
  {
    gc();
    delete o.s;
  }
}
testOneDeletion();

function testTwoDeletions()
{
  var o = {
    p: 1,
    r: 3,
    s: 4,
    t: 5,
  };

  for (var i in o)
  {
    gc();
    delete o.t;
    delete o.s;
  }
}
testTwoDeletions();

function testThreeDeletions()
{
  var o = {
    p: 1,
    r: 3,
    s: 4,
    t: 5,
    x: 7,
  };

  for (var i in o)
  {
    gc();
    delete o.x;
    delete o.t;
    delete o.s;
  }
}
testThreeDeletions();

/******************************************************************************/

if (typeof reportCompare === "function")
  reportCompare(true, true);

print("Tests complete");