summaryrefslogtreecommitdiffstats
path: root/webkit/data/listener/listener_leak2.html
blob: 72d3a365662da1175fd3fc7de0032479f8be5c8b (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
<html>
<head><title>Event Listener Leak Test 2</title></head>
<body onload="leak()">
<script>
if (typeof(gc) == "undefined") gc = function() {};

var node = null;

function EventListenerLeakTestObject2() {}

function createListener(node) {
  var foo = new EventListenerLeakTestObject2();
  return function(evt) {
    // This closure references |node| and an instance of leak object.
    node.foo = foo;
  };
}

function doLeak() {
  if (!node) node = document.createElement('span');
  for (var i = 0; i < 10000; i++) {
    node.onclick = createListener(node);
  }
}

function leak() {
  doLeak();
  gc();
  gc();
}
</script>

<p>This page leaks memory.</p>

<!-- Allow leaking manually. -->
<input type="button" value="Leak More" onclick="leak()">

</body>
</html>