Skip to content

Commit dbb289b

Browse files
Evan Stadechromium-wpt-export-bot
authored andcommitted
IDB: handle double deletion in SQLite store.
calling deleteDatabase() on a non-existent database normally doesn't even create a Database object, but if it does exist and deleteDatabase is called on it twice, the first call will delete the DatabaseConnection and the second call (enqueued behind the first) needs to be able to handle this state. Bug: 4025399 Change-Id: I64279e940e79af5435447cda7cf9304d5f61a288 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6658503 Reviewed-by: Abhishek Shanthkumar <[email protected]> Commit-Queue: Evan Stade <[email protected]> Cr-Commit-Position: refs/heads/main@{#1478097}
1 parent c9943d6 commit dbb289b

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

IndexedDB/idbfactory_deleteDatabase.any.js

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,36 @@
55
'use strict';
66

77
async_test(t => {
8-
const open_rq = createdb(t, undefined, 9);
8+
const delete_rq = indexedDB.deleteDatabase('db-that-doesnt-exist');
9+
delete_rq.onerror = fail(t, 'delete_rq.error');
10+
delete_rq.onsuccess = t.step_func(e => {
11+
assert_equals(e.oldVersion, 0, 'event.oldVersion');
12+
assert_equals(e.target.source, null, 'event.target.source');
13+
});
914

15+
const open_rq = createdb(t, undefined, 9);
1016
open_rq.onupgradeneeded = t.step_func(e => {});
1117
open_rq.onsuccess = t.step_func(e => {
1218
const db = e.target.result;
1319
db.close();
1420

15-
const delete_rq = indexedDB.deleteDatabase(db.name);
16-
delete_rq.onerror = t.step_func(e => {
17-
assert_unreached('Unexpected delete_rq.error event');
21+
const delete_rq1 = indexedDB.deleteDatabase(db.name);
22+
delete_rq1.onerror = fail(t, 'delete_rq1.error');
23+
delete_rq1.onsuccess = t.step_func(e => {
24+
assert_equals(e.oldVersion, 9, 'event.oldVersion');
25+
assert_equals(e.target.source, null, 'event.target.source');
1826
});
19-
delete_rq.onsuccess = t.step_func(e => {
27+
28+
const delete_rq2 = indexedDB.deleteDatabase(db.name);
29+
delete_rq2.onerror = fail(t, 'delete_rq2.error');
30+
31+
delete_rq2.onsuccess = t.step_func_done(e => {
32+
assert_equals(e.oldVersion, 0, 'event.oldVersion');
2033
assert_equals(e.target.source, null, 'event.target.source');
21-
t.done();
2234
});
2335
});
24-
}, 'deleteDatabase() request should have no source');
36+
}, 'deleteDatabase() request should have no source, and deleting a non-existent\
37+
database should succeed with oldVersion of 0.');
2538

2639
async_test(t => {
2740
const open_rq = createdb(t, undefined, 9);

0 commit comments

Comments
 (0)