mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-27 04:05:32 +00:00
0cdebe20d7
In retrospect, overloading `Connection::connectionReady` to mean "is ready _and_ supports this operation" wasn't a good idea. This commit reverts that change (cfd44c936a9b), and adds two new methods: * `Connection::operationSupported`, to check if a connection supports sync or async operations. This method is public. * `Connection::ensureOperationSupported`, that asserts or returns an error if the connection doesn't support an operation. This is private. `operationSupported` is used by callers like `Service::minimizeMemory` to detect if the connection supports sync operations, since both sync and async connections implement `mozIStorageConnection` now. Finally, some callers used `!mDBConn` to check if the connection was ready, while others used `connectionReady()`. This commit changes them to use the latter. Differential Revision: https://phabricator.services.mozilla.com/D24974 --HG-- extra : moz-landing-system : lando
23 lines
650 B
JavaScript
23 lines
650 B
JavaScript
/* Any copyright is dedicated to the Public Domain.
|
|
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
// This file tests that invoking `Service::minimizeMemory` succeeds for sync
|
|
// and async connections.
|
|
|
|
function minimizeMemory() {
|
|
Services.storage.QueryInterface(Ci.nsIObserver)
|
|
.observe(null, "memory-pressure", null);
|
|
}
|
|
|
|
add_task(async function test_minimizeMemory_async_connection() {
|
|
let db = await openAsyncDatabase(getTestDB());
|
|
minimizeMemory();
|
|
await asyncClose(db);
|
|
});
|
|
|
|
add_task(async function test_minimizeMemory_sync_connection() {
|
|
let db = getOpenedDatabase();
|
|
minimizeMemory();
|
|
db.close();
|
|
});
|