Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that pointerUp Action is Being Issued on Element Being Tested #43214

Merged
merged 4 commits into from
Nov 30, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 60 additions & 25 deletions css/selectors/invalidation/user-action-pseudo-classes-in-has.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
</style>
<div id=subject1 class=ancestor>
<div>
<div id=unhoverme>No :hover</div>
<div id=hoverme class=descendant1>Hover and click me</div>
<div id=focusme1 tabindex=1>Focus me</div>
<div id=focusme2 class=descendant2 tabindex=2>Focus me</div>
Expand All @@ -37,47 +38,81 @@
</div>
<script>
const tab_key = '\ue004';
const hovermeRect = hoverme.getBoundingClientRect();
const focusme1Rect = focusme1.getBoundingClientRect();

promise_test(async () => {
assert_equals(getComputedStyle(subject1).color, "rgb(0, 0, 0)", "subject1 initially black");
assert_equals(getComputedStyle(subject2).color, "rgb(0, 0, 0)", "subject3 initially black");

await new test_driver
.Actions()
.pointerMove(hovermeRect.x + 1, hovermeRect.y + 1, {origin: "viewport"})
.send();
await new Promise(resolve => {
hoverme.addEventListener("mouseover", () => {
dshin-moz marked this conversation as resolved.
Show resolved Hide resolved
resolve();
}, {once: true});
new test_driver
.Actions()
.pointerMove(0, 0, {origin: hoverme})
.send();
});
assert_equals(getComputedStyle(subject1).color, "rgb(0, 0, 255)",
"subject1 should be blue");
assert_equals(getComputedStyle(subject3).color, "rgb(0, 0, 128)",
"subject3 should be navy");

await new test_driver
.Actions()
.pointerMove(hovermeRect.x + 1, hovermeRect.y + 1, {origin: "viewport"})
.pointerDown()
.send();
await new Promise(resolve => {
unhoverme.addEventListener("mouseover", () => {
resolve();
}, {once: true});
new test_driver
.Actions()
.pointerMove(0, 0, {origin: unhoverme})
.send();
});
assert_equals(getComputedStyle(subject1).color, "rgb(0, 0, 0)",
"subject1 should be back to black");
assert_equals(getComputedStyle(subject3).color, "rgb(0, 0, 0)",
"subject3 should be back to black");


await new Promise(resolve => {
hoverme.addEventListener("mousedown", () => {
resolve();
}, {once: true});
new test_driver
.Actions()
.pointerMove(0, 0, {origin: hoverme})
.pointerDown()
.send();
});
assert_equals(getComputedStyle(subject1).color, "rgb(135, 206, 235)",
"subject1 should be skyblue");
assert_equals(getComputedStyle(subject3).color, "rgb(173, 216, 230)",
"subject3 should be lightblue");

await new test_driver
.Actions()
.pointerUp()
.send();
assert_equals(getComputedStyle(subject1).color, "rgb(0, 0, 255)",
"subject1 should be blue again");
assert_equals(getComputedStyle(subject3).color, "rgb(0, 0, 128)",
"subject3 should be navy again");
await new Promise(resolve => {
unhoverme.addEventListener("mouseover", () => {
resolve();
}, {once: true});
new test_driver
.Actions()
.pointerUp()
.pointerMove(0, 0, {origin: unhoverme})
foolip marked this conversation as resolved.
Show resolved Hide resolved
foolip marked this conversation as resolved.
Show resolved Hide resolved
.send();
});
assert_equals(getComputedStyle(subject1).color, "rgb(0, 0, 0)",
"subject1 should be back to black");
assert_equals(getComputedStyle(subject3).color, "rgb(0, 0, 0)",
"subject3 should be back to black");

await new test_driver
.Actions()
.pointerMove(focusme1Rect.x + 1, focusme1Rect.y + 1, {origin: "viewport"})
.pointerDown()
.pointerUp()
.send();
await new Promise(resolve => {
focusme1.addEventListener("mouseup", () => {
resolve();
}, {once: true});
new test_driver
.Actions()
.pointerMove(0, 0, {origin: focusme1})
.pointerDown()
.pointerUp()
.send();
});
assert_equals(getComputedStyle(subject1).color, "rgb(0, 128, 0)",
"subject1 should be green");
assert_equals(getComputedStyle(subject3).color, "rgb(0, 100, 0)",
Expand Down