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/forms/the-select-element/customizable-select/select-button-behaviors.tentative.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<link rel=author href="mailto:jarhar@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<style>
select,::picker(select) {
appearance: base-select;
}
</style>
<form>
<select>
<button id=btninselect>button in select</button>
<option>option</option>
</select>
<button id=btninform>button in form</button>
</form>
<script>
const select = document.querySelector('select');
const btninselect = document.getElementById('btninselect');
const btninform = document.getElementById('btninform');
const form = document.querySelector('form');
promise_test(async () => {
assert_false(btninselect.matches(':default'),
'Button in select should not match :default.');
assert_true(btninform.matches(':default'),
'Button in form should match :default.');
let formWasSubmitted = false;
form.addEventListener('submit', event => {
event.preventDefault();
formWasSubmitted = true;
}, {once: true});
await test_driver.click(select);
assert_false(formWasSubmitted,
'Clicking the select button should not submit the form.');
await test_driver.click(btninform);
assert_true(formWasSubmitted,
'Clicking the button in the form should submit the form.');
}, 'Select button should not be the default form submit button.');
promise_test(async () => {
select.setAttribute('disabled', '');
assert_false(btninselect.matches(':disabled'));
}, 'Select button should not inherit :disabled from select.');
</script>