From 490bd934d05a3bc1d99c8ac58f3d01c465389dc9 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Fri, 27 May 2022 14:02:53 +0000 Subject: [PATCH] Bug 1771009 - Make TimeoutManager::SetTimeout no-op if window is dying r=smaug setTimeout is not affected since nsGlobalWindowInner::SetTimeout is not called at all when it's dying, but that's not the case with AbortSignal.timout, so we have to explicitly deal with such situation. Differential Revision: https://phabricator.services.mozilla.com/D147368 --- dom/base/TimeoutManager.cpp | 2 +- .../dom/abort/crashtests/timeout-close.html | 22 +++++++++++++++++++ testing/web-platform/tests/lint.ignore | 1 + 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 testing/web-platform/tests/dom/abort/crashtests/timeout-close.html diff --git a/dom/base/TimeoutManager.cpp b/dom/base/TimeoutManager.cpp index b5c261382a68..4ccf3fd86ad7 100644 --- a/dom/base/TimeoutManager.cpp +++ b/dom/base/TimeoutManager.cpp @@ -465,7 +465,7 @@ nsresult TimeoutManager::SetTimeout(TimeoutHandler* aHandler, int32_t interval, // If we don't have a document (we could have been unloaded since // the call to setTimeout was made), do nothing. nsCOMPtr doc = mWindow.GetExtantDoc(); - if (!doc) { + if (!doc || mWindow.IsDying()) { return NS_OK; } diff --git a/testing/web-platform/tests/dom/abort/crashtests/timeout-close.html b/testing/web-platform/tests/dom/abort/crashtests/timeout-close.html new file mode 100644 index 000000000000..ee8544a7f57e --- /dev/null +++ b/testing/web-platform/tests/dom/abort/crashtests/timeout-close.html @@ -0,0 +1,22 @@ + + + + + diff --git a/testing/web-platform/tests/lint.ignore b/testing/web-platform/tests/lint.ignore index 33aafc900aa9..c2804fa81b7f 100644 --- a/testing/web-platform/tests/lint.ignore +++ b/testing/web-platform/tests/lint.ignore @@ -341,6 +341,7 @@ SET TIMEOUT: speculation-rules/prerender/resources/prerender-response-code.html SET TIMEOUT: speculation-rules/prerender/resources/deferred-promise-utils.js SET TIMEOUT: speculation-rules/prerender/resources/utils.js SET TIMEOUT: html/browsers/browsing-the-web/back-forward-cache/timers.html +SET TIMEOUT: dom/abort/crashtests/timeout-close.html # setTimeout use in reftests SET TIMEOUT: acid/acid3/test.html