From 220a38db001fb47e3fd8295f3f8671014bf90b45 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Mon, 22 Nov 2021 22:30:34 +0000 Subject: [PATCH] Bug 1741181 - NotifyRequestDestroy() only when the manager is alive r=smaug Differential Revision: https://phabricator.services.mozilla.com/D131535 --- dom/base/Document.h | 9 ++++++++ dom/locks/LockRequestChild.cpp | 6 ++++- .../crashtests/iframe-append.https.html | 22 +++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 testing/web-platform/tests/web-locks/crashtests/iframe-append.https.html diff --git a/dom/base/Document.h b/dom/base/Document.h index b7361c51b966..9769c776749d 100644 --- a/dom/base/Document.h +++ b/dom/base/Document.h @@ -4859,6 +4859,15 @@ class Document : public nsINode, uint32_t mLazyLoadImageReachViewportLoaded; uint32_t mContentEditableCount; + /** + * Count of the number of active LockRequest objects, including ones from + * workers. Note that the value won't be updated while the document is being + * destroyed. + * + * TODO(krosylight): We may want to move this to window object instead, but + * it's not clear whether the spec relates locks to the window/agent or the + * document. See also https://github.com/WICG/web-locks/issues/95. + */ uint32_t mLockCount = 0; EditingState mEditingState; diff --git a/dom/locks/LockRequestChild.cpp b/dom/locks/LockRequestChild.cpp index 1d9996faf81c..14470acc44d8 100644 --- a/dom/locks/LockRequestChild.cpp +++ b/dom/locks/LockRequestChild.cpp @@ -54,7 +54,11 @@ LockRequestChild::LockRequestChild( } void LockRequestChild::ActorDestroy(ActorDestroyReason aReason) { - CastedManager()->NotifyRequestDestroy(); + if (aReason != ActorDestroyReason::AncestorDeletion) { + // Ping the manager if it's still alive, otherwise we don't have to as the + // document is being destroyed + CastedManager()->NotifyRequestDestroy(); + } } IPCResult LockRequestChild::RecvResolve(const LockMode& aLockMode, diff --git a/testing/web-platform/tests/web-locks/crashtests/iframe-append.https.html b/testing/web-platform/tests/web-locks/crashtests/iframe-append.https.html new file mode 100644 index 000000000000..be5d1b365c5c --- /dev/null +++ b/testing/web-platform/tests/web-locks/crashtests/iframe-append.https.html @@ -0,0 +1,22 @@ + + + + +