2 <script src=
"../../resources/js-test.js"></script>
3 <script src=
"resources/shared.js"></script>
6 description("Verify that that requests 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
)
18 evalAndLog("db = event.target.result");
19 evalAndLog("store = db.createObjectStore('store')");
20 evalAndLog("store.put({value: 'value'}, 'key')");
26 evalAndLog("db = event.target.result");
27 evalAndLog("tx = db.transaction('store')");
28 evalAndLog("store = tx.objectStore('store')");
29 evalAndLog("request = store.get('key')");
30 tx
.oncomplete
= function onTransactionComplete() {
32 evalAndLog("db.close()");
33 shouldBeEqualToString("typeof request.result", "object");
35 // Verify that the same object is returned on each access to request.result.
36 evalAndLog("request.result.x = 123");
37 shouldBe("request.result.x", "123");
39 // Try and induce a leak by a reference cycle from DOM to V8 and back.
40 // If the v8 value of request.result (etc) is only held by the requests's
41 // V8 wrapper then there will be no leak.
42 evalAndLog("request.result.leak = request");
43 evalAndLog("observer = internals.observeGC(request)");
44 evalAndLog("request = null");
46 shouldBeTrue("observer.wasCollected");