Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / storage / indexeddb / request-leak.html
blob8d28fb4ded547559d4a19340f226400bc3f0534a
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 requests 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 preamble(evt);
18 evalAndLog("db = event.target.result");
19 evalAndLog("store = db.createObjectStore('store')");
20 evalAndLog("store.put({value: 'value'}, 'key')");
23 function onOpen(evt)
25 preamble(evt);
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() {
31 preamble();
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");
45 evalAndLog("gc()");
46 shouldBeTrue("observer.wasCollected");
47 finishJSTest();
52 </script>