8000 script(webdriver): Check if element is disabled based on WebDriver specification by PotatoCP · Pull Request #38490 · servo/servo · GitHub
[go: up one dir, main page]

Skip to content

Conversation

PotatoCP
Copy link
Contributor
@PotatoCP PotatoCP commented Aug 6, 2025

Checking if an element is disabled based on spec. Fix the command Is Element Enabled.

Testing: Covered in WPT (./tests/wpt/tests/webdriver/tests/classic/is_element_enabled/enabled.py)

@PotatoCP PotatoCP requested a review from gterzian as a code owner August 6, 2025 05:43
expected: FAIL

[test_optgroup_with_select[disabled\]]
[test_option_with_optgroup[disabled\]]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

optgroup has not been check in is_actually_disabled()

// TODO:
// an optgroup element that has a disabled attribute
// a menuitem element that has a disabled attribute
// a fieldset element that is a disabled fieldset

@PotatoCP PotatoCP force-pushed the wd-implement-disabled branch from 2e1ebef to c47c6c6 Compare August 6, 2025 07:20
Signed-off-by: PotatoCP <Kenzie.Raditya.Tirtarahardja@huawei.com>
@PotatoCP PotatoCP force-pushed the wd-implement-disabled branch from c47c6c6 to 079e2a2 Compare August 6, 2025 07:35
@yezhizhen yezhizhen self-requested a review August 7, 2025 06:09
Copy link
Member
@yezhizhen yezhizhen left a comment

Choose a reason for hiding this comment

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

Can you also add doc for fn handle_is_enabled?

Comment on lines +116 to +122
// Step 1.2
// The spec suggests that we immediately return false if the above is not true.
// However, it causes disabled option element to not be considered as disabled.
// Hence, here we also check if the element itself is actually disabled.
if disabled {
return true;
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Step 1.2
// The spec suggests that we immediately return false if the above is not true.
// However, it causes disabled option element to not be considered as disabled.
// Hence, here we also check if the element itself is actually disabled.
if disabled {
return true;
}
return disabled;

If it is option element, then we won't enter step 1 in the first place. It exposes other problems. Just follow the spec.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

actually steps 1 include option element https://w3c.github.io/webdriver/#dfn-disabled

  1. If element is an option element or element is an optgroup element:

1.1. For each inclusive ancestor ancestor of element:

1.1.1. If ancestor is an optgroup element or ancestor is a select element, and ancestor is actually disabled, return true.

1.2. Return false.

You can see that if it's an option it will go to steps 1.1, but in steps 1.1.1. it will only check optgroup and select.

Copy link
Member

Choose a reason for hiding this comment

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

So you mean the spec has some problem here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think yes

Copy link
Member

Choose a reason for hiding this comment

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

Can you file a spec issue for this?

Copy link
Contributor Author
@PotatoCP PotatoCP Aug 11, 2025

Choose a reason for hiding this comment

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

Can you file a spec issue for this?

I've opened w3c/webdriver#1917

Signed-off-by: PotatoCP <Kenzie.Raditya.Tirtarahardja@huawei.com>
Signed-off-by: PotatoCP <Kenzie.Raditya.Tirtarahardja@huawei.com>
Signed-off-by: PotatoCP <Kenzie.Raditya.Tirtarahardja@huawei.com>
Copy link
Member
@yezhizhen yezhizhen left a comment

Choose a reason for hiding this comment

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

LGTM. But there were two marked resolved but not changed.

Signed-off-by: PotatoCP <Kenzie.Raditya.Tirtarahardja@huawei.com>
Copy link
Member
@yezhizhen yezhizhen left a comment

Choose a reason for hiding this comment

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

@xiaochengh This is ready to merge.

Copy link
Member
@jdm jdm left a comment

Choose a reason for hiding this comment

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

Thanks for reviewing, @yezhizhen!

@jdm jdm added this pull request to the merge queue Aug 11, 2025< 6D4F /a>
@PotatoCP PotatoCP deleted the wd-implement-disabled branch August 11, 2025 06:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0