Skip to content

Commit

Permalink
Fix dialog closewatcher crash
Browse files Browse the repository at this point in the history
See the bug for details, but it's possible (and ok) to already
have a closewatcher in showModal().

I also found a test that wasn't being run, due to an error in a
prior migration.

Fixed: 384549097
Change-Id: I4f32e782a01cda79c63088b9bbf8ea41e158703e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6153855
Auto-Submit: Mason Freed <masonf@chromium.org>
Reviewed-by: Joey Arhar <jarhar@chromium.org>
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1403636}
  • Loading branch information
mfreed7 authored and chromium-wpt-export-bot committed Jan 8, 2025
1 parent 3fdd928 commit fed5fd6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>

<!-- This test passes if it does not crash. -->

<dl>
<dt contenteditable></dt>
<dialog open></dialog>
</dl>

<script>
const dialog = document.querySelector('dialog');
dialog.open = false;
document.querySelector('dl').addEventListener("focusin", () => {
dialog.showModal();
});
document.defaultView.requestIdleCallback(() => {
window.getSelection().addRange(document.createRange());
dialog.close();
});
</script>
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<!DOCTYPE html>

<!-- This test passes if it does not crash. -->

<iframe id="frame"></iframe>
<script>
async_test(function(t) {
onload = t.step_func(() => {
const host = document.createElement("div");
frame.appendChild(host);
frame.contentDocument.body.innerHTML = "<dialog></dialog>";
document.body.offsetTop;
const root = host.attachShadow({mode: 'open'});
root.innerHTML = "<content>";
const dialog = frame.contentDocument.querySelector("dialog");
dialog.showModal();
t.done();
});
}, "Dialog.showModal() called when we have a dirty shadow distribution should not crash.");
window.onload = () => {
const host = document.createElement("div");
frame.appendChild(host);
frame.contentDocument.body.innerHTML = "<dialog></dialog>";
document.body.offsetTop;
const root = host.attachShadow({mode: 'open'});
root.innerHTML = "<content>";
const dialog = frame.contentDocument.querySelector("dialog");
dialog.showModal();
};
</script>

0 comments on commit fed5fd6

Please sign in to comment.