Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 //-----------------------------------------------------------------------------
7 var BUGNUMBER = 394709;
8 var summary = 'Do not leak with object.watch and closure';
9 var actual = 'No Leak';
10 var expect = 'No Leak';
12 if (typeof countHeap == 'undefined')
13 {
14 countHeap = function () {
15 print('This test requires countHeap which is not supported');
16 return 0;
17 };
18 }
20 //-----------------------------------------------------------------------------
21 test();
22 //-----------------------------------------------------------------------------
24 function test()
25 {
26 enterFunc ('test');
27 printBugNumber(BUGNUMBER);
28 printStatus (summary);
30 // Ensure that we flush all values so that gc() collects all objects that
31 // the user cannot reach from JS.
32 eval();
34 runtest();
35 gc();
36 var count1 = countHeap();
37 runtest();
38 gc();
39 var count2 = countHeap();
40 runtest();
41 gc();
42 var count3 = countHeap();
43 /* Try to be tolerant of conservative GC noise: we want a steady leak. */
44 if (count1 < count2 && count2 < count3)
45 throw "A leaky watch point is detected";
47 function runtest () {
48 var obj = { b: 0 };
49 obj.watch('b', watcher);
51 function watcher(id, old, value) {
52 ++obj.n;
53 return value;
54 }
55 }
57 reportCompare(expect, actual, summary);
59 exitFunc ('test');
60 }