Skip to content

Commit

Permalink
Bug 1837083 [wpt PR 40404] - Fix dialog modal check in Close(), a=tes…
Browse files Browse the repository at this point in the history
…tonly

Automatic update from web-platform-tests
Fix dialog modal check in Close()

is_modal_ was being checked after the call to SetIsModal(false). This
patch caches the value of is_modal_ so that the subsequent modal check
actually works as intended.

This was pointed out here:
whatwg/html#9178 (comment)

HTML spec PR: whatwg/html#9178

Change-Id: Ic1bd87f9843bce7016ff672dd73fcc616e41a85c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4596156
Reviewed-by: Di Zhang <[email protected]>
Commit-Queue: Joey Arhar <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1159722}

--

wpt-commits: 2f6058492b28367114a9195b97d1e58d8d96fae9
wpt-pr: 40404
  • Loading branch information
josepharhar authored and moz-wptsync-bot committed Jun 28, 2023
1 parent 60e47e9 commit 7aed2d8
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
<button id=host2button>button</button>
</div>

<dialog id=mydialog2>hello world</dialog>

<script>
polyfill_declarative_shadow_dom(document);

Expand Down Expand Up @@ -68,4 +70,16 @@
dialog.close();
assert_equals(document.activeElement, b2);
}, 'Focus restore should occur when the focused element is slotted into a dialog.');

test(() => {
b1.focus();
const dialog = document.getElementById('mydialog2');
dialog.showModal();
dialog.blur();
assert_equals(document.activeElement, document.body,
'Focus should return to the body when calling dialog.blur().');
dialog.close();
assert_equals(document.activeElement, b1,
'Focus should be restored to the previously focused element.');
}, 'Focus restore should always occur for modal dialogs.');
</script>

0 comments on commit 7aed2d8

Please sign in to comment.