Bug 1580617 - Make nsDocShell::GetContentBlockingLog() reject its returned promise when there's no content viewer; r=baku

Differential Revision: https://phabricator.services.mozilla.com/D45587

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Ehsan Akhgari 2019-09-15 13:06:28 +00:00
parent 7389ffb35c
commit e8b78f99fc

View File

@ -3626,19 +3626,20 @@ NS_IMETHODIMP
nsDocShell::GetContentBlockingLog(Promise** aPromise) {
NS_ENSURE_ARG_POINTER(aPromise);
if (!mContentViewer) {
*aPromise = nullptr;
return NS_ERROR_FAILURE;
}
Document* doc = mContentViewer->GetDocument();
ErrorResult rv;
RefPtr<Promise> promise = Promise::Create(doc->GetOwnerGlobal(), rv);
if (NS_WARN_IF(rv.Failed())) {
return rv.StealNSResult();
}
promise->MaybeResolve(
NS_ConvertUTF8toUTF16(doc->GetContentBlockingLog()->Stringify()));
if (mContentViewer) {
promise->MaybeResolve(
NS_ConvertUTF8toUTF16(doc->GetContentBlockingLog()->Stringify()));
} else {
promise->MaybeRejectWithUndefined();
}
promise.forget(aPromise);
return NS_OK;
}