summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/forms/the-select-element/stylable-select/select-mouse-behavior.tentative.html
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/html/semantics/forms/the-select-element/stylable-select/select-mouse-behavior.tentative.html')
-rw-r--r--testing/web-platform/tests/html/semantics/forms/the-select-element/stylable-select/select-mouse-behavior.tentative.html62
1 files changed, 62 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/semantics/forms/the-select-element/stylable-select/select-mouse-behavior.tentative.html b/testing/web-platform/tests/html/semantics/forms/the-select-element/stylable-select/select-mouse-behavior.tentative.html
new file mode 100644
index 0000000000..aff976d1ad
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/forms/the-select-element/stylable-select/select-mouse-behavior.tentative.html
@@ -0,0 +1,62 @@
+<!DOCTYPE html>
+<link rel=author href="mailto:jarhar@chromium.org">
+<link rel=help href="https://bugs.chromium.org/p/chromium/issues/detail?id=1422275">
+<link rel=help href="https://github.com/openui/open-ui/issues/433#issuecomment-1452461404">
+<link rel=help href="https://github.com/openui/open-ui/issues/386#issuecomment-1452469497">
+<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>
+<script src="/resources/testdriver-actions.js"></script>
+
+<style>
+select {
+ appearance: base-select;
+}
+</style>
+
+<!-- TODO(http://crbug.com/1511354): Add test cases with no <button> and no <datalist>. -->
+<select>
+ <button type=popover>button</button>
+ <datalist>
+ <option class=one>one</option>
+ <option class=two>two</option>
+ </datalist>
+</select>
+
+<script>
+const select = document.querySelector('select');
+const button = document.querySelector('button');
+const optionOne = document.querySelector('option.one');
+const optionTwo = document.querySelector('option.two');
+
+promise_test(async () => {
+ assert_false(select.matches(':open'),
+ 'Select should be closed at the start of the test.');
+
+ await test_driver.click(button);
+ assert_true(select.matches(':open'),
+ 'Select should be open after clicking the button.');
+
+ await test_driver.click(button);
+ assert_false(select.matches(':open'),
+ 'Select should be closed after clicking the button a second time.');
+}, 'Select with appearance:base-select should open and close when clicking the button.');
+
+promise_test(async () => {
+ assert_false(select.matches(':open'),
+ 'Select should be closed at the start of the test.');
+ assert_equals(select.value, 'one',
+ 'Select.value should be one at the start of the test.');
+
+ await test_driver.click(button);
+ assert_true(select.matches(':open'),
+ 'Select should be open after clicking the button.');
+
+ await test_driver.click(optionTwo);
+ assert_false(select.matches(':open'),
+ 'Select should be closed after clicking an option.');
+ assert_equals(select.value, 'two',
+ 'Select.value should be two after clicking the option.');
+}, 'Clicking an option in an appearance:base-select select should choose the option and close the popover.');
+</script>