mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-25 18:07:31 +09:00
Fix IndexedDB clone failures for WebExtension cache records
This commit is contained in:
parent
f20132edb0
commit
e5a431b519
1 changed files with 36 additions and 0 deletions
|
|
@ -46,6 +46,28 @@ namespace {
|
||||||
|
|
||||||
NS_DEFINE_IID(kIDBRequestIID, PRIVATE_IDBREQUEST_IID);
|
NS_DEFINE_IID(kIDBRequestIID, PRIVATE_IDBREQUEST_IID);
|
||||||
|
|
||||||
|
bool
|
||||||
|
IsExtensionDatabase(IDBTransaction* aTransaction)
|
||||||
|
{
|
||||||
|
if (!aTransaction || !aTransaction->Database()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
IDBFactory* factory = aTransaction->Database()->Factory();
|
||||||
|
if (!factory || !factory->GetPrincipalInfo()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const PrincipalInfo* principalInfo = factory->GetPrincipalInfo();
|
||||||
|
if (principalInfo->type() != PrincipalInfo::TContentPrincipalInfo) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return StringBeginsWith(
|
||||||
|
principalInfo->get_ContentPrincipalInfo().originNoSuffix(),
|
||||||
|
NS_LITERAL_CSTRING("moz-extension://"));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
IDBRequest::IDBRequest(IDBDatabase* aDatabase)
|
IDBRequest::IDBRequest(IDBDatabase* aDatabase)
|
||||||
|
|
@ -389,6 +411,20 @@ IDBRequest::SetResultCallback(ResultCallback* aCallback)
|
||||||
// as NS_ERROR_DOM_DATA_CLONE_ERR here.
|
// as NS_ERROR_DOM_DATA_CLONE_ERR here.
|
||||||
MOZ_ASSERT(rv == NS_ERROR_DOM_DATA_CLONE_ERR);
|
MOZ_ASSERT(rv == NS_ERROR_DOM_DATA_CLONE_ERR);
|
||||||
|
|
||||||
|
// Legacy WebExtension caches may contain structured-clone values that
|
||||||
|
// this older IndexedDB implementation cannot materialize (uBO discards
|
||||||
|
// these records while migrating its disposable cache). Treat such a
|
||||||
|
// record as absent so the extension can use its storage.local fallback.
|
||||||
|
// Keep the standards-required failure behavior for regular web origins.
|
||||||
|
if (rv == NS_ERROR_DOM_DATA_CLONE_ERR &&
|
||||||
|
IsExtensionDatabase(mTransaction)) {
|
||||||
|
JS_ClearPendingException(cx);
|
||||||
|
mError = nullptr;
|
||||||
|
mResultVal.setUndefined();
|
||||||
|
mHaveResultOrErrorCode = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// We are not setting a result or an error object here since we want to
|
// We are not setting a result or an error object here since we want to
|
||||||
// throw an exception when the 'result' property is being touched.
|
// throw an exception when the 'result' property is being touched.
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue