зеркало из https://github.com/mozilla/gecko-dev.git
Bug 916094 - Assertions removed from IDBFactory::Create() when it's used in JS from chrome in IPC. r=bent
This commit is contained in:
Родитель
a4808ff3f8
Коммит
ee8268ad59
|
@ -191,10 +191,8 @@ IDBFactory::Create(JSContext* aCx,
|
|||
nsCString origin;
|
||||
StoragePrivilege privilege;
|
||||
PersistenceType defaultPersistenceType;
|
||||
nsresult rv =
|
||||
QuotaManager::GetInfoFromWindow(nullptr, &group, &origin, &privilege,
|
||||
&defaultPersistenceType);
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
QuotaManager::GetInfoForChrome(&group, &origin, &privilege,
|
||||
&defaultPersistenceType);
|
||||
|
||||
nsRefPtr<IDBFactory> factory = new IDBFactory();
|
||||
factory->mGroup = group;
|
||||
|
@ -231,6 +229,15 @@ IDBFactory::Create(ContentParent* aContentParent,
|
|||
|
||||
NS_ASSERTION(!nsContentUtils::GetCurrentJSContext(), "Should be called from C++");
|
||||
|
||||
// We need to get this information before we push a null principal to avoid
|
||||
// IsCallerChrome() assertion in quota manager.
|
||||
nsCString group;
|
||||
nsCString origin;
|
||||
StoragePrivilege privilege;
|
||||
PersistenceType defaultPersistenceType;
|
||||
QuotaManager::GetInfoForChrome(&group, &origin, &privilege,
|
||||
&defaultPersistenceType);
|
||||
|
||||
nsCOMPtr<nsIPrincipal> principal =
|
||||
do_CreateInstance("@mozilla.org/nullprincipal;1");
|
||||
NS_ENSURE_TRUE(principal, NS_ERROR_FAILURE);
|
||||
|
@ -253,9 +260,13 @@ IDBFactory::Create(ContentParent* aContentParent,
|
|||
|
||||
JSAutoCompartment ac(cx, global);
|
||||
|
||||
nsRefPtr<IDBFactory> factory;
|
||||
rv = Create(cx, global, aContentParent, getter_AddRefs(factory));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsRefPtr<IDBFactory> factory = new IDBFactory();
|
||||
factory->mGroup = group;
|
||||
factory->mASCIIOrigin = origin;
|
||||
factory->mPrivilege = privilege;
|
||||
factory->mDefaultPersistenceType = defaultPersistenceType;
|
||||
factory->mOwningObject = global;
|
||||
factory->mContentParent = aContentParent;
|
||||
|
||||
mozilla::HoldJSObjects(factory.get());
|
||||
factory->mRootedOwningObject = true;
|
||||
|
@ -609,12 +620,7 @@ IDBFactory::OpenInternal(const nsAString& aName,
|
|||
rv = openHelper->WaitForOpenAllowed();
|
||||
}
|
||||
else {
|
||||
StoragePrivilege openerPrivilege;
|
||||
rv = QuotaManager::GetInfoFromWindow(window, nullptr, nullptr,
|
||||
&openerPrivilege, nullptr);
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
|
||||
if (openerPrivilege != Chrome &&
|
||||
if (mPrivilege != Chrome &&
|
||||
aPersistenceType == PERSISTENCE_TYPE_PERSISTENT) {
|
||||
nsRefPtr<CheckPermissionsHelper> permissionHelper =
|
||||
new CheckPermissionsHelper(openHelper, window);
|
||||
|
|
|
@ -925,27 +925,6 @@ GetTemporaryStorageLimit(nsIFile* aDirectory, uint64_t aCurrentUsage,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
GetInfoForChrome(nsACString* aGroup, nsACString* aASCIIOrigin,
|
||||
StoragePrivilege* aPrivilege,
|
||||
PersistenceType* aDefaultPersistenceType)
|
||||
{
|
||||
static const char kChromeOrigin[] = "chrome";
|
||||
|
||||
if (aGroup) {
|
||||
aGroup->AssignLiteral(kChromeOrigin);
|
||||
}
|
||||
if (aASCIIOrigin) {
|
||||
aASCIIOrigin->AssignLiteral(kChromeOrigin);
|
||||
}
|
||||
if (aPrivilege) {
|
||||
*aPrivilege = Chrome;
|
||||
}
|
||||
if (aDefaultPersistenceType) {
|
||||
*aDefaultPersistenceType = PERSISTENCE_TYPE_PERSISTENT;
|
||||
}
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
QuotaManager::QuotaManager()
|
||||
|
@ -2163,13 +2142,7 @@ QuotaManager::GetInfoFromWindow(nsPIDOMWindow* aWindow,
|
|||
{
|
||||
NS_ASSERTION(NS_IsMainThread(),
|
||||
"We're about to touch a window off the main thread!");
|
||||
|
||||
if (!aWindow) {
|
||||
NS_ASSERTION(nsContentUtils::IsCallerChrome(),
|
||||
"Null window but not chrome!");
|
||||
GetInfoForChrome(aGroup, aASCIIOrigin, aPrivilege, aDefaultPersistenceType);
|
||||
return NS_OK;
|
||||
}
|
||||
NS_ASSERTION(aWindow, "Don't hand me a null window!");
|
||||
|
||||
nsCOMPtr<nsIScriptObjectPrincipal> sop = do_QueryInterface(aWindow);
|
||||
NS_ENSURE_TRUE(sop, NS_ERROR_FAILURE);
|
||||
|
@ -2184,6 +2157,31 @@ QuotaManager::GetInfoFromWindow(nsPIDOMWindow* aWindow,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// static
|
||||
void
|
||||
QuotaManager::GetInfoForChrome(nsACString* aGroup,
|
||||
nsACString* aASCIIOrigin,
|
||||
StoragePrivilege* aPrivilege,
|
||||
PersistenceType* aDefaultPersistenceType)
|
||||
{
|
||||
NS_ASSERTION(nsContentUtils::IsCallerChrome(), "Only for chrome!");
|
||||
|
||||
static const char kChromeOrigin[] = "chrome";
|
||||
|
||||
if (aGroup) {
|
||||
aGroup->AssignLiteral(kChromeOrigin);
|
||||
}
|
||||
if (aASCIIOrigin) {
|
||||
aASCIIOrigin->AssignLiteral(kChromeOrigin);
|
||||
}
|
||||
if (aPrivilege) {
|
||||
*aPrivilege = Chrome;
|
||||
}
|
||||
if (aDefaultPersistenceType) {
|
||||
*aDefaultPersistenceType = PERSISTENCE_TYPE_PERSISTENT;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS2(QuotaManager, nsIQuotaManager, nsIObserver)
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -314,6 +314,12 @@ public:
|
|||
StoragePrivilege* aPrivilege,
|
||||
PersistenceType* aDefaultPersistenceType);
|
||||
|
||||
static void
|
||||
GetInfoForChrome(nsACString* aGroup,
|
||||
nsACString* aASCIIOrigin,
|
||||
StoragePrivilege* aPrivilege,
|
||||
PersistenceType* aDefaultPersistenceType);
|
||||
|
||||
static void
|
||||
GetOriginPatternString(uint32_t aAppId, bool aBrowserOnly,
|
||||
const nsACString& aOrigin, nsAutoCString& _retval)
|
||||
|
|
Загрузка…
Ссылка в новой задаче