Commit 3d61edae authored by jsbell@chromium.org's avatar jsbell@chromium.org

IndexedDB: Make sure indexing completes if object store is deleted

Unhandled case found via W3c web-platform-tests. If an indexing
operation is kicked off then the object store is deleted, an
ASSERT was hit since the cursor is invalid. Check (via the cursor)
that the store has not been deleted; if it has, stop indexing.

BUG=362711

Review URL: https://codereview.chromium.org/235883002

git-svn-id: svn://svn.chromium.org/blink/trunk@171377 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 4dd3aeca
This is a testharness.js-based test.
PASS deleteDatabase success event type, existing DB
Harness: the test ran to completion.
<!DOCTYPE html>
<title>IndexedDB: Deleting an object store with a new index should complete</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
var t = async_test('deleteDatabase success event type, existing DB');
t.step(function() {
var dbName = 'db' + location.pathname;
var openRequest = indexedDB.open(dbName);
openRequest.onupgradeneeded = t.step_func(function(e) {
var db = openRequest.result;
var store = db.createObjectStore('store');
store.put('value', 'key');
store.createIndex('index', 'keyPath');
assert_array_equals(db.objectStoreNames, ['store'], 'One store should be present.');
assert_array_equals(store.indexNames, ['index'], 'One index should be present.');
db.deleteObjectStore('store');
assert_array_equals(db.objectStoreNames, [], 'No stores should be present.');
});
openRequest.onsuccess = t.step_func(function(e) {
var db = openRequest.result;
assert_array_equals(db.objectStoreNames, [], 'No stores should be present.');
t.done();
});
});
</script>
......@@ -77,6 +77,7 @@ public:
void continueFunction(PassRefPtr<IDBKey>, PassRefPtr<IDBKey> primaryKey, ExceptionState&);
void postSuccessHandlerCallback();
bool isDeleted() const;
void close();
void setValueReady(PassRefPtr<IDBKey>, PassRefPtr<IDBKey> primaryKey, PassRefPtr<SharedBuffer> value);
PassRefPtr<IDBKey> idbPrimaryKey() const { return m_primaryKey; }
......@@ -99,7 +100,6 @@ private:
PassRefPtr<IDBObjectStore> effectiveObjectStore() const;
void checkForReferenceCycle();
bool isDeleted() const;
OwnPtr<blink::WebIDBCursor> m_backend;
RefPtr<IDBRequest> m_request;
......
......@@ -333,7 +333,7 @@ private:
Vector<int64_t> indexIds;
indexIds.append(m_indexMetadata.id);
if (cursor) {
if (cursor && !cursor->isDeleted()) {
cursor->continueFunction(static_cast<IDBKey*>(0), static_cast<IDBKey*>(0), ASSERT_NO_EXCEPTION);
RefPtr<IDBKey> primaryKey = cursor->idbPrimaryKey();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment