Skip to content

Truly independent web browser

LibWeb: Test what the hover seal answers as keys and rules move

Andreas Klingd9e97ae483fa
diff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-seal-beside-a-frame-in-flight.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-seal-beside-a-frame-in-flight.txt
new file mode 100644
index 00000000000..d77c76f5095
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-seal-beside-a-frame-in-flight.txt
@@ -0,0 +1,5 @@
+no key: commit
+key in the update of the flying frame: clock
+computed width: 200px
+key gone in the update of the flying frame: commit
+computed width: 100px
diff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-seal-follows-a-hover-rule.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-seal-follows-a-hover-rule.txt
new file mode 100644
index 00000000000..1fa2913090c
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-seal-follows-a-hover-rule.txt
@@ -0,0 +1,4 @@
+no rule: commit
+rule added: clock
+computed width: 200px
+rule removed: commit
diff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-seal-follows-disabled-controls.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-seal-follows-disabled-controls.txt
new file mode 100644
index 00000000000..8265bf41c56
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-seal-follows-disabled-controls.txt
@@ -0,0 +1,5 @@
+enabled: commit
+disabled: clock
+enabled again: commit
+another disabled arrived: clock
+it left: commit
diff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-seal-follows-elements-arriving-and-leaving.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-seal-follows-elements-arriving-and-leaving.txt
new file mode 100644
index 00000000000..3bc76281b00
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-seal-follows-elements-arriving-and-leaving.txt
@@ -0,0 +1,3 @@
+no button: commit
+button arrived: clock
+button left: commit
diff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-seal-follows-keys-across-unrelated-rules.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-seal-follows-keys-across-unrelated-rules.txt
new file mode 100644
index 00000000000..23ba81b241f
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-seal-follows-keys-across-unrelated-rules.txt
@@ -0,0 +1,5 @@
+carrier stands: clock
+carrier stands, after a rule came: clock
+carrier went: commit
+carrier came, after a rule moved: clock
+computed width: 200px
diff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-seal-follows-the-classes-of-a-compound.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-seal-follows-the-classes-of-a-compound.txt
new file mode 100644
index 00000000000..f2315ee4a7e
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-seal-follows-the-classes-of-a-compound.txt
@@ -0,0 +1,4 @@
+first alone: commit
+both: clock
+computed width: 200px
+second alone: commit
diff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-seal-has-hover.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-seal-has-hover.txt
new file mode 100644
index 00000000000..e75b66b34d8
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-seal-has-hover.txt
@@ -0,0 +1,2 @@
+hovered: clock
+computed width: 200px
diff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-seal-in-a-shadow-tree.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-seal-in-a-shadow-tree.txt
new file mode 100644
index 00000000000..c38a3324945
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-seal-in-a-shadow-tree.txt
@@ -0,0 +1,5 @@
+no element carries the class: commit
+the element in the tree does: clock
+computed width: 200px
+:host(:hover): clock
+computed width: 300px
diff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-seal-nested-and-alternatives.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-seal-nested-and-alternatives.txt
new file mode 100644
index 00000000000..4050737b1b8
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-seal-nested-and-alternatives.txt
@@ -0,0 +1,10 @@
+none: commit
+computed width: 100px
+class of &: clock
+computed width: 200px
+class of :is(): clock
+computed width: 300px
+class of :where(:is()): clock
+computed width: 400px
+none again: commit
+computed width: 100px
diff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-seal-not-hover.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-seal-not-hover.txt
new file mode 100644
index 00000000000..aedffa45c05
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-seal-not-hover.txt
@@ -0,0 +1,4 @@
+no key: commit
+key: clock
+computed width: 100px
+bare :not(:hover): clock
diff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-seal-sibling-and-descendant-effects.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-seal-sibling-and-descendant-effects.txt
new file mode 100644
index 00000000000..e0fd9cd77d0
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-seal-sibling-and-descendant-effects.txt
@@ -0,0 +1,3 @@
+no trigger: commit
+trigger: clock, widths on screen 80 70 60
+computed: 80px 70px 60px
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/frame-in-flight.js b/Tests/LibWeb/Text/input/HTML/frame-in-flight/frame-in-flight.js
index 4cbdcc3be13..5a24a836180 100644
--- a/Tests/LibWeb/Text/input/HTML/frame-in-flight/frame-in-flight.js
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/frame-in-flight.js
@@ -126,3 +126,14 @@ async function whileLaneHovers(during, documents = [document], frameTime = undef
internals.setManualRenderingOpportunities(false);
}
}
+
+// Has a lane hover (x, y) beside a task, over the frame of a rendering update it injects, and answers who presents the
+// document's last frame then: the clock, or the commit, where the seal found no hover could restyle anything in the frame.
+async function hoverSeal(x, y) {
+ // NB: The lane an earlier move left would do for whileLaneHovers(), before the frame of what the test just wrote.
+ await twoFramesLanded();
+ return whileLaneHovers(frameTime => {
+ internals.injectHoverPointer(x, y, frameTime + 16);
+ return internals.lastFramePresentedBy(document);
+ });
+}
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-seal-beside-a-frame-in-flight.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-seal-beside-a-frame-in-flight.html
new file mode 100644
index 00000000000..f826e398a99
--- /dev/null
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-seal-beside-a-frame-in-flight.html
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<script src="../../include.js"></script>
+<script src="frame-in-flight.js"></script>
+<style>
+ body { margin: 0; }
+ div { width: 100px; height: 100px; }
+ .menu:hover { width: 200px; }
+</style>
+<div id="target"></div>
+<script>
+ // A pointer move that waits while a frame flies is hovered by the lane of that frame, once it comes together. What
+ // the rendering update of the frame moved counts for the seal of its lane.
+ asyncTest(async done => {
+ const hoverBesideFlight = async mutate => {
+ await whileRecordingInFlight(mutate, () => {
+ internals.moveHoverPointer(50, 50);
+ });
+ internals.setManualRenderingOpportunities(true);
+ do await nextTask();
+ while (internals.frameSchedulerState() !== "idle" || internals.clockLaneIsComing(document));
+ internals.injectClockTick(performance.now() + 32);
+ const by = internals.lastFramePresentedBy(document);
+ internals.setManualRenderingOpportunities(false);
+ return by;
+ };
+
+ println(`no key: ${await hoverSeal(50, 50)}`);
+ await twoFrames();
+ internals.queueMouseMove(500, 500);
+ await twoFrames();
+
+ println(`key in the update of the flying frame: ${await hoverBesideFlight(() => target.classList.add("menu"))}`);
+ await twoFrames();
+ println(`computed width: ${getComputedStyle(target).width}`);
+ internals.queueMouseMove(500, 500);
+ await twoFrames();
+
+ println(`key gone in the update of the flying frame: ${await hoverBesideFlight(() => target.classList.remove("menu"))}`);
+ await twoFrames();
+ println(`computed width: ${getComputedStyle(target).width}`);
+ done();
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-seal-follows-a-hover-rule.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-seal-follows-a-hover-rule.html
new file mode 100644
index 00000000000..b2a0f138734
--- /dev/null
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-seal-follows-a-hover-rule.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<script src="../../include.js"></script>
+<script src="frame-in-flight.js"></script>
+<style>
+ body { margin: 0; }
+ #target { width: 100px; height: 100px; }
+</style>
+<div id="target"></div>
+<script>
+ // A rule testing :hover that arrives after the seal found none gives the next frame's hover a restyle to make, and
+ // one that goes takes it away again.
+ asyncTest(async done => {
+ println(`no rule: ${await hoverSeal(50, 50)}`);
+ await twoFrames();
+
+ const style = document.createElement("style");
+ style.textContent = "#target:hover { width: 200px; }";
+ document.head.append(style);
+ internals.queueMouseMove(500, 500);
+ await twoFrames();
+ println(`rule added: ${await hoverSeal(50, 50)}`);
+ await twoFrames();
+ println(`computed width: ${getComputedStyle(target).width}`);
+
+ style.remove();
+ internals.queueMouseMove(500, 500);
+ await twoFrames();
+ println(`rule removed: ${await hoverSeal(50, 50)}`);
+ done();
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-seal-follows-disabled-controls.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-seal-follows-disabled-controls.html
new file mode 100644
index 00000000000..1e2f664d3f6
--- /dev/null
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-seal-follows-disabled-controls.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<script src="../../include.js"></script>
+<script src="frame-in-flight.js"></script>
+<style>
+ body { margin: 0; }
+ div { width: 100px; height: 100px; }
+ textarea { display: block; width: 100px; height: 100px; margin: 0; padding: 0; border: 0; }
+</style>
+<div id="target"></div>
+<textarea id="control"></textarea>
+<script>
+ // A disabled control under the pointer takes no mouse event, which only the style engine tells, and has the lane
+ // follow the pointer wherever it goes: the seal follows the state of a control beside the element hovered, as it comes
+ // and goes, and as a control that holds it arrives and leaves.
+ asyncTest(async done => {
+ const run = async name => {
+ println(`${name}: ${await hoverSeal(50, 50)}`);
+ await twoFrames();
+ internals.queueMouseMove(500, 500);
+ await twoFrames();
+ };
+ await run("enabled");
+ control.disabled = true;
+ await run("disabled");
+ control.disabled = false;
+ await run("enabled again");
+ const another = document.createElement("textarea");
+ another.disabled = true;
+ document.body.append(another);
+ await run("another disabled arrived");
+ another.remove();
+ await run("it left");
+ done();
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-seal-follows-elements-arriving-and-leaving.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-seal-follows-elements-arriving-and-leaving.html
new file mode 100644
index 00000000000..cfd47fbea14
--- /dev/null
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-seal-follows-elements-arriving-and-leaving.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<script src="../../include.js"></script>
+<script src="frame-in-flight.js"></script>
+<style>
+ body { margin: 0; }
+ #wrapper { width: 100px; height: 100px; }
+ #wrapper button { display: block; width: 100px; height: 100px; }
+</style>
+<div id="wrapper"></div>
+<script>
+ // Default.css restyles a <button> on hover: the seal follows one arriving and one leaving, deep in a subtree that
+ // arrives and leaves whole.
+ asyncTest(async done => {
+ println(`no button: ${await hoverSeal(50, 50)}`);
+ await twoFrames();
+ internals.queueMouseMove(500, 500);
+ await twoFrames();
+
+ const subtree = document.createElement("div");
+ subtree.append(document.createElement("div"));
+ subtree.firstChild.append(document.createElement("button"));
+ wrapper.append(subtree);
+ println(`button arrived: ${await hoverSeal(50, 50)}`);
+ await twoFrames();
+ internals.queueMouseMove(500, 500);
+ await twoFrames();
+
+ subtree.remove();
+ println(`button left: ${await hoverSeal(50, 50)}`);
+ done();
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-seal-follows-keys-across-unrelated-rules.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-seal-follows-keys-across-unrelated-rules.html
new file mode 100644
index 00000000000..8454ed4d196
--- /dev/null
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-seal-follows-keys-across-unrelated-rules.html
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<script src="../../include.js"></script>
+<script src="frame-in-flight.js"></script>
+<style>
+ body { margin: 0; }
+ div { width: 100px; height: 100px; }
+ .menu:hover { width: 200px; }
+</style>
+<div id="target" class="menu"></div>
+<div id="other"></div>
+<script>
+ // A rule that tests no :hover leaves the seal's answer as it was, and the keys it follows: a key that moves after
+ // the rule counts as before it.
+ asyncTest(async done => {
+ const run = async (name, x, y) => {
+ println(`${name}: ${await hoverSeal(x, y)}`);
+ await twoFrames();
+ internals.queueMouseMove(500, 500);
+ await twoFrames();
+ };
+ await run("carrier stands", 50, 50);
+
+ const style = document.createElement("style");
+ style.textContent = "#other { outline: 1px solid rgb(0, 128, 0); }";
+ document.head.append(style);
+ await run("carrier stands, after a rule came", 50, 50);
+
+ target.classList.remove("menu");
+ await run("carrier went", 50, 50);
+
+ style.textContent = "#other { outline: 2px solid rgb(0, 128, 0); }";
+ await twoFrames();
+ other.classList.add("menu");
+ println(`carrier came, after a rule moved: ${await hoverSeal(50, 150)}`);
+ await twoFrames();
+ println(`computed width: ${getComputedStyle(other).width}`);
+ done();
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-seal-follows-the-classes-of-a-compound.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-seal-follows-the-classes-of-a-compound.html
new file mode 100644
index 00000000000..1adb72a6d8b
--- /dev/null
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-seal-follows-the-classes-of-a-compound.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<script src="../../include.js"></script>
+<script src="frame-in-flight.js"></script>
+<style>
+ body { margin: 0; }
+ div { width: 100px; height: 100px; }
+ .first.second:hover { width: 200px; }
+</style>
+<div id="target" class="first"></div>
+<script>
+ // A compound asks every key it names of one element: the seal follows each class as it comes and goes.
+ asyncTest(async done => {
+ println(`first alone: ${await hoverSeal(50, 50)}`);
+ await twoFrames();
+ internals.queueMouseMove(500, 500);
+ await twoFrames();
+
+ target.classList.add("second");
+ println(`both: ${await hoverSeal(50, 50)}`);
+ await twoFrames();
+ println(`computed width: ${getComputedStyle(target).width}`);
+ internals.queueMouseMove(500, 500);
+ await twoFrames();
+
+ target.classList.remove("first");
+ println(`second alone: ${await hoverSeal(50, 50)}`);
+ done();
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-seal-has-hover.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-seal-has-hover.html
new file mode 100644
index 00000000000..2c0cca876b7
--- /dev/null
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-seal-has-hover.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<script src="../../include.js"></script>
+<script src="frame-in-flight.js"></script>
+<style>
+ body { margin: 0; }
+ #parent, #child { width: 100px; height: 100px; }
+ #parent:has(:hover) #child { width: 200px; }
+</style>
+<div id="parent"><div id="child"></div></div>
+<script>
+ // Any element's hover can flip the :has() of an element above it, whose key no element under the pointer carries.
+ asyncTest(async done => {
+ println(`hovered: ${await hoverSeal(50, 50)}`);
+ await twoFrames();
+ println(`computed width: ${getComputedStyle(child).width}`);
+ done();
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-seal-in-a-shadow-tree.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-seal-in-a-shadow-tree.html
new file mode 100644
index 00000000000..fda18814dff
--- /dev/null
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-seal-in-a-shadow-tree.html
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<script src="../../include.js"></script>
+<script src="frame-in-flight.js"></script>
+<style>
+ body { margin: 0; }
+ #host { display: block; width: 100px; height: 100px; }
+</style>
+<div id="host"></div>
+<script>
+ // A rule in a shadow tree counts as any other, for the elements of the tree.
+ asyncTest(async done => {
+ const shadow = host.attachShadow({ mode: "open" });
+ shadow.innerHTML = `<style>
+ div { width: 100px; height: 100px; }
+ .inner:hover { width: 200px; }
+ </style><div id="inside"></div>`;
+ const inside = shadow.getElementById("inside");
+ println(`no element carries the class: ${await hoverSeal(50, 50)}`);
+ await twoFrames();
+ internals.queueMouseMove(500, 500);
+ await twoFrames();
+
+ inside.classList.add("inner");
+ println(`the element in the tree does: ${await hoverSeal(50, 50)}`);
+ await twoFrames();
+ println(`computed width: ${getComputedStyle(inside).width}`);
+ internals.queueMouseMove(500, 500);
+ await twoFrames();
+
+ inside.classList.remove("inner");
+ const later = document.createElement("style");
+ later.textContent = ":host(:hover) div { width: 300px; }";
+ shadow.append(later);
+ println(`:host(:hover): ${await hoverSeal(50, 50)}`);
+ await twoFrames();
+ println(`computed width: ${getComputedStyle(inside).width}`);
+ done();
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-seal-nested-and-alternatives.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-seal-nested-and-alternatives.html
new file mode 100644
index 00000000000..c76bf97dd98
--- /dev/null
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-seal-nested-and-alternatives.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<script src="../../include.js"></script>
+<script src="frame-in-flight.js"></script>
+<style>
+ body { margin: 0; }
+ div { width: 100px; height: 100px; }
+ .nested, section {
+ &:hover { width: 200px; }
+ }
+ :is(.alternative, article):hover { width: 300px; }
+ :where(:is(.deep)):hover { width: 400px; }
+</style>
+<div id="target"></div>
+<script>
+ // The keys of a compound are those of each alternative of its &, :is() and :where().
+ asyncTest(async done => {
+ const run = async name => {
+ println(`${name}: ${await hoverSeal(50, 50)}`);
+ await twoFrames();
+ println(`computed width: ${getComputedStyle(target).width}`);
+ internals.queueMouseMove(500, 500);
+ await twoFrames();
+ };
+ await run("none");
+ target.className = "nested";
+ await run("class of &");
+ target.className = "alternative";
+ await run("class of :is()");
+ target.className = "deep";
+ await run("class of :where(:is())");
+ target.className = "";
+ await run("none again");
+ done();
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-seal-not-hover.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-seal-not-hover.html
new file mode 100644
index 00000000000..f8383a05692
--- /dev/null
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-seal-not-hover.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<script src="../../include.js"></script>
+<script src="frame-in-flight.js"></script>
+<style>
+ body { margin: 0; }
+ div { width: 100px; height: 100px; }
+ .keyed:not(:hover) { width: 200px; }
+</style>
+<div id="target"></div>
+<script>
+ // Leaving :hover restyles an element as entering it does: what counts is the key beside the :not(:hover). A rule with
+ // no key beside it applies to any element.
+ asyncTest(async done => {
+ println(`no key: ${await hoverSeal(50, 50)}`);
+ await twoFrames();
+ internals.queueMouseMove(500, 500);
+ await twoFrames();
+
+ target.classList.add("keyed");
+ println(`key: ${await hoverSeal(50, 50)}`);
+ await twoFrames();
+ println(`computed width: ${getComputedStyle(target).width}`);
+ internals.queueMouseMove(500, 500);
+ await twoFrames();
+
+ target.classList.remove("keyed");
+ const style = document.createElement("style");
+ style.textContent = ":not(:hover) { outline: 1px solid rgb(0, 128, 0); }";
+ document.head.append(style);
+ println(`bare :not(:hover): ${await hoverSeal(50, 50)}`);
+ done();
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-seal-sibling-and-descendant-effects.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-seal-sibling-and-descendant-effects.html
new file mode 100644
index 00000000000..0a151d3a638
--- /dev/null
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-seal-sibling-and-descendant-effects.html
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<script src="../../include.js"></script>
+<script src="frame-in-flight.js"></script>
+<style>
+ body { margin: 0; }
+ #wrapper { width: 200px; height: 100px; }
+ #hovered { width: 100px; height: 100px; }
+ #next, #later, #inner { width: 50px; height: 10px; }
+ .trigger:hover ~ #later { width: 60px; }
+ .trigger:hover + #next { width: 70px; }
+ .trigger:hover #inner { width: 80px; }
+</style>
+<div id="wrapper">
+ <div id="hovered"><div id="inner"></div></div>
+ <div id="next"></div>
+ <div id="later"></div>
+</div>
+<script>
+ // What a hover restyles need not be what it hovers: the key that counts is that of the compound testing :hover,
+ // whichever element the rule ends in.
+ asyncTest(async done => {
+ println(`no trigger: ${await hoverSeal(50, 50)}`);
+ await twoFrames();
+ internals.queueMouseMove(500, 500);
+ await twoFrames();
+
+ hovered.classList.add("trigger");
+ await twoFramesLanded();
+ const by = await whileLaneHovers(frameTime => {
+ internals.injectHoverPointer(50, 50, frameTime + 16);
+ const width = element => internals.presentedBorderBox(element)?.width;
+ return `${internals.lastFramePresentedBy(document)}, widths on screen ${width(inner)} ${width(next)} ${width(later)}`;
+ });
+ println(`trigger: ${by}`);
+ await twoFrames();
+ println(`computed: ${getComputedStyle(inner).width} ${getComputedStyle(next).width} ${getComputedStyle(later).width}`);
+ done();
+ });
+</script>