Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector / sources / debugger-async / async-callstack-indexed-db.html
blobf701d058572da433d20ced09fe8ad0e46ab636f0
1 <html>
2 <head>
3 <script src="../../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../../http/tests/inspector/debugger-test.js"></script>
5 <script>
7 var version = 1;
8 var db;
10 function testFunction()
12 setTimeout(openDB);
15 function onError()
17 console.error("FAIL: " + new Error().stack);
18 debugger;
21 function openDB()
23 var request = indexedDB.open("async-callstack-indexed-db", version);
24 request.onupgradeneeded = onUpgradeNeeded;
25 request.onsuccess = onSuccessOpenDB;
26 request.onerror = onError;
29 function onUpgradeNeeded(e)
31 debugger;
32 var db = e.target.result;
33 e.target.transaction.onerror = onError;
35 if (db.objectStoreNames.contains("foo"))
36 db.deleteObjectStore("foo");
38 db.createObjectStore("foo", { keyPath: "id" });
41 function onSuccessOpenDB(e)
43 debugger;
44 db = e.target.result;
45 populateDB();
48 function populateDB()
50 var trans = db.transaction(["foo"], "readwrite");
51 var store = trans.objectStore("foo");
52 var request = store.put({ "id" : 1, "bar": "baz" });
53 request.onsuccess = onSuccessStorePut;
54 request.onerror = onError;
57 function onSuccessStorePut(e)
59 debugger;
60 getAllItems();
63 function getAllItems()
65 var trans = db.transaction(["foo"], "readwrite");
66 var store = trans.objectStore("foo");
67 var keyRange = IDBKeyRange.lowerBound(0);
68 var cursorRequest = store.openCursor(keyRange);
69 cursorRequest.onsuccess = onSuccessCursorRequest;
70 cursorRequest.onerror = onError;
73 function onSuccessCursorRequest(e)
75 debugger;
76 deleteItem();
79 function deleteItem()
81 var trans = db.transaction(["foo"], "readwrite");
82 var store = trans.objectStore("foo");
83 var request = store.delete(1);
84 request.onsuccess = onSuccessDeleteItem;
85 request.onerror = onError;
88 function onSuccessDeleteItem()
90 debugger;
91 deleteDB();
94 function deleteDB()
96 db.close();
97 var request = indexedDB.deleteDatabase("async-callstack-indexed-db");
98 request.onsuccess = onSuccessDeleteDatabase;
99 request.onerror = onError;
102 function onSuccessDeleteDatabase()
104 debugger;
107 function test()
109 var totalDebuggerStatements = 6;
110 var maxAsyncCallStackDepth = 4;
111 InspectorTest.runAsyncCallStacksTest(totalDebuggerStatements, maxAsyncCallStackDepth);
114 </script>
115 </head>
117 <body onload="runTest()">
118 <input type='button' onclick='testFunction()' value='Test'/>
120 Tests asynchronous call stacks for IndexedDB.
121 </p>
122 </body>
123 </html>