Skip to content

Fix dialog requestClose() to handle edge case #10983

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

lukewarlow
Copy link
Member

@lukewarlow lukewarlow commented Feb 2, 2025

Fix dialog requestClose() to handle edge case

Dialog requestClose() now directly calls close the dialog if dialog's close watcher is null.

This replaces a previous assert that's wrong.

(See WHATWG Working Mode: Changes for more details.)


/interactive-elements.html ( diff )

@lukewarlow lukewarlow marked this pull request as ready for review February 2, 2025 23:53
@lukewarlow lukewarlow force-pushed the fix-dialog-requestclose branch from 67f78ff to bc0f5ec Compare February 2, 2025 23:56
Copy link
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is more temporary patches since we haven't fixed the asymmetry between setting open and calling show().

@mfreed7 PTAL?

@lukewarlow
Copy link
Member Author

I guess this is more temporary patches since we haven't fixed the asymmetry between setting open and calling show().

Yeah idk what the end result we want is, perhaps we can change this to an assert in future and make sure close watcher is created when open is added but for now this seems like the minimal fix to prevent a crash.

I think it's potentially worth a discussion at whatnot about what we envisage the end state to be for the open attribute because it causes many an issue so it might be worth spending time fully fixing it up.

Dialog requestClose() now directly calls close the dialog if dialog's close watcher is null.

This replaces a previous assert that's wrong.
@lukewarlow lukewarlow force-pushed the fix-dialog-requestclose branch from bc0f5ec to e2f7801 Compare February 3, 2025 12:20
@mfreed7
Copy link
Contributor

mfreed7 commented Feb 7, 2025

So I just put up a patch in Chromium to fix (I think all?) of these crasher/assert cases. Instead of relaxing the asserts, it adds attribute change steps for open that construct the close watcher and add the dialog to the open dialogs list when the open attribute is added to the <dialog>. WDYT about that approach, instead of the one in this PR?

@lukewarlow
Copy link
Member Author

lukewarlow commented Feb 7, 2025

Provided there's no unexpected behaviour (such as the dialog being added to the list (set in chrome so might not be noticed) twice when calling show() and showModal()) I think that's preferable. Would solve the initially open case too.

For the sake of completeness I think it should match :open too. I know that's not a spec concern but it would be good to add a WPT to ensure it's synced to the attribute correctly. (Likewise when removing the open attribute)

@mfreed7
Copy link
Contributor

mfreed7 commented Feb 10, 2025

Provided there's no unexpected behaviour (such as the dialog being added to the list (set in chrome so might not be noticed) twice when calling show() and showModal()) I think that's preferable. Would solve the initially open case too.

I added (back) DCHECKs everywhere I'm modifying the dialog list, to make sure it's being managed correctly. All existing tests pass, so I think this approach is looking good. Would you be interested in tweaking this PR (or #10954) accordingly? I can too, I'm just kind of swamped so it might take me some time.

For the sake of completeness I think it should match :open too. I know that's not a spec concern but it would be good to add a WPT to ensure it's synced to the attribute correctly. (Likewise when removing the open attribute)

I'll add :open checks to the appropriate tests.

@lukewarlow
Copy link
Member Author

I'll close this PR and update the other one to include all the proposed changes.

@lukewarlow lukewarlow closed this Feb 10, 2025
aarongable pushed a commit to chromium/chromium that referenced this pull request Feb 19, 2025
See this request:

whatwg/html#10983 (comment)

plus this comment:

https://chromium-review.googlesource.com/c/chromium/src/+/6245064/comments/e932d31a_c996d18e

This just adds more testing of dialog closedby and requestClose, to
make sure close watchers are still set up, the `:open` pseudo class
works properly, events get fired correctly, etc., when the dialog
`open` attribute is manually added and removed.

Bug: 376516550
Change-Id: Ibdee09c5f722db2ce97c64c38c39726c1503e1d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6253798
Auto-Submit: Mason Freed <[email protected]>
Commit-Queue: Mason Freed <[email protected]>
Reviewed-by: Joey Arhar <[email protected]>
Reviewed-by: Luke <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1422074}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Feb 19, 2025
See this request:

whatwg/html#10983 (comment)

plus this comment:

https://chromium-review.googlesource.com/c/chromium/src/+/6245064/comments/e932d31a_c996d18e

