Bug 1660189 - Bail out from nsPrintJob::DoCommonPrint if the docshell was destroyed in beforeprint event handlers. r=dholbert

Differential Revision: https://phabricator.services.mozilla.com/D87827
This commit is contained in:
Hiroyuki Ikezoe 2020-08-21 04:58:49 +00:00
Родитель c57fa21220
Коммит c3e70abe26
1 изменённых файлов: 4 добавлений и 0 удалений

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

@ -183,6 +183,7 @@ static CallState CollectDocuments(Document& aDoc,
return CallState::Continue;
}
MOZ_CAN_RUN_SCRIPT
static void DispatchEventToWindowTree(Document& aDoc, const nsAString& aEvent) {
nsTArray<nsCOMPtr<Document>> targets;
CollectDocuments(aDoc, targets);
@ -655,6 +656,9 @@ nsresult nsPrintJob::DoCommonPrint(bool aIsPrintPreview,
// for print output. (Obviously if `aSourceDoc` is a clone, it already
// has these changes.)
DispatchEventToWindowTree(*aSourceDoc, u"beforeprint"_ns);
if (mIsDestroying) {
return NS_ERROR_FAILURE;
}
}
{