Commit 090cf338 authored by Kagami Sascha Rosylight's avatar Kagami Sascha Rosylight
Browse files

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
parent 396dfffa
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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<Document> doc = mWindow.GetExtantDoc();
  if (!doc) {
  if (!doc || mWindow.IsDying()) {
    return NS_OK;
  }

+15 −0
Original line number Diff line number Diff line
<!DOCTYPE html>
<html class="test-wait">
<meta charset="utf-8">
<script>
  const xhr = new XMLHttpRequest()
  setTimeout(() => {
    xhr.open('GET', '/', false)
    xhr.send()
    AbortSignal.timeout(41.62684667994843)
  }, 1)
  setTimeout(() => {
    location.href = "about:blank"
    document.documentElement.classList.remove("test-wait")
  }, 0)
</script>
+1 −0
Original line number Diff line number Diff line
@@ -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