1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
|
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<style>
* {
font-size: 20px;
}
</style>
</head>
<body>
<!-- This behavior is not explicitly specified. -->
<input type=checkbox id=cb1 checked> <label for=cb1>ghi</label>
<input type=radio id=r1 checked> <label for=r1>jkl</label>
<label id=lc>abc <input type=checkbox id=cb2 checked></label>
<label id=lr>def <input type=radio id=r2 checked></label>
<script>
promise_test(async () => {
await new Promise(resolve => {
addEventListener("load", resolve, { once: true });
});
}, "Wait for load");
const tabKey = "\uE004";
promise_test(async t => {
const checkbox = document.querySelector("input[type=checkbox]");
// pointerdown on the checkbox
await (new test_driver.Actions()
.pointerMove(2, 2, { origin: checkbox })
.pointerDown())
.send();
t.add_cleanup(async () => {
// Release the pointer
await (new test_driver.Actions().pointerUp()).send();
});
assert_equals(document.querySelector("input:active"), checkbox,
"Checkboxes should be :active while it is pressed");
// Press tab
await (new test_driver.Actions().keyDown(tabKey).keyUp(tabKey)).send();
assert_equals(document.querySelector(":active"), null,
"Checkboxes should not be :active after tab is used to change focus.");
}, "Checkboxes should clear :active when the user tabs away from them while pressing it with a pointing device");
promise_test(async t => {
const radio = document.querySelector("input[type=radio]");
// pointerdown on the radio
await (new test_driver.Actions()
.pointerMove(2, 2, { origin: radio })
.pointerDown())
.send();
t.add_cleanup(async () => {
// Release the pointer
await (new test_driver.Actions().pointerUp()).send();
});
assert_equals(document.querySelector("input:active"), radio,
"Radios should be :active while it is pressed");
// Press tab
await (new test_driver.Actions().keyDown(tabKey).keyUp(tabKey)).send();
assert_equals(document.querySelector(":active"), null,
"Radios should not be :active after tab is used to change focus.");
}, "Radios should clear :active when the user tabs away from them while pressing it with a pointing device");
promise_test(async t => {
const checkbox = document.querySelector("label > input[type=checkbox]");
const label = checkbox.parentElement;
// pointerdown on the label
await (new test_driver.Actions()
.pointerMove(2, 2, { origin: label })
.pointerDown())
.send();
t.add_cleanup(async () => {
// Release the pointer
await (new test_driver.Actions().pointerUp()).send();
});
assert_equals(document.querySelector("input:active"), checkbox,
"Checkboxes should be :active while the label is pressed");
// Press tab
await (new test_driver.Actions().keyDown(tabKey).keyUp(tabKey)).send();
assert_equals(document.querySelector(":active"), null,
"Checkboxes should not be :active after tab is used to change focus.");
}, "Checkboxes should clear :active when the user tabs away from them while pressing the parent label with a pointing device");
promise_test(async t => {
const radio = document.querySelector("label > input[type=radio]");
const label = radio.parentElement;
const radioRect = radio.getBoundingClientRect();
const labelRect = label.getBoundingClientRect();
// pointerdown on the label
await (new test_driver.Actions()
.pointerMove(2, 2, { origin: label })
.pointerDown())
.send();
t.add_cleanup(async () => {
// Release the pointer
await (new test_driver.Actions().pointerUp()).send();
});
assert_equals(document.querySelector("input:active"), radio,
"Radios should be :active while the label is pressed");
// Press tab
await (new test_driver.Actions().keyDown(tabKey).keyUp(tabKey)).send();
assert_equals(document.querySelector(":active"), null,
"Radios should not be :active after tab is used to change focus.");
}, "Radios should clear :active when the user tabs away from them while pressing the parent label with a pointing device");
promise_test(async t => {
const label = document.querySelector("label[for=cb1]");
// pointerdown on the label
await (new test_driver.Actions()
.pointerMove(2, 2, { origin: label })
.pointerDown())
.send();
t.add_cleanup(async () => {
// Release the pointer
await (new test_driver.Actions().pointerUp()).send();
});
assert_equals(document.querySelector("input:active"), label.control,
"Checkboxes should be :active while the label is pressed");
// Press tab
await (new test_driver.Actions().keyDown(tabKey).keyUp(tabKey)).send();
assert_equals(document.querySelector(":active"), null,
"Checkboxes should not be :active after tab is used to change focus.");
}, "Checkboxes should clear :active when the user tabs away from them while pressing the following label with a pointing device");
promise_test(async t => {
const label = document.querySelector("label[for=r1]");
// pointerdown on the label
await (new test_driver.Actions()
.pointerMove(2, 2, { origin: label })
.pointerDown())
.send();
t.add_cleanup(async () => {
// Release the pointer
await (new test_driver.Actions().pointerUp()).send();
});
assert_equals(document.querySelector("input:active"), label.control,
"Radios should be :active while the label is pressed");
// Press tab
await (new test_driver.Actions().keyDown(tabKey).keyUp(tabKey)).send();
assert_equals(document.querySelector(":active"), null,
"Radios should not be :active after tab is used to change focus.");
}, "Radios should clear :active when the user tabs away from them while pressing the following label with a pointing device");
</script>
</body>
</html>
|