blob: 434ce41e1c6d6e650a20b4e4f7c78d9f07f4f1a3 [file] [log] [blame]
fpizlo@apple.com17955702014-03-02 03:45:06 +00001// Tests that opaque roots behave correctly during young generation collections
mhahnenberg@apple.comcf057142014-02-10 19:59:16 +00002
3// Create the primary Root.
4var root = new Root();
5// This secondary root is for allocating a second Element without overriding
6// the primary Root's Element.
7var otherRoot = new Root();
8
9// Run an Eden collection so that the Root will be in the old gen (and won't be rescanned).
10edenGC();
11
12// Create a new Element and set a custom property on it.
13var elem = new Element(root);
14elem.customProperty = "hello";
15
16// Make the Element unreachable except through the ephemeron with the Root.
17elem = null;
18
19// Create another Element so that we process the weak handles in block of the original Element.
20var test = new Element(otherRoot);
21
22// Run another Eden collection to process the weak handles in the Element's block. If opaque roots
23// are cleared then we'll think that the original Element is dead because the Root won't be in the
24// set of opaque roots.
25edenGC();
26
27// Check if the primary Root's Element exists and has our custom property.
28var elem = getElement(root);
fpizlo@apple.com17955702014-03-02 03:45:06 +000029if (elem.customProperty != "hello")
30 throw new Error("bad value of customProperty: " + elem.customProperty);