mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-04 23:30:20 +00:00
LibWeb: Add window.internals.getComputedRole(element)
This change adds a window.internals.getComputedLabel(element) function, for use in testing ARIA-related behavior. It also patches the imported WPT testdriver.js script’s test_driver.get_computed_role(element) function to call our window.internals.getComputedRole(element) function.
This commit is contained in:
parent
d946d94e2d
commit
c5966bbdcb
Notes:
github-actions[bot]
2024-12-06 18:32:55 +00:00
Author: https://github.com/sideshowbarker
Commit: c5966bbdcb
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2779
Reviewed-by: https://github.com/tcl3 ✅
4 changed files with 15 additions and 1 deletions
|
@ -203,6 +203,14 @@ void Internals::expire_cookies_with_time_offset(WebIDL::LongLong seconds)
|
||||||
internals_page().client().page_did_expire_cookies_with_time_offset(AK::Duration::from_seconds(seconds));
|
internals_page().client().page_did_expire_cookies_with_time_offset(AK::Duration::from_seconds(seconds));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOLINTNEXTLINE(readability-convert-member-functions-to-static
|
||||||
|
String Internals::get_computed_role(DOM::Element& element)
|
||||||
|
{
|
||||||
|
if (auto role = element.role_or_default(); role.has_value())
|
||||||
|
return MUST(String::from_utf8(ARIA::role_name(role.value())));
|
||||||
|
return String {};
|
||||||
|
}
|
||||||
|
|
||||||
String Internals::get_computed_label(DOM::Element& element)
|
String Internals::get_computed_label(DOM::Element& element)
|
||||||
{
|
{
|
||||||
auto& active_document = internals_window().associated_document();
|
auto& active_document = internals_window().associated_document();
|
||||||
|
|
|
@ -48,6 +48,7 @@ public:
|
||||||
void enable_cookies_on_file_domains();
|
void enable_cookies_on_file_domains();
|
||||||
void expire_cookies_with_time_offset(WebIDL::LongLong seconds);
|
void expire_cookies_with_time_offset(WebIDL::LongLong seconds);
|
||||||
|
|
||||||
|
String get_computed_role(DOM::Element& element);
|
||||||
String get_computed_label(DOM::Element& element);
|
String get_computed_label(DOM::Element& element);
|
||||||
|
|
||||||
static u16 get_echo_server_port();
|
static u16 get_echo_server_port();
|
||||||
|
|
|
@ -38,6 +38,7 @@ interface Internals {
|
||||||
undefined enableCookiesOnFileDomains();
|
undefined enableCookiesOnFileDomains();
|
||||||
undefined expireCookiesWithTimeOffset(long long seconds);
|
undefined expireCookiesWithTimeOffset(long long seconds);
|
||||||
|
|
||||||
|
DOMString getComputedRole(Element element);
|
||||||
DOMString getComputedLabel(Element element);
|
DOMString getComputedLabel(Element element);
|
||||||
unsigned short getEchoServerPort();
|
unsigned short getEchoServerPort();
|
||||||
};
|
};
|
||||||
|
|
|
@ -250,7 +250,11 @@
|
||||||
* rejected in the cases the WebDriver command errors
|
* rejected in the cases the WebDriver command errors
|
||||||
*/
|
*/
|
||||||
get_computed_role: async function(element) {
|
get_computed_role: async function(element) {
|
||||||
let role = await window.test_driver_internal.get_computed_role(element);
|
// XXX: Ladybird-specific change: Upstream WPT calls
|
||||||
|
// window.test_driver_internal.get_computed_role(element) here,
|
||||||
|
// but we’ve changed that to our Ladybird-specific
|
||||||
|
// window.internals.getComputedRole(el).
|
||||||
|
let role = await window.internals.getComputedRole(element);
|
||||||
return role;
|
return role;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue