OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script src="../../resources/js-test.js"></script> | 2 <script src="../../resources/js-test.js"></script> |
3 <script src="resources/shared.js"></script> | 3 <script src="resources/shared.js"></script> |
4 <script> | 4 <script> |
5 | 5 |
6 description("Verify that that cursors weakly hold script value properties"); | 6 description("Verify that that cursors weakly hold script value properties"); |
7 | 7 |
8 if (window.internals) { | 8 if (window.internals) { |
9 indexedDBTest(prepareDatabase, onOpen); | 9 indexedDBTest(prepareDatabase, onOpen); |
10 } else { | 10 } else { |
(...skipping 22 matching lines...) Expand all Loading... |
33 tx.oncomplete = function() { | 33 tx.oncomplete = function() { |
34 db.close(); | 34 db.close(); |
35 | 35 |
36 // Try and induce a leak by a reference cycle from DOM to V8 and back. | 36 // Try and induce a leak by a reference cycle from DOM to V8 and back. |
37 // If the v8 value of cursor.key (etc) is only held by the cursor's | 37 // If the v8 value of cursor.key (etc) is only held by the cursor's |
38 // V8 wrapper then there will be no leak. | 38 // V8 wrapper then there will be no leak. |
39 cursor.key.cursor = cursor; | 39 cursor.key.cursor = cursor; |
40 cursor.primaryKey.cursor = cursor; | 40 cursor.primaryKey.cursor = cursor; |
41 cursor.value.cursor = cursor; | 41 cursor.value.cursor = cursor; |
42 | 42 |
43 cursorObserver = internals.observeGC(cursor); | 43 // Do not pass the object directly to observeGC function. This may |
| 44 // remain live on this function's stack preventing GC from collecting |
| 45 // it. Accessing the object inside an inner function will prevent any |
| 46 // unneeded references on this function's stack. |
| 47 cursorObserver = internals.observeGC((() => {return cursor;})()); |
44 | 48 |
45 cursorRequest = null; | 49 cursorRequest = null; |
46 cursor = null; | 50 cursor = null; |
47 | 51 |
48 gc(); | 52 gc(); |
49 | 53 |
50 shouldBeTrue("cursorObserver.wasCollected"); | 54 shouldBeTrue("cursorObserver.wasCollected"); |
51 finishJSTest(); | 55 finishJSTest(); |
52 }; | 56 }; |
53 } | 57 } |
54 | 58 |
55 | 59 |
56 </script> | 60 </script> |
OLD | NEW |