| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
var gTestfile = 'regress-394709.js'; |
| 7 |
|
| 8 |
var BUGNUMBER = 394709; |
| 9 |
var summary = 'Do not leak with object.watch and closure'; |
| 10 |
var actual = 'No Leak'; |
| 11 |
var expect = 'No Leak'; |
| 12 |
|
| 13 |
if (typeof countHeap == 'undefined') |
| 14 |
{ |
| 15 |
countHeap = function () { |
| 16 |
print('This test requires countHeap which is not supported'); |
| 17 |
return 0; |
| 18 |
}; |
| 19 |
} |
| 20 |
|
| 21 |
|
| 22 |
test(); |
| 23 |
|
| 24 |
|
| 25 |
function test() |
| 26 |
{ |
| 27 |
enterFunc ('test'); |
| 28 |
printBugNumber(BUGNUMBER); |
| 29 |
printStatus (summary); |
| 30 |
|
| 31 |
runtest(); |
| 32 |
gc(); |
| 33 |
var counter = countHeap(); |
| 34 |
runtest(); |
| 35 |
gc(); |
| 36 |
if (counter != countHeap()) |
| 37 |
throw "A leaky watch point is detected"; |
| 38 |
|
| 39 |
function runtest () { |
| 40 |
var obj = { b: 0 }; |
| 41 |
obj.watch('b', watcher); |
| 42 |
|
| 43 |
function watcher(id, old, value) { |
| 44 |
++obj.n; |
| 45 |
return value; |
| 46 |
} |
| 47 |
} |
| 48 |
|
| 49 |
reportCompare(expect, actual, summary); |
| 50 |
|
| 51 |
exitFunc ('test'); |
| 52 |
} |