Skip to content

Commit

Permalink
Remove exception from requestClose
Browse files Browse the repository at this point in the history
See this conversation:

https://github.com/whatwg/html/pull/10737/files#r1873864137

There doesn't seem to be a reason to require `closedby` to be used
in order for `requestClose()` to work.

Bug: 376516550
Change-Id: I1d942ccafec9c30bad1bc6c4b3dfbb3f7782750b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6077771
Commit-Queue: David Baron <[email protected]>
Auto-Submit: Mason Freed <[email protected]>
Reviewed-by: David Baron <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1393736}
  • Loading branch information
mfreed7 authored and chromium-wpt-export-bot committed Dec 9, 2024
1 parent 73fd679 commit 9d05543
Showing 1 changed file with 11 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,8 @@
promise_test(async (t) => {
await setup(t,closedby);
openDialog(modal);
if (dialog.closedBy != "none") {
dialog.requestClose();
assert_false(dialog.open);
} else {
assert_throws_dom('InvalidStateError',() => dialog.requestClose());
assert_true(dialog.open);
}
dialog.requestClose();
assert_false(dialog.open);
},`requestClose basic behavior ${testDescription}`);

promise_test(async (t) => {
Expand All @@ -78,15 +73,11 @@
dialog.addEventListener('close',() => events.push('close'),{signal});
openDialog(modal);
assert_array_equals(events,[]);
if (dialog.closedBy != "none") {
dialog.requestClose();
assert_false(dialog.open);
assert_array_equals(events,['cancel'],'close is scheduled');
await new Promise(resolve => requestAnimationFrame(resolve));
assert_array_equals(events,['cancel','close']);
} else {
assert_throws_dom('InvalidStateError',() => dialog.requestClose());
}
dialog.requestClose();
assert_false(dialog.open);
assert_array_equals(events,['cancel'],'close is scheduled');
await new Promise(resolve => requestAnimationFrame(resolve));
assert_array_equals(events,['cancel','close']);
},`requestClose fires both cancel and close ${testDescription}`);

promise_test(async (t) => {
Expand All @@ -97,12 +88,8 @@
openDialog(modal);
dialog.setAttribute('closedby',closedby);
assert_array_equals(events,[]);
if (dialog.closedBy != "none") {
dialog.requestClose();
assert_false(dialog.open);
} else {
assert_throws_dom('InvalidStateError',() => dialog.requestClose());
}
dialog.requestClose();
assert_false(dialog.open);
},`changing closedby from 'none' to '${closedby}' for ${modal ? "modal" : "modeless"} dialog`);

promise_test(async (t) => {
Expand All @@ -113,12 +100,8 @@
openDialog(modal);
dialog.removeAttribute('closedby');
assert_array_equals(events,[]);
if (dialog.closedBy != "none") {
dialog.requestClose();
assert_false(dialog.open);
} else {
assert_throws_dom('InvalidStateError',() => dialog.requestClose());
}
dialog.requestClose();
assert_false(dialog.open);
},`Removing closedby when closedby='${closedby}' for ${modal ? "modal" : "modeless"} dialog`);

if (dialog.closedBy != "none") {
Expand Down

0 comments on commit 9d05543

Please sign in to comment.