This just adds more testing of dialog closedby and requestClose, to
make sure close watchers are still set up, the `:open` pseudo class
works properly, events get fired correctly, etc., when the dialog
`open` attribute is manually added and removed.

Bug: 376516550
Change-Id: Ibdee09c5f722db2ce97c64c38c39726c1503e1d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6253798
Auto-Submit: Mason Freed <[email protected]>
Commit-Queue: Mason Freed <[email protected]>
Reviewed-by: Joey Arhar <[email protected]>
Reviewed-by: Luke <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1422074}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Feb 19, 2025
See this request:

whatwg/html#10983 (comment)

plus this comment:

https://chromium-review.googlesource.com/c/chromium/src/+/6245064/comments/e932d31a_c996d18e

This just adds more testing of dialog closedby and requestClose, to
make sure close watchers are still set up, the `:open` pseudo class
works properly, events get fired correctly, etc., when the dialog
`open` attribute is manually added and removed.

Bug: 376516550
Change-Id: Ibdee09c5f722db2ce97c64c38c39726c1503e1d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6253798
Auto-Submit: Mason Freed <[email protected]>
Commit-Queue: Mason Freed <[email protected]>
Reviewed-by: Joey Arhar <[email protected]>
Reviewed-by: Luke <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1422074}
i3roly pushed a commit to i3roly/firefox-dynasty that referenced this pull request Feb 26, 2025
…estClose, a=testonly

Automatic update from web-platform-tests
Improve testing dialog closedby and requestClose

See this request:

whatwg/html#10983 (comment)

plus this comment:

https://chromium-review.googlesource.com/c/chromium/src/+/6245064/comments/e932d31a_c996d18e

This just adds more testing of dialog closedby and requestClose, to
make sure close watchers are still set up, the `:open` pseudo class
works properly, events get fired correctly, etc., when the dialog
`open` attribute is manually added and removed.

Bug: 376516550
Change-Id: Ibdee09c5f722db2ce97c64c38c39726c1503e1d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6253798
Auto-Submit: Mason Freed <[email protected]>
Commit-Queue: Mason Freed <[email protected]>
Reviewed-by: Joey Arhar <[email protected]>
Reviewed-by: Luke <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1422074}

--

wpt-commits: 57d6088fe0481e9662763d2147831219e692d3bc
wpt-pr: 50808
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Feb 27, 2025
…estClose, a=testonly

Automatic update from web-platform-tests
Improve testing dialog closedby and requestClose

See this request:

whatwg/html#10983 (comment)

plus this comment:

https://chromium-review.googlesource.com/c/chromium/src/+/6245064/comments/e932d31a_c996d18e

This just adds more testing of dialog closedby and requestClose, to
make sure close watchers are still set up, the `:open` pseudo class
works properly, events get fired correctly, etc., when the dialog
`open` attribute is manually added and removed.

Bug: 376516550
Change-Id: Ibdee09c5f722db2ce97c64c38c39726c1503e1d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6253798
Auto-Submit: Mason Freed <[email protected]>
Commit-Queue: Mason Freed <[email protected]>
Reviewed-by: Joey Arhar <[email protected]>
Reviewed-by: Luke <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1422074}

--

wpt-commits: 57d6088fe0481e9662763d2147831219e692d3bc
wpt-pr: 50808
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Mar 1, 2025
…estClose, a=testonly

Automatic update from web-platform-tests
Improve testing dialog closedby and requestClose

See this request:

whatwg/html#10983 (comment)

plus this comment:

https://chromium-review.googlesource.com/c/chromium/src/+/6245064/comments/e932d31a_c996d18e

This just adds more testing of dialog closedby and requestClose, to
make sure close watchers are still set up, the `:open` pseudo class
works properly, events get fired correctly, etc., when the dialog
`open` attribute is manually added and removed.

Bug: 376516550
Change-Id: Ibdee09c5f722db2ce97c64c38c39726c1503e1d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6253798
Auto-Submit: Mason Freed <masonfchromium.org>
Commit-Queue: Mason Freed <masonfchromium.org>
Reviewed-by: Joey Arhar <jarharchromium.org>
Reviewed-by: Luke <lwarlowigalia.com>
Cr-Commit-Position: refs/heads/main{#1422074}

--

wpt-commits: 57d6088fe0481e9662763d2147831219e692d3bc
wpt-pr: 50808

UltraBlame original commit: 9668c9902b5818811f24cb50228e71a8fa1ca08e
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Mar 1, 2025
…estClose, a=testonly

Automatic update from web-platform-tests
Improve testing dialog closedby and requestClose

See this request:

whatwg/html#10983 (comment)

plus this comment:

https://chromium-review.googlesource.com/c/chromium/src/+/6245064/comments/e932d31a_c996d18e

This just adds more testing of dialog closedby and requestClose, to
make sure close watchers are still set up, the `:open` pseudo class
works properly, events get fired correctly, etc., when the dialog
`open` attribute is manually added and removed.

Bug: 376516550
Change-Id: Ibdee09c5f722db2ce97c64c38c39726c1503e1d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6253798
Auto-Submit: Mason Freed <masonfchromium.org>
Commit-Queue: Mason Freed <masonfchromium.org>
Reviewed-by: Joey Arhar <jarharchromium.org>
Reviewed-by: Luke <lwarlowigalia.com>
Cr-Commit-Position: refs/heads/main{#1422074}

--

wpt-commits: 57d6088fe0481e9662763d2147831219e692d3bc
wpt-pr: 50808

UltraBlame original commit: 9668c9902b5818811f24cb50228e71a8fa1ca08e
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Mar 1, 2025
…estClose, a=testonly

Automatic update from web-platform-tests
Improve testing dialog closedby and requestClose

See this request:

whatwg/html#10983 (comment)

plus this comment:

https://chromium-review.googlesource.com/c/chromium/src/+/6245064/comments/e932d31a_c996d18e

This just adds more testing of dialog closedby and requestClose, to
make sure close watchers are still set up, the `:open` pseudo class
works properly, events get fired correctly, etc., when the dialog
`open` attribute is manually added and removed.

Bug: 376516550
Change-Id: Ibdee09c5f722db2ce97c64c38c39726c1503e1d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6253798
Auto-Submit: Mason Freed <masonfchromium.org>
Commit-Queue: Mason Freed <masonfchromium.org>
Reviewed-by: Joey Arhar <jarharchromium.org>
Reviewed-by: Luke <lwarlowigalia.com>
Cr-Commit-Position: refs/heads/main{#1422074}

--

wpt-commits: 57d6088fe0481e9662763d2147831219e692d3bc
wpt-pr: 50808

UltraBlame original commit: 9668c9902b5818811f24cb50228e71a8fa1ca08e
jamienicol pushed a commit to jamienicol/gecko that referenced this pull request Mar 5, 2025
…estClose, a=testonly

Automatic update from web-platform-tests
Improve testing dialog closedby and requestClose

See this request:

whatwg/html#10983 (comment)

plus this comment:

https://chromium-review.googlesource.com/c/chromium/src/+/6245064/comments/e932d31a_c996d18e

This just adds more testing of dialog closedby and requestClose, to
make sure close watchers are still set up, the `:open` pseudo class
works properly, events get fired correctly, etc., when the dialog
`open` attribute is manually added and removed.

Bug: 376516550
Change-Id: Ibdee09c5f722db2ce97c64c38c39726c1503e1d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6253798
Auto-Submit: Mason Freed <[email protected]>
Commit-Queue: Mason Freed <[email protected]>
Reviewed-by: Joey Arhar <[email protected]>
Reviewed-by: Luke <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1422074}

--

wpt-commits: 57d6088fe0481e9662763d2147831219e692d3bc
wpt-pr: 50808
glandium pushed a commit to mozilla-firefox/firefox that referenced this pull request Apr 1, 2025
…estClose, a=testonly

Automatic update from web-platform-tests
Improve testing dialog closedby and requestClose

See this request:

whatwg/html#10983 (comment)

plus this comment:

https://chromium-review.googlesource.com/c/chromium/src/+/6245064/comments/e932d31a_c996d18e

This just adds more testing of dialog closedby and requestClose, to
make sure close watchers are still set up, the `:open` pseudo class
works properly, events get fired correctly, etc., when the dialog
`open` attribute is manually added and removed.

Bug: 376516550
Change-Id: Ibdee09c5f722db2ce97c64c38c39726c1503e1d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6253798
Auto-Submit: Mason Freed <[email protected]>
Commit-Queue: Mason Freed <[email protected]>
Reviewed-by: Joey Arhar <[email protected]>
Reviewed-by: Luke <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1422074}

--

wpt-commits: 57d6088fe0481e9662763d2147831219e692d3bc
wpt-pr: 50808
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

3 participants