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

Unified 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: Added Status checks. 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 side-by-side diff with in-line comments
Download patch
Index: content/test/data/indexeddb/corrupted_open_db_detection.html
diff --git a/content/test/data/indexeddb/corrupted_open_db_detection.html b/content/test/data/indexeddb/corrupted_open_db_detection.html
index 198aed551b8562f7204bf4893915ca14f5668b78..2778c02450ba18f754468435da41f347eb7b682b 100644
--- a/content/test/data/indexeddb/corrupted_open_db_detection.html
+++ b/content/test/data/indexeddb/corrupted_open_db_detection.html
@@ -10,7 +10,10 @@
<script type="text/javascript" src="common.js"></script>
<script>
+var testType = 'get';
+
function test() {
+ testType = location.hash.substring(1);
indexedDBTest(upgradeCallback, openCallback);
}
@@ -92,6 +95,27 @@ function getData() {
request.onerror = requestError;
}
+function iterateData() {
+ transaction = db.transaction('storeName');
+ db.onclose = databaseClosed;
+ transaction.onabort = transactionAbort;
+ transaction.onerror = transactionError;
+ var store = transaction.objectStore('storeName');
+ var request = store.openCursor();
+ request.oncomplete = unexpectedCompleteCallback;
+ request.onerror = requestError;
+ request.onsuccess = function (event){
+ var cursor = request.result;
+ if (cursor) {
+ // Get an object. Probably shouldn't get this far, but won't call this an error.
+ cursor.continue();
+ } else {
+ // Got the last object. We shouldn't get this far.
+ fail("Should *not* have been able to iterate over database.");
+ }
+ };
+}
+
function openCallback() {
var xmlhttp = new window.XMLHttpRequest();
xmlhttp.open("GET", "/corrupt/test/corruptdb?storeName", false /*sync*/);
@@ -99,7 +123,13 @@ function openCallback() {
if (xmlhttp.readyState === 4) {
if (xmlhttp.status === 200) {
// The database is now corrupt.
- getData();
+ if (testType === 'get') {
+ getData();
+ } else if (testType === 'iterate') {
+ iterateData();
+ } else {
+ fail('Unknown test: "' + testType + '"');
+ }
}
}
};

Powered by Google App Engine
This is Rietveld 408576698