diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /layout/forms/test/test_select_key_navigation_bug961363.html | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | layout/forms/test/test_select_key_navigation_bug961363.html | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/layout/forms/test/test_select_key_navigation_bug961363.html b/layout/forms/test/test_select_key_navigation_bug961363.html new file mode 100644 index 0000000000..7815149778 --- /dev/null +++ b/layout/forms/test/test_select_key_navigation_bug961363.html @@ -0,0 +1,131 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=961363 +--> +<head> +<meta charset="utf-8"> +<title>Test for Bug 961363</title> +<script src="/tests/SimpleTest/SimpleTest.js"></script> +<script src="/tests/SimpleTest/EventUtils.js"></script> +<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> +<script type="application/javascript"> + /** Test for Bug 961363 **/ + + SimpleTest.waitForExplicitFinish(); + + function test() { + SimpleTest.waitForFocus(function() { + const single_list = [ + {key: "DOWN", change: true, state: [false, false, true, false]}, + {key: "UP", change: true, state: [false, true, false, false]}, + {key: "RIGHT", change: true, state: [false, false, true, false]}, + {key: "LEFT", change: true, state: [false, true, false, false]}, + {key: "END", change: true, state: [false, false, false, true ]}, + {key: "HOME", change: true, state: [true, false, false, false]}, + {key: "PAGE_DOWN", change: false, state: [true, false, false, false]}, + {key: "PAGE_UP", change: false, state: [true, false, false, false]} + ]; + + const single_dropdown = [ + {key: "DOWN", change: true, state: [false, false, true, false]}, + {key: "UP", change: true, state: [false, true, false, false]}, + {key: "RIGHT", change: true, state: [false, false, true, false]}, + {key: "LEFT", change: true, state: [false, true, false, false]}, + {key: "END", change: true, state: [false, false, false, true ]}, + {key: "HOME", change: true, state: [true, false, false, false]}, + {key: "PAGE_DOWN", change: false, state: [true, false, false, false]}, + {key: "PAGE_UP", change: false, state: [true, false, false, false]} + ]; + + const multiple = [ + {key: "DOWN", change: false, state: [false, true, true, false]}, + {key: "UP", change: false, state: [false, false, true, false]}, + {key: "RIGHT", change: false, state: [false, false, false, false]}, + {key: "LEFT", change: false, state: [false, true, false, false]}, + {key: "PAGE_DOWN", change: false, state: [false, true, false, true ]}, + {key: "PAGE_UP", change: false, state: [false, false, false, true ]}, + {key: "END", change: false, state: [false, false, false, false]}, + {key: "HOME", change: false, state: [true, false, false, false]} + ]; + + function select_test(id, tests) { + let element = document.getElementById(id); + element.focus(); + tests.forEach(data => { + let previousValue = element.value; + let key = data.k; + synthesizeKey("VK_" + data.key, {shiftKey: false, metaKey: false, + ctrlKey: true }); + (data.change ? isnot : is)( + element.value, previousValue, + `value should ${data.change ? "": "not "} have changed while testing CTRL+${data.key} (id: ${id})` + ); + + // Hit ctrl+space, but only for <select multiple> elements; doing so + // for single <select> elements will just trigger the dropdown to + // open. This is especially important because e10s-backed dropdowns + // behave differently: their .value isn't updated until the dropdown + // is closed (and the change confirmed), e.g. by pressing Enter. + let action; + if (element.multiple) { + synthesizeKey(" ", {shiftKey: false, metaKey: false, + ctrlKey: true}); + action = `CTRL+SPACE (after testing CTRL+${data.key})`; + } else { + action = `testing CTRL+${data.key}`; + } + + let selected = [...element.options].map(o => o.selected); + is(selected.toString(), data.state.toString(), + `selected options match after ${action} (id: ${id})`); + }); + } + + select_test("single-list", single_list); + if (!navigator.platform.includes("Mac")) { + select_test("single-dropdown", single_dropdown); + } else { + todo(false, "Make these tests work on OSX"); + } + + select_test("multiple", multiple); + SimpleTest.finish(); + }); + } +</script> +</head> +<body onload="test();"> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=961363">Mozilla Bug 961363</a> +<div> + <ul> + <li> + <select id="single-list" size="3"> + <option>0</option> + <option selected>1</option> + <option>2</option> + <option>3</option> + </select> + </li> + <li> + <select id="single-dropdown" size="1"> + <option>0</option> + <option selected>1</option> + <option>2</option> + <option>3</option> + </select> + </li> + <li> + <select id="multiple" multiple size="3"> + <option>0</option> + <option selected>1</option> + <option>2</option> + <option>3</option> + </select> + </li> + </ul> +</div> +<pre id="test"> +</pre> +</body> +</html> |