Bug 1741181 - NotifyRequestDestroy() only when the manager is alive r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D131535
This commit is contained in:
Kagami Sascha Rosylight 2021-11-22 22:30:34 +00:00
Родитель db1fb88e14
Коммит 220a38db00
3 изменённых файлов: 36 добавлений и 1 удалений

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

@ -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;

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

@ -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,

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

@ -0,0 +1,22 @@
<!DOCTYPE html>
<html class="test-wait">
<meta charset="utf-8">
<iframe id="id_0"></iframe>
<script>
/** @param {HTMLIFrameElement} iframe */
function waitForLoad(iframe) {
// iframe is initialized immediately on Chrome while it needs some time on Firefox
if (iframe.contentDocument.readyState === "complete") {
return;
}
return new Promise(r => iframe.onload = r);
}
const iframe = document.getElementById("id_0");
iframe.contentWindow.navigator.locks.request("weblock_0", async () => {
await waitForLoad(iframe);
document.body.append(iframe);
await waitForLoad(iframe);
document.documentElement.classList.remove("test-wait");
});
</script>