Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: LayoutTests/storage/indexeddb/key-cursor-request-cycle.html

Issue 924863003: IndexedDB: Replace custom binding logic with [SetWrapperReferenceTo] (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Restore deleted line Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | LayoutTests/storage/indexeddb/key-cursor-request-cycle-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="../../resources/js-test.js"></script> 2 <script src="../../resources/js-test.js"></script>
3 <script src="resources/shared.js"></script> 3 <script src="resources/shared.js"></script>
4 <script> 4 <script>
5 5
6 description("Verify that that cursors weakly hold request, and work if request i s GC'd"); 6 description("Verify that that key cursors weakly hold request, and work if reque st is GC'd");
7 7
8 indexedDBTest(prepareDatabase, onOpen); 8 indexedDBTest(prepareDatabase, onOpen);
9 9
10 function prepareDatabase(evt) 10 function prepareDatabase(evt)
11 { 11 {
12 preamble(evt); 12 preamble(evt);
13 evalAndLog("db = event.target.result"); 13 evalAndLog("db = event.target.result");
14 evalAndLog("store = db.createObjectStore('store')"); 14 evalAndLog("store = db.createObjectStore('store')");
15 store.put("value1", "key1"); 15 store.put("value1", "key1");
16 store.put("value2", "key2"); 16 store.put("value2", "key2");
17 } 17 }
18 18
19 function onOpen(evt) 19 function onOpen(evt)
20 { 20 {
21 preamble(evt); 21 preamble(evt);
22 evalAndLog("db = event.target.result"); 22 evalAndLog("db = event.target.result");
23 evalAndLog("tx = db.transaction('store')"); 23 evalAndLog("tx = db.transaction('store')");
24 evalAndLog("store = tx.objectStore('store')"); 24 evalAndLog("store = tx.objectStore('store')");
25 25
26 evalAndLog("cursorRequest = store.openCursor()"); 26 evalAndLog("cursorRequest = store.openKeyCursor()");
27 cursorRequest.onsuccess = function openCursorRequestSuccess(evt) { 27 cursorRequest.onsuccess = function openCursorRequestSuccess(evt) {
28 preamble(evt); 28 preamble(evt);
29 debug("Result will be checked later, to ensure that lazy access is safe" ); 29 debug("Result will be checked later, to ensure that lazy access is safe" );
30 }; 30 };
31 31
32 evalAndLog("otherRequest = store.get(0)"); 32 evalAndLog("otherRequest = store.get(0)");
33 otherRequest.onsuccess = function otherRequestSuccess(evt) { 33 otherRequest.onsuccess = function otherRequestSuccess(evt) {
34 preamble(evt); 34 preamble(evt);
35 35
36 debug("Verify that the request's result can be accessed lazily:"); 36 debug("Verify that the request's result can be accessed lazily:");
37 evalAndLog("gc()"); 37 evalAndLog("gc()");
38 38
39 evalAndLog("cursor = cursorRequest.result"); 39 evalAndLog("cursor = cursorRequest.result");
40 shouldBeNonNull("cursor"); 40 shouldBeNonNull("cursor");
41 shouldBeEqualToString("cursor.key", "key1"); 41 shouldBeEqualToString("cursor.key", "key1");
42 shouldBeEqualToString("cursor.value", "value1");
43 evalAndLog("cursorRequest.extra = 123"); 42 evalAndLog("cursorRequest.extra = 123");
44 evalAndLog("cursor.extra = 456"); 43 evalAndLog("cursor.extra = 456");
45 44
46 // Assign a new handler to inspect the request and cursor indirectly. 45 // Assign a new handler to inspect the request and cursor indirectly.
47 cursorRequest.onsuccess = function cursorContinueSuccess(evt) { 46 cursorRequest.onsuccess = function cursorContinueSuccess(evt) {
48 preamble(evt); 47 preamble(evt);
49 evalAndLog("cursor = event.target.result"); 48 evalAndLog("cursor = event.target.result");
50 shouldBeNonNull("cursor"); 49 shouldBeNonNull("cursor");
51 shouldBeEqualToString("cursor.key", "key2"); 50 shouldBeEqualToString("cursor.key", "key2");
52 shouldBeEqualToString("cursor.value", "value2");
53 shouldBe("event.target.extra", "123"); 51 shouldBe("event.target.extra", "123");
54 shouldBe("cursor.extra", "456"); 52 shouldBe("cursor.extra", "456");
55 }; 53 };
56 54
57 debug("Ensure request is not released if cursor is still around."); 55 debug("Ensure request is not released if cursor is still around.");
58 cursorRequestObservation = internals.observeGC(cursorRequest); 56 cursorRequestObservation = internals.observeGC(cursorRequest);
59 evalAndLog("cursorRequest = null"); 57 evalAndLog("cursorRequest = null");
60 evalAndLog("gc()"); 58 evalAndLog("gc()");
61 shouldBeFalse("cursorRequestObservation.wasCollected"); 59 shouldBeFalse("cursorRequestObservation.wasCollected");
62 60
63 evalAndLog("cursor.continue()"); 61 evalAndLog("cursor.continue()");
64 62
65 cursorObservation = internals.observeGC(cursor); 63 cursorObservation = internals.observeGC(cursor);
66 evalAndLog("cursor = null"); 64 evalAndLog("cursor = null");
67 evalAndLog("gc()"); 65 evalAndLog("gc()");
68 shouldBeFalse("cursorObservation.wasCollected"); 66 shouldBeFalse("cursorObservation.wasCollected");
69 67
70 evalAndLog("finalRequest = store.get(0)"); 68 evalAndLog("finalRequest = store.get(0)");
71 finalRequest.onsuccess = function finalRequestSuccess(evt) { 69 finalRequest.onsuccess = function finalRequestSuccess(evt) {
72 preamble(evt); 70 preamble(evt);
73 shouldBeEqualToString("cursor.key", "key2"); 71 shouldBeEqualToString("cursor.key", "key2");
74 shouldBeEqualToString("cursor.value", "value2");
75 72
76 cursorObservation = internals.observeGC(cursor); 73 cursorObservation = internals.observeGC(cursor);
77 evalAndLog("cursor = null"); 74 evalAndLog("cursor = null");
78 evalAndLog("gc()"); 75 evalAndLog("gc()");
79 shouldBeTrue("cursorRequestObservation.wasCollected"); 76 shouldBeTrue("cursorRequestObservation.wasCollected");
80 shouldBeTrue("cursorObservation.wasCollected"); 77 shouldBeTrue("cursorObservation.wasCollected");
81 }; 78 };
82 }; 79 };
83 80
84 tx.oncomplete = finishJSTest; 81 tx.oncomplete = finishJSTest;
85 } 82 }
86 83
87 84
88 </script> 85 </script>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/storage/indexeddb/key-cursor-request-cycle-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698