Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / storage / indexeddb / cursor-request-cycle.html
blob4f65843e93caec4a4234c6cc3782723d4bd306c9
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 request, and work if request is GC'd");
8 indexedDBTest(prepareDatabase, onOpen);
10 function prepareDatabase(evt)
12 preamble(evt);
13 evalAndLog("db = event.target.result");
14 evalAndLog("store = db.createObjectStore('store')");
15 store.put("value1", "key1");
16 store.put("value2", "key2");
19 function onOpen(evt)
21 preamble(evt);
22 evalAndLog("db = event.target.result");
23 evalAndLog("tx = db.transaction('store')");
24 evalAndLog("store = tx.objectStore('store')");
26 evalAndLog("cursorRequest = store.openCursor()");
27 cursorRequest.onsuccess = function openCursorRequestSuccess(evt) {
28 preamble(evt);
29 debug("Result will be checked later, to ensure that lazy access is safe");
32 evalAndLog("otherRequest = store.get(0)");
33 otherRequest.onsuccess = function otherRequestSuccess(evt) {
34 preamble(evt);
36 debug("Verify that the request's result can be accessed lazily:");
37 evalAndLog("gc()");
39 evalAndLog("cursor = cursorRequest.result");
40 shouldBeNonNull("cursor");
41 shouldBeEqualToString("cursor.key", "key1");
42 shouldBeEqualToString("cursor.value", "value1");
43 evalAndLog("cursorRequest.extra = 123");
44 evalAndLog("cursor.extra = 456");
46 // Assign a new handler to inspect the request and cursor indirectly.
47 cursorRequest.onsuccess = function cursorContinueSuccess(evt) {
48 preamble(evt);
49 evalAndLog("cursor = event.target.result");
50 shouldBeNonNull("cursor");
51 shouldBeEqualToString("cursor.key", "key2");
52 shouldBeEqualToString("cursor.value", "value2");
53 shouldBe("event.target.extra", "123");
54 shouldBe("cursor.extra", "456");
57 debug("Ensure request is not released if cursor is still around.");
58 cursorRequestObservation = internals.observeGC(cursorRequest);
59 evalAndLog("cursorRequest = null");
60 evalAndLog("gc()");
61 shouldBeFalse("cursorRequestObservation.wasCollected");
63 evalAndLog("cursor.continue()");
65 cursorObservation = internals.observeGC(cursor);
66 evalAndLog("cursor = null");
67 evalAndLog("gc()");
68 shouldBeFalse("cursorObservation.wasCollected");
70 evalAndLog("finalRequest = store.get(0)");
71 finalRequest.onsuccess = function finalRequestSuccess(evt) {
72 preamble(evt);
73 shouldBeEqualToString("cursor.key", "key2");
74 shouldBeEqualToString("cursor.value", "value2");
76 cursorObservation = internals.observeGC(cursor);
77 evalAndLog("cursor = null");
78 evalAndLog("gc()");
79 shouldBeTrue("cursorRequestObservation.wasCollected");
80 shouldBeTrue("cursorObservation.wasCollected");
84 tx.oncomplete = finishJSTest;
88 </script>