Skip to content

Commit

Permalink
WebLocks: Remove invalid DCHECK and add some comments.
Browse files Browse the repository at this point in the history
It is possible for a ExecutionContext to be destroyed, and all its locks
to be released while the lock is still being set up. Remove a DCHECK
that tried to verify that this didn't happen. All the relevant code
should work correctly even if Lock::handle_ does become unbound.

If the handle_ gets unbound because the ExecutionContext is destroyed
Lock might not signal LockManager that it is no longer held and thus can
be destroyed, but that is okay, as LockManager itself will clear out all
references to Lock objects when the ExecutionContext is destroyed
anyway.

Bug: 1190515
Change-Id: Idbb6014cbd7f18257fdf3f7a2dffa7f7aeae75c7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2783622
Reviewed-by: Joshua Bell <jsbell@chromium.org>
Commit-Queue: Marijn Kruisselbrink <mek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#868622}
  • Loading branch information
mkruisselbrink authored and chromium-wpt-export-bot committed Apr 1, 2021
1 parent 9a53c90 commit 1e1b2de
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions web-locks/frames.tentative.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -243,4 +243,23 @@

}, 'Removed Frame with pending request');

promise_test(async t => {
assert_implements(navigator.locks);
const res = uniqueName(t);

const frame = await iframe('about:blank');

// Remove a frame while it is in the process of requesting a lock.
// The promise returned by `request` will never resolve since its frame no
// longer exists, but the lock should still be released.
await new Promise(resolve => {
frame.contentWindow.navigator.locks.request(res, () => {
frame.remove();
resolve();
});
});

assert_false((await navigator.locks.query()).held.includes(res));
}, 'Removed Frame as lock is granted');

</script>

0 comments on commit 1e1b2de

Please sign in to comment.