Bug 1654803 - Fixing the crash issue in PermissionDelegateHandler::GetPermission(). r=baku

At very rare situations, we won't be able to get the top level window
context. Perhaps, it's the case that the window has been detached from
the dom tree while checking the permission. So, we need to check the top
level window context before we really use it.

Differential Revision: https://phabricator.services.mozilla.com/D85978
This commit is contained in:
Tim Huang 2020-08-12 07:53:35 +00:00
Родитель 8b5b04028f
Коммит aaf012c1e2
1 изменённых файлов: 2 добавлений и 2 удалений

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

@ -262,7 +262,7 @@ nsresult PermissionDelegateHandler::GetPermission(const nsACString& aType,
bc) {
RefPtr<WindowContext> topWC = bc->GetTopWindowContext();
if (topWC->IsInProcess()) {
if (topWC && topWC->IsInProcess()) {
// If the top-level window context is in the same process, we directly get
// the node principal from the top-level document to test the permission.
// We cannot check the lists in the window context in this case since the
@ -276,7 +276,7 @@ nsresult PermissionDelegateHandler::GetPermission(const nsACString& aType,
if (topDoc) {
principal = topDoc->NodePrincipal();
}
} else {
} else if (topWC) {
// Get the delegated permissions from the top-level window context.
DelegatedPermissionList list =
aExactHostMatch ? topWC->GetDelegatedExactHostMatchPermissions()