Commit 220a38db authored by Kagami Sascha Rosylight's avatar Kagami Sascha Rosylight
Browse files

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

parent db1fb88e
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -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;

+5 −1
Original line number Diff line number Diff line
@@ -54,8 +54,12 @@ LockRequestChild::LockRequestChild(
}

void LockRequestChild::ActorDestroy(ActorDestroyReason aReason) {
  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,
                                        bool aIsAvailable) {
+22 −0
Original line number Diff line number Diff line
<!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>