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

Side by Side Diff: content/test/data/indexeddb/corrupted_open_db_detection.html

Issue 237143006: Make iterating over a corrupted IndexedDB fail. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <!-- 3 <!--
4 Copyright 2014 The Chromium Authors. All rights reserved. 4 Copyright 2014 The Chromium Authors. All rights reserved.
5 Use of this source code is governed by a BSD-style license that can be 5 Use of this source code is governed by a BSD-style license that can be
6 found in the LICENSE file. 6 found in the LICENSE file.
7 --> 7 -->
8 <head> 8 <head>
9 <title>IDB test that db's corrupted while open are properly handled Part 1 / 2</ title> 9 <title>IDB test that db's corrupted while open are properly handled Part 1 / 2</ title>
10 <script type="text/javascript" src="common.js"></script> 10 <script type="text/javascript" src="common.js"></script>
11 <script> 11 <script>
12 12
13 var testType = 'get';
14
13 function test() { 15 function test() {
16 testType = location.hash.substring(1);
14 indexedDBTest(upgradeCallback, openCallback); 17 indexedDBTest(upgradeCallback, openCallback);
15 } 18 }
16 19
17 var numObjectsWrittenToDb = 500; 20 var numObjectsWrittenToDb = 500;
18 var numTransactions = 0; 21 var numTransactions = 0;
19 var numTransactionErrors = 0; 22 var numTransactionErrors = 0;
20 var numTransactionAborts = 0; 23 var numTransactionAborts = 0;
21 var numKeys = 0; 24 var numKeys = 0;
22 var transaction; 25 var transaction;
23 var request; 26 var request;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 db.onclose = databaseClosed; 88 db.onclose = databaseClosed;
86 transaction.onabort = transactionAbort; 89 transaction.onabort = transactionAbort;
87 transaction.onerror = transactionError; 90 transaction.onerror = transactionError;
88 request.oncomplete = unexpectedCompleteCallback; 91 request.oncomplete = unexpectedCompleteCallback;
89 store = transaction.objectStore('storeName'); 92 store = transaction.objectStore('storeName');
90 request = store.get('key-0'); 93 request = store.get('key-0');
91 request.onsuccess = unexpectedSuccessCallback; 94 request.onsuccess = unexpectedSuccessCallback;
92 request.onerror = requestError; 95 request.onerror = requestError;
93 } 96 }
94 97
98 function iterateData() {
99 transaction = db.transaction('storeName');
100 db.onclose = databaseClosed;
101 transaction.onabort = transactionAbort;
102 transaction.onerror = transactionError;
103 var store = transaction.objectStore('storeName');
104 var request = store.openCursor();
105 request.oncomplete = unexpectedCompleteCallback;
106 request.onerror = requestError;
107 request.onsuccess = function (event){
108 var cursor = request.result;
109 if (cursor) {
110 // Get an object. Probably shouldn't get this far, but won't call this an error.
111 cursor.continue();
112 } else {
113 // Got the last object. We shouldn't get this far.
114 fail("Should *not* have been able to iterate over database.");
115 }
116 };
117 }
118
95 function openCallback() { 119 function openCallback() {
96 var xmlhttp = new window.XMLHttpRequest(); 120 var xmlhttp = new window.XMLHttpRequest();
97 xmlhttp.open("GET", "/corrupt/test/corruptdb?storeName", false /*sync*/); 121 xmlhttp.open("GET", "/corrupt/test/corruptdb?storeName", false /*sync*/);
98 xmlhttp.onreadystatechange = function() { 122 xmlhttp.onreadystatechange = function() {
99 if (xmlhttp.readyState === 4) { 123 if (xmlhttp.readyState === 4) {
100 if (xmlhttp.status === 200) { 124 if (xmlhttp.status === 200) {
101 // The database is now corrupt. 125 // The database is now corrupt.
102 getData(); 126 if (testType === 'get') {
127 getData();
128 } else if (testType === 'iterate') {
129 iterateData();
130 }
131 else {
jsbell 2014/04/14 20:44:20 nit: Put on same line as }
cmumford 2014/04/14 23:39:23 Done.
132 fail('Unknown test: "' + testType + '"');
133 }
103 } 134 }
104 } 135 }
105 }; 136 };
106 xmlhttp.send(); 137 xmlhttp.send();
107 } 138 }
108 139
109 </script> 140 </script>
110 </head> 141 </head>
111 <body onLoad="test()"> 142 <body onLoad="test()">
112 <div id="status">Starting...</div> 143 <div id="status">Starting...</div>
113 </body> 144 </body>
114 </html> 145 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698