mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 04:41:11 +00:00
Bug 1919428 - SDB: Add a new testing only notification for database work starting; r=dom-storage-reviewers,jari
Differential Revision: https://phabricator.services.mozilla.com/D220107
This commit is contained in:
parent
64442a38cd
commit
c963354f7a
@ -48,6 +48,7 @@
|
||||
#include "mozilla/ipc/PBackgroundParent.h"
|
||||
#include "mozilla/ipc/PBackgroundSharedTypes.h"
|
||||
#include "mozilla/ipc/ProtocolUtils.h"
|
||||
#include "NotifyUtils.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsError.h"
|
||||
@ -1162,6 +1163,8 @@ nsresult OpenOp::SendToIOThread() {
|
||||
return rv;
|
||||
}
|
||||
|
||||
simpledb::NotifyDatabaseWorkStarted();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
22
dom/simpledb/NotifyUtils.cpp
Normal file
22
dom/simpledb/NotifyUtils.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "NotifyUtils.h"
|
||||
|
||||
#include "mozilla/StaticPrefs_dom.h"
|
||||
#include "mozilla/dom/quota/NotifyUtilsCommon.h"
|
||||
|
||||
namespace mozilla::dom::simpledb {
|
||||
|
||||
void NotifyDatabaseWorkStarted() {
|
||||
if (!StaticPrefs::dom_quotaManager_testing()) {
|
||||
return;
|
||||
}
|
||||
|
||||
quota::NotifyObserversOnMainThread("SimpleDB::DatabaseWorkStarted");
|
||||
}
|
||||
|
||||
} // namespace mozilla::dom::simpledb
|
16
dom/simpledb/NotifyUtils.h
Normal file
16
dom/simpledb/NotifyUtils.h
Normal file
@ -0,0 +1,16 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef DOM_SIMPLEDB_NOTIFYUTILS_H_
|
||||
#define DOM_SIMPLEDB_NOTIFYUTILS_H_
|
||||
|
||||
namespace mozilla::dom::simpledb {
|
||||
|
||||
void NotifyDatabaseWorkStarted();
|
||||
|
||||
} // namespace mozilla::dom::simpledb
|
||||
|
||||
#endif // DOM_SIMPLEDB_NOTIFYUTILS_H_
|
@ -26,6 +26,7 @@ EXPORTS.mozilla.dom += [
|
||||
UNIFIED_SOURCES += [
|
||||
"ActorsChild.cpp",
|
||||
"ActorsParent.cpp",
|
||||
"NotifyUtils.cpp",
|
||||
"SDBConnection.cpp",
|
||||
"SDBRequest.cpp",
|
||||
"SDBResults.cpp",
|
||||
|
36
dom/simpledb/test/xpcshell/test_databaseWorkStarted.js
Normal file
36
dom/simpledb/test/xpcshell/test_databaseWorkStarted.js
Normal file
@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
const { PrincipalUtils } = ChromeUtils.importESModule(
|
||||
"resource://testing-common/dom/quota/test/modules/PrincipalUtils.sys.mjs"
|
||||
);
|
||||
const { SimpleDBUtils } = ChromeUtils.importESModule(
|
||||
"resource://testing-common/dom/simpledb/test/modules/SimpleDBUtils.sys.mjs"
|
||||
);
|
||||
const { TestUtils } = ChromeUtils.importESModule(
|
||||
"resource://testing-common/TestUtils.sys.mjs"
|
||||
);
|
||||
|
||||
add_task(async function testSteps() {
|
||||
const principal = PrincipalUtils.createPrincipal("https://example.com");
|
||||
const name = "test_databaseWorkStarted.js";
|
||||
|
||||
info("Starting database opening");
|
||||
|
||||
const openPromise = (async function () {
|
||||
const connection = SimpleDBUtils.createConnection(principal);
|
||||
const request = connection.open(name);
|
||||
const promise = SimpleDBUtils.requestFinished(request);
|
||||
return promise;
|
||||
})();
|
||||
|
||||
info("Waiting for database work to start");
|
||||
|
||||
await TestUtils.topicObserved("SimpleDB::DatabaseWorkStarted");
|
||||
|
||||
info("Waiting for database to finish opening");
|
||||
|
||||
await openPromise;
|
||||
});
|
@ -1,4 +1,6 @@
|
||||
[DEFAULT]
|
||||
head = "head.js"
|
||||
|
||||
["test_databaseWorkStarted.js"]
|
||||
|
||||
["test_slowStorageInitialization.js"]
|
||||
|
Loading…
Reference in New Issue
Block a user