| if (this.importScripts) { |
| importScripts('../../../resources/js-test.js'); |
| importScripts('shared.js'); |
| } |
| |
| description("Verify that that cursors weakly hold script value properties"); |
| |
| if (window.internals) { |
| indexedDBTest(prepareDatabase, onOpen); |
| } else { |
| testFailed('This test requires access to the Internals object'); |
| finishJSTest(); |
| } |
| |
| function prepareDatabase(evt) |
| { |
| db = event.target.result; |
| store = db.createObjectStore('store'); |
| store.put({value: 'value'}, ['key']); |
| } |
| |
| function onOpen(evt) |
| { |
| // evalAndLog() is not used as that generates new DOM nodes. |
| |
| db = evt.target.result; |
| tx = db.transaction('store'); |
| store = tx.objectStore('store'); |
| cursorRequest = store.openCursor(); |
| cursorRequest.onsuccess = function() { |
| cursor = cursorRequest.result; |
| }; |
| tx.oncomplete = function() { |
| db.close(); |
| |
| // Try and induce a leak by a reference cycle from DOM to V8 and back. |
| // If the v8 value of cursor.key (etc) is only held by the cursor's |
| // V8 wrapper then there will be no leak. |
| cursor.key.cursor = cursor; |
| cursor.primaryKey.cursor = cursor; |
| cursor.value.cursor = cursor; |
| |
| cursorObserver = internals.observeGC(cursor); |
| |
| cursorRequest = null; |
| cursor = null; |
| |
| gc(); |
| |
| shouldBeTrue("cursorObserver.wasCollected"); |
| finishJSTest(); |
| }; |
| } |