Bug 1919493 - IDB: Add a new testing only notification for database work starting; r=dom-storage-reviewers,jari
Differential Revision: https://phabricator.services.mozilla.com/D220245
This commit is contained in:
@@ -148,6 +148,7 @@
|
||||
#include "mozilla/ipc/ProtocolUtils.h"
|
||||
#include "mozilla/mozalloc.h"
|
||||
#include "mozilla/storage/Variant.h"
|
||||
#include "NotifyUtils.h"
|
||||
#include "nsBaseHashtable.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsClassHashtable.h"
|
||||
@@ -14886,6 +14887,8 @@ nsresult FactoryOp::SendToIOThread() {
|
||||
quotaManager->IOThread()->Dispatch(this, NS_DISPATCH_NORMAL)),
|
||||
NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR, IDB_REPORT_INTERNAL_ERR_LAMBDA);
|
||||
|
||||
NotifyDatabaseWorkStarted();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
22
dom/indexedDB/NotifyUtils.cpp
Normal file
22
dom/indexedDB/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::indexedDB {
|
||||
|
||||
void NotifyDatabaseWorkStarted() {
|
||||
if (!StaticPrefs::dom_indexedDB_testing()) {
|
||||
return;
|
||||
}
|
||||
|
||||
quota::NotifyObserversOnMainThread("IndexedDB::DatabaseWorkStarted");
|
||||
}
|
||||
|
||||
} // namespace mozilla::dom::indexedDB
|
||||
16
dom/indexedDB/NotifyUtils.h
Normal file
16
dom/indexedDB/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_INDEXEDDB_NOTIFYUTILS_H_
|
||||
#define DOM_INDEXEDDB_NOTIFYUTILS_H_
|
||||
|
||||
namespace mozilla::dom::indexedDB {
|
||||
|
||||
void NotifyDatabaseWorkStarted();
|
||||
|
||||
} // namespace mozilla::dom::indexedDB
|
||||
|
||||
#endif // DOM_INDEXEDDB_NOTIFYUTILS_H_
|
||||
@@ -83,6 +83,7 @@ UNIFIED_SOURCES += [
|
||||
"IndexedDatabaseManager.cpp",
|
||||
"IndexedDBCommon.cpp",
|
||||
"KeyPath.cpp",
|
||||
"NotifyUtils.cpp",
|
||||
"ProfilerHelpers.cpp",
|
||||
"ReportInternalError.cpp",
|
||||
"SchemaUpgrades.cpp",
|
||||
|
||||
36
dom/indexedDB/test/unit/test_databaseWorkStarted.js
Normal file
36
dom/indexedDB/test/unit/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 { IndexedDBUtils } = ChromeUtils.importESModule(
|
||||
"resource://testing-common/dom/indexedDB/test/modules/IndexedDBUtils.sys.mjs"
|
||||
);
|
||||
const { TestUtils } = ChromeUtils.importESModule(
|
||||
"resource://testing-common/TestUtils.sys.mjs"
|
||||
);
|
||||
|
||||
/* exported testSteps */
|
||||
async function testSteps() {
|
||||
const principal = PrincipalUtils.createPrincipal("https://example.com");
|
||||
const name = "test_databaseWorkStarted.js";
|
||||
|
||||
info("Starting database opening");
|
||||
|
||||
const openPromise = (async function () {
|
||||
const request = indexedDB.openForPrincipal(principal, name);
|
||||
const promise = IndexedDBUtils.requestFinished(request);
|
||||
return promise;
|
||||
})();
|
||||
|
||||
info("Waiting for database work to start");
|
||||
|
||||
await TestUtils.topicObserved("IndexedDB::DatabaseWorkStarted");
|
||||
|
||||
info("Waiting for database to finish opening");
|
||||
|
||||
await openPromise;
|
||||
}
|
||||
@@ -48,6 +48,8 @@ skip-if = ["tsan"]
|
||||
|
||||
["test_connection_idle_maintenance_stop.js"]
|
||||
|
||||
["test_databaseWorkStarted.js"]
|
||||
|
||||
["test_database_close_without_onclose.js"]
|
||||
|
||||
["test_database_onclose.js"]
|
||||
|
||||
Reference in New Issue
Block a user