Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 2 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /html/semantics/popovers/popover-minimum-role.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8" />
<title>Popover minimum role</title>
<link rel="author" href="mailto:masonf@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/popover-utils.js"></script>
<div popover id=popover>Popover</div>
<div id=div style="display:block">Div</div>
<script>
test((t) => {
const popover = document.querySelector('#popover');
assert_equals(popover.computedRole,'generic','Closed popover: role is generic');
t.add_cleanup(() => popover.hidePopover());
popover.showPopover();
assert_equals(popover.computedRole,'group','With popover attribute, role is group');
},'If specified on an element with an implicit role of generic, then the element\'s role instead maps to group.');
test((t) => {
const div = document.querySelector('#div');
assert_equals(div.computedRole,'generic','Without popover attribute, role is generic');
div.setAttribute('popover','');
assert_true(isElementVisible(div),'element is visible due to display:block');
assert_equals(div.computedRole,'generic','With popover attribute, but before showPopover(), role is still generic');
t.add_cleanup(() => div.hidePopover());
div.showPopover();
assert_equals(div.computedRole,'group','When showing as a popover, role is group');
div.removeAttribute('style');
assert_equals(div.computedRole,'group','Including with style rule removed');
},'Dynamic changes to popover attribute should change the role.');
</script>