tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 04b98c0b40f63a06091f281414c58cc9ce7a2b7d
parent ff809e3dbdfbd97c8d8037227be412d06bbe0759
Author: Dominic Farolino <dom@chromium.org>
Date:   Wed,  3 Dec 2025 14:49:24 +0000

Bug 2003646 [wpt PR 56420] - Menu: Implement defaultchecked attribute, a=testonly

Automatic update from web-platform-tests
Menu: Implement defaultchecked attribute

This CL implements the defaultchecked content attribute and
defaultChecked IDL attribute that reflects it. It also adds tests.

The defaultchecked attribute follows the input element's default
semantics, in that changes to the `defaultchecked` attribute (either by
direct mutation, or through the reflecting IDL attribute) can change the
checkedness of the element up until the first *non-default* change to
checkedness is made, in which case the "dirtyness" is set.

R=masonf

Bug: 406566432
Change-Id: I58e3e18c07dd1c7d11a7084545dec2a15f496a4d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7188670
Commit-Queue: Dominic Farolino <dom@chromium.org>
Reviewed-by: Mason Freed <masonf@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1552832}

--

wpt-commits: f94f283df901bb56b795d72c81f26ae130576ba5
wpt-pr: 56420

Diffstat:
Mtesting/web-platform/tests/html/semantics/menu/tentative/checkable.html | 55++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 54 insertions(+), 1 deletion(-)

diff --git a/testing/web-platform/tests/html/semantics/menu/tentative/checkable.html b/testing/web-platform/tests/html/semantics/menu/tentative/checkable.html @@ -26,6 +26,9 @@ <menuitem id=multiple2></menuitem> <menuitem id=multiple3></menuitem> </fieldset> + <fieldset checkable=multiple> + <menuitem defaultchecked id=defaultCheckedItem>Default checked</menuitem> + </fieldset> </menulist> <script> @@ -185,7 +188,7 @@ test(() => { single1.checked = true; assert_true(single1.checked, true); fieldset.removeAttribute('checkable'); - assert_false(single1.checked, false, + assert_false(single1.checked, "menuitem gets unchecked after fieldset becomes uncheckable"); single1.checked = true; assert_false(single1.checked, @@ -206,4 +209,54 @@ test(() => { assert_false(single2.checked, "second menuitem becomes unchecked"); }, "fieldset multiple => single; all but the first checked menuitem gets " + "reset"); + +// Testing the `defaultchecked` content attribute and `defaultChecked` IDL +// attribute. +test(() => { + assert_true(defaultCheckedItem.checked, + "defaultchecked makes the menu item checked by default"); + assert_true(defaultCheckedItem.matches(":default"), + ":default matches when the defaultchecked attribute is present"); + + // Unset the default while checkedness is still clean. + defaultCheckedItem.removeAttribute('defaultchecked'); + assert_false(defaultCheckedItem.defaultChecked, + "defaultChecked IDL attribute reflects the content attribute"); + assert_false(defaultCheckedItem.checked, + "Unsetting defaultchecked when checkedness is clean unchecks the item"); + assert_false(defaultCheckedItem.matches(":default"), + ":default does not match when defaultchecked attribute is missing or false (1/2)"); + + // Toggle it again while checkedness is clean, but this time with the IDL + // attribute, which should reflect the content attribute. + defaultCheckedItem.defaultChecked = true; + assert_true(defaultCheckedItem.checked, + "Setting defaultChecked to true when checkedness is clean checks the item"); + assert_true(defaultCheckedItem.matches(":default"), + ":default matches when the defaultchecked attribute is set, even via IDL"); + + // Unset checkedness, dirtying the default checkedness. + defaultCheckedItem.checked = false; + assert_true(defaultCheckedItem.defaultChecked, + "Default checkedness is still true"); + assert_false(defaultCheckedItem.checked, "checked becomes false"); + assert_true(defaultCheckedItem.matches(":default"), + "still matches the default checkedness"); + + // Unset default checkedness. This will only have the effect of changing the + // :default pseudo-class matching. + defaultCheckedItem.defaultChecked = false; + assert_false(defaultCheckedItem.matches(":default"), + ":default no longer matches"); + + // Set default checkedness back to true. Since the checkedness is now dirty, + // this won't change the actual checked state anymore, as the menu item has + // had its default checkedness overridden. + defaultCheckedItem.defaultChecked = true; + assert_false(defaultCheckedItem.checked, + "checked state is no longer dictated by default checkedness any"); + assert_true(defaultCheckedItem.matches(":default"), + ":default matches again, following the default checkedness, even " + + "though the checkedness is dirty"); +}, "Default checkedness and checkedness dirtying are wired up correctly"); </script>