2 <script src=
"../../resources/js-test.js"></script>
3 <script src=
"resources/shared.js"></script>
6 description("Verify that that cursors weakly hold script value properties");
8 if (window
.internals
) {
9 indexedDBTest(prepareDatabase
, onOpen
);
11 testFailed('This test requires access to the Internals object');
15 function prepareDatabase(evt
)
17 db
= event
.target
.result
;
18 store
= db
.createObjectStore('store');
19 store
.put({value
: 'value'}, ['key']);
24 // evalAndLog() is not used as that generates new DOM nodes.
26 db
= evt
.target
.result
;
27 tx
= db
.transaction('store');
28 store
= tx
.objectStore('store');
29 cursorRequest
= store
.openCursor();
30 cursorRequest
.onsuccess = function() {
31 cursor
= cursorRequest
.result
;
33 tx
.oncomplete = function() {
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
38 // V8 wrapper then there will be no leak.
39 cursor
.key
.cursor
= cursor
;
40 cursor
.primaryKey
.cursor
= cursor
;
41 cursor
.value
.cursor
= cursor
;
43 cursorObserver
= internals
.observeGC(cursor
);
50 shouldBeTrue("cursorObserver.wasCollected");