Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / storage / indexeddb / cursor-leak.html
blobabeabf87944aeb4aa06633e6a0daa942e93df0d3
1 <!DOCTYPE html>
2 <script src="../../resources/js-test.js"></script>
3 <script src="resources/shared.js"></script>
4 <script>
6 description("Verify that that cursors weakly hold script value properties");
8 if (window.internals) {
9 indexedDBTest(prepareDatabase, onOpen);
10 } else {
11 testFailed('This test requires access to the Internals object');
12 finishJSTest();
15 function prepareDatabase(evt)
17 db = event.target.result;
18 store = db.createObjectStore('store');
19 store.put({value: 'value'}, ['key']);
22 function onOpen(evt)
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() {
34 db.close();
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);
45 cursorRequest = null;
46 cursor = null;
48 gc();
50 shouldBeTrue("cursorObserver.wasCollected");
51 finishJSTest();
56 </script>