Bug 1789959: Gracefully handle mCachedFields being null in xpcAccessible::GetCache. r=nlapre

Otherwise, we crash when inspecting RemoteAccessible objects in Dev Tools if the cache is disabled or hasn't been received yet.

Differential Revision: https://phabricator.services.mozilla.com/D161872
This commit is contained in:
James Teh 2022-11-14 23:29:07 +00:00
Родитель 8d586270bc
Коммит f520d4fa05
1 изменённых файлов: 10 добавлений и 11 удалений

Просмотреть файл

@ -376,19 +376,18 @@ xpcAccessible::GetCache(nsIPersistentProperties** aCachedFields) {
}
RefPtr<nsPersistentProperties> props = new nsPersistentProperties();
if (IntlGeneric()->IsRemote()) {
RefPtr<AccAttributes> cachedFields =
IntlGeneric()->AsRemote()->mCachedFields;
if (RemoteAccessible* remoteAcc = IntlGeneric()->AsRemote()) {
if (RefPtr<AccAttributes> cachedFields = remoteAcc->mCachedFields) {
nsAutoString unused;
for (auto iter : *cachedFields) {
nsAutoString name;
iter.NameAsString(name);
nsAutoString unused;
for (auto iter : *cachedFields) {
nsAutoString name;
iter.NameAsString(name);
nsAutoString value;
iter.ValueAsString(value);
nsAutoString value;
iter.ValueAsString(value);
props->SetStringProperty(NS_ConvertUTF16toUTF8(name), value, unused);
props->SetStringProperty(NS_ConvertUTF16toUTF8(name), value, unused);
}
}
}