-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Converting databases() wpt tests to promise_tests to fix flakiness Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=899085 Change-Id: I91848796d7508408bb3e5b9fb05f725564fa9971 Reviewed-on: https://chromium-review.googlesource.com/c/1299959 Reviewed-by: Victor Costan <pwnall@chromium.org> Reviewed-by: Chase Phillips <cmp@chromium.org> Commit-Queue: Victor Costan <pwnall@chromium.org> Cr-Commit-Position: refs/heads/master@{#603701}
- Loading branch information
1 parent
7b94252
commit c169e95
Showing
3 changed files
with
69 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,62 @@ | ||
// META: script=support.js | ||
|
||
async_test( async function(t) { | ||
let made_database_check = t.step_func(async function() { | ||
let idb_databases_promise = await indexedDB.databases(); | ||
assert_true( | ||
idb_databases_promise.some( | ||
e => e.name == "TestDatabase" && e.version == 1), | ||
"Call to databases() did not find database."); | ||
t.done(); | ||
}); | ||
delete_then_open(t, "TestDatabase", ()=>{}, made_database_check); | ||
}, "Report one database test."); | ||
|
||
async_test( function(t) { | ||
let done_making_databases_callback = t.step_func(async function() { | ||
let idb_databases_promise = await indexedDB.databases(); | ||
assert_true( | ||
idb_databases_promise.some( | ||
e => e.name == "TestDatabase1" && e.version == 1), | ||
"Call to databases() did not find database."); | ||
assert_true( | ||
idb_databases_promise.some( | ||
e => e.name == "TestDatabase2" && e.version == 1), | ||
"Call to databases() did not find database."); | ||
assert_true( | ||
idb_databases_promise.some( | ||
e => e.name == "TestDatabase3" && e.version == 1), | ||
"Call to databases() did not find database."); | ||
t.done(); | ||
}); | ||
let make_databases_barrier = create_barrier(done_making_databases_callback); | ||
delete_then_open(t, "TestDatabase1", ()=>{}, make_databases_barrier(t)); | ||
delete_then_open(t, "TestDatabase2", ()=>{}, make_databases_barrier(t)); | ||
delete_then_open(t, "TestDatabase3", ()=>{}, make_databases_barrier(t)); | ||
}, "Report multiple databases test."); | ||
|
||
async_test( function(t) { | ||
let delete_request = indexedDB.deleteDatabase("NonExistentDatabase"); | ||
delete_request.onsuccess = t.step_func(async function() { | ||
let idb_databases_promise = await indexedDB.databases(); | ||
assert_false( | ||
idb_databases_promise.some( | ||
e => e.name == "NonExistentDatabase"), | ||
"Call to databases() found excluded database."); | ||
t.done(); | ||
}); | ||
}, "Don't report nonexistant databases test."); | ||
// META: script=support-promises.js | ||
|
||
promise_test(async testCase => { | ||
// Delete any databases that may not have been cleaned up after | ||
// previous test runs. | ||
await deleteAllDatabases(testCase); | ||
|
||
const db_name = "TestDatabase"; | ||
const db = await createNamedDatabase(testCase, db_name, ()=>{}); | ||
const databases_promise = await indexedDB.databases(); | ||
const expected_result = [ | ||
{"name": db_name, "version": 1}, | ||
]; | ||
assert_object_equals( | ||
databases_promise, | ||
expected_result, | ||
"Call to databases() did not retrieve the single expected result."); | ||
}, "Enumerate one database."); | ||
|
||
promise_test(async testCase => { | ||
// Delete any databases that may not have been cleaned up after previous test | ||
// runs. | ||
await deleteAllDatabases(testCase); | ||
|
||
const db_name1 = "TestDatabase1"; | ||
const db_name2 = "TestDatabase2"; | ||
const db_name3 = "TestDatabase3"; | ||
const db1 = await createNamedDatabase(testCase, db_name1, ()=>{}); | ||
const db2 = await createNamedDatabase(testCase, db_name2, ()=>{}); | ||
const db3 = await createNamedDatabase(testCase, db_name3, ()=>{}); | ||
const databases_promise = await indexedDB.databases(); | ||
const expected_result = [ | ||
{"name": db_name1, "version": 1}, | ||
{"name": db_name2, "version": 1}, | ||
{"name": db_name3, "version": 1}, | ||
]; | ||
assert_object_equals( | ||
databases_promise, | ||
expected_result, | ||
"Call to databases() did not retrieve the multiple expected results"); | ||
}, "Enumerate multiple databases."); | ||
|
||
promise_test(async testCase => { | ||
// Add some databases and close their connections. | ||
const db1 = await createNamedDatabase(testCase, "DB1", ()=>{}); | ||
const db2 = await createNamedDatabase(testCase, "DB2", ()=>{}); | ||
db1.onversionchange = () => { db1.close() }; | ||
db2.onversionchange = () => { db2.close() }; | ||
|
||
// Delete any databases that may not have been cleaned up after previous test | ||
// runs as well as the two databases made above. | ||
await deleteAllDatabases(testCase); | ||
|
||
// Make sure the databases are no longer returned. | ||
const databases_promise = await indexedDB.databases(); | ||
assert_object_equals( | ||
databases_promise, | ||
[], | ||
"Call to databases() found database it should not have.") | ||
}, "Make sure an empty list is returned for the case of no databases."); | ||
|
||
done(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters