зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 0b329aa2c4e3 (bug 1653276) for assertion failures on ActorsChild.cpp. CLOSED TREE
This commit is contained in:
Родитель
3711f2ee72
Коммит
743e75604c
|
@ -1349,14 +1349,12 @@ bool BackgroundFactoryRequestChild::HandleResponse(
|
|||
static_cast<BackgroundDatabaseChild*>(aResponse.databaseChild());
|
||||
MOZ_ASSERT(databaseActor);
|
||||
|
||||
IDBDatabase* const database = [this, databaseActor]() -> IDBDatabase* {
|
||||
NotNull<IDBDatabase*> database = [this, databaseActor] {
|
||||
IDBDatabase* database = databaseActor->GetDOMObject();
|
||||
if (!database) {
|
||||
Unused << this;
|
||||
|
||||
if (NS_WARN_IF(!databaseActor->EnsureDOMObject())) {
|
||||
return nullptr;
|
||||
}
|
||||
databaseActor->EnsureDOMObject();
|
||||
MOZ_ASSERT(mDatabaseActor);
|
||||
|
||||
database = databaseActor->GetDOMObject();
|
||||
|
@ -1365,10 +1363,12 @@ bool BackgroundFactoryRequestChild::HandleResponse(
|
|||
MOZ_ASSERT(!database->IsClosed());
|
||||
}
|
||||
|
||||
return database;
|
||||
return WrapNotNullUnchecked(database);
|
||||
}();
|
||||
|
||||
if (!database || database->IsClosed()) {
|
||||
MOZ_ASSERT(mDatabaseActor == databaseActor);
|
||||
|
||||
if (database->IsClosed()) {
|
||||
// If the database was closed already, which is only possible if we fired an
|
||||
// "upgradeneeded" event, then we shouldn't fire a "success" event here.
|
||||
// Instead we fire an error event with AbortErr.
|
||||
|
@ -1377,13 +1377,7 @@ bool BackgroundFactoryRequestChild::HandleResponse(
|
|||
SetResultAndDispatchSuccessEvent(mRequest, nullptr, *database);
|
||||
}
|
||||
|
||||
if (database) {
|
||||
MOZ_ASSERT(mDatabaseActor == databaseActor);
|
||||
|
||||
databaseActor->ReleaseDOMObject();
|
||||
} else {
|
||||
databaseActor->SendDeleteMeInternal();
|
||||
}
|
||||
databaseActor->ReleaseDOMObject();
|
||||
MOZ_ASSERT(!mDatabaseActor);
|
||||
|
||||
return true;
|
||||
|
@ -1596,14 +1590,14 @@ void BackgroundDatabaseChild::SendDeleteMeInternal() {
|
|||
}
|
||||
}
|
||||
|
||||
bool BackgroundDatabaseChild::EnsureDOMObject() {
|
||||
void BackgroundDatabaseChild::EnsureDOMObject() {
|
||||
AssertIsOnOwningThread();
|
||||
MOZ_ASSERT(mOpenRequestActor);
|
||||
|
||||
if (mTemporaryStrongDatabase) {
|
||||
MOZ_ASSERT(!mSpec);
|
||||
MOZ_ASSERT(mDatabase == mTemporaryStrongDatabase);
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(mSpec);
|
||||
|
@ -1613,11 +1607,6 @@ bool BackgroundDatabaseChild::EnsureDOMObject() {
|
|||
auto& factory =
|
||||
static_cast<BackgroundFactoryChild*>(Manager())->GetDOMObject();
|
||||
|
||||
if (!factory.GetParentObject()) {
|
||||
// Already disconnected from global.
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: This AcquireStrongRefFromRawPtr looks suspicious. This should be
|
||||
// changed or at least well explained, see also comment on
|
||||
// BackgroundFactoryChild.
|
||||
|
@ -1631,8 +1620,6 @@ bool BackgroundDatabaseChild::EnsureDOMObject() {
|
|||
mDatabase = mTemporaryStrongDatabase;
|
||||
|
||||
mOpenRequestActor->SetDatabaseActor(this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void BackgroundDatabaseChild::ReleaseDOMObject() {
|
||||
|
@ -1722,28 +1709,9 @@ BackgroundDatabaseChild::RecvPBackgroundIDBVersionChangeTransactionConstructor(
|
|||
|
||||
MaybeCollectGarbageOnIPCMessage();
|
||||
|
||||
auto* const actor =
|
||||
static_cast<BackgroundVersionChangeTransactionChild*>(aActor);
|
||||
EnsureDOMObject();
|
||||
|
||||
if (!EnsureDOMObject()) {
|
||||
NS_WARNING("Factory is already disconnected from global");
|
||||
|
||||
actor->SendDeleteMeInternal(true);
|
||||
|
||||
// XXX This is a hack to ensure that transaction/request serial numbers stay
|
||||
// in sync between parent and child. Actually, it might be better to create
|
||||
// an IDBTransaction in the child and abort that.
|
||||
Unused
|
||||
<< mozilla::ipc::BackgroundChildImpl::GetThreadLocalForCurrentThread()
|
||||
->mIndexedDBThreadLocal->NextTransactionSN(
|
||||
IDBTransaction::Mode::VersionChange);
|
||||
Unused << IDBRequest::NextSerialNumber();
|
||||
|
||||
// If we return IPC_FAIL_NO_REASON(this) here, we crash...
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
MOZ_ASSERT(!mDatabase->IsInvalidated());
|
||||
auto* actor = static_cast<BackgroundVersionChangeTransactionChild*>(aActor);
|
||||
|
||||
// XXX NotNull might encapsulate this
|
||||
const auto request =
|
||||
|
|
|
@ -249,7 +249,7 @@ class BackgroundDatabaseChild final : public PBackgroundIDBDatabaseChild {
|
|||
|
||||
void SendDeleteMeInternal();
|
||||
|
||||
[[nodiscard]] bool EnsureDOMObject();
|
||||
void EnsureDOMObject();
|
||||
|
||||
void ReleaseDOMObject();
|
||||
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
|
||||
<body>
|
||||
<script>
|
||||
function createDb() {
|
||||
return new Promise((resolve, reject) => {
|
||||
const openRequest = indexedDB.open("test-abort-on-reload", 1);
|
||||
openRequest.onsuccess = () => {
|
||||
const db = openRequest.result;
|
||||
// This would throw when db is corrupted.
|
||||
db.transaction("databases", "readwrite");
|
||||
db.onversionchange = () => {
|
||||
db.close();
|
||||
};
|
||||
resolve();
|
||||
};
|
||||
openRequest.onupgradeneeded = (evt) => {
|
||||
// Interrupt upgrade
|
||||
window.location.reload();
|
||||
opener.info('reload requested\n');
|
||||
openRequest.result.createObjectStore("databases");
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function reset() {
|
||||
return new Promise((resolve, reject) => {
|
||||
const request = indexedDB.deleteDatabase("test-abort-on-reload");
|
||||
request.onsuccess = resolve;
|
||||
});
|
||||
}
|
||||
|
||||
async function test() {
|
||||
opener.postMessage("message", "*");
|
||||
|
||||
for (let i = 0; i < 10; ++i) {
|
||||
opener.info(`iteration ${i}`);
|
||||
await createDb();
|
||||
await reset();
|
||||
}
|
||||
}
|
||||
|
||||
test();
|
||||
</script>
|
||||
</body>
|
|
@ -119,9 +119,6 @@ support-files =
|
|||
|
||||
[test_abort_deleted_index.html]
|
||||
[test_abort_deleted_objectStore.html]
|
||||
[test_abort_on_reload.html]
|
||||
support-files =
|
||||
abort_on_reload.html
|
||||
[test_add_put.html]
|
||||
[test_add_twice_failure.html]
|
||||
[test_advance.html]
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<title>Indexed Database Test</title>
|
||||
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
|
||||
<script type="text/javascript">
|
||||
let openedWindow
|
||||
let reloads = 0
|
||||
|
||||
function openWindow() {
|
||||
openedWindow = window.open("abort_on_reload.html");
|
||||
}
|
||||
|
||||
function messageListener(event) {
|
||||
ok(true, "reload recorded");
|
||||
|
||||
if (++reloads == 20) {
|
||||
openedWindow.close();
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
|
||||
function runTest() {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
window.addEventListener("message", messageListener);
|
||||
|
||||
openWindow();
|
||||
}
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body onload="runTest();">
|
||||
</body>
|
||||
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче