Skip to content

Truly independent web browser

LibWeb: Test a read of a slottable as its slot hides and its rule goes

Andreas Kling3b95dbe866f1
diff --git a/Tests/LibWeb/Text/expected/css/style-engine/read-of-a-slottable-as-its-slot-hides-and-its-rule-goes.txt b/Tests/LibWeb/Text/expected/css/style-engine/read-of-a-slottable-as-its-slot-hides-and-its-rule-goes.txt
new file mode 100644
index 00000000000..9542a6e309b
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/css/style-engine/read-of-a-slottable-as-its-slot-hides-and-its-rule-goes.txt
@@ -0,0 +1,2 @@
+Before: slottable 4px, child 4px
+After: slottable 0px, child 0px
diff --git a/Tests/LibWeb/Text/input/css/style-engine/read-of-a-slottable-as-its-slot-hides-and-its-rule-goes.html b/Tests/LibWeb/Text/input/css/style-engine/read-of-a-slottable-as-its-slot-hides-and-its-rule-goes.html
new file mode 100644
index 00000000000..7baf1089bd1
--- /dev/null
+++ b/Tests/LibWeb/Text/input/css/style-engine/read-of-a-slottable-as-its-slot-hides-and-its-rule-goes.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<style id="sheet">.rule { margin-left: 4px; }</style>
+<script src="../../include.js"></script>
+<div id="host"><span id="slottable" class="rule"></span></div>
+<div id="plain"><span id="child" class="rule"></span></div>
+<script>
+ // A slottable is below its slot. Where the slot hides in the update that takes a rule away, a read answers without
+ // the rule, as it does below any other element that hides.
+ asyncTest(async done => {
+ const frame = () => new Promise(resolve => requestAnimationFrame(resolve));
+ const report = title => {
+ println(`${title}: slottable ${getComputedStyle(slottable).marginLeft}, child ${getComputedStyle(child).marginLeft}`);
+ };
+ const slot = document.createElement("slot");
+ host.attachShadow({ mode: "open" }).append(slot);
+ await frame();
+ report("Before");
+ await frame();
+ slot.hidden = true;
+ plain.hidden = true;
+ document.getElementById("sheet").media = "print";
+ await frame();
+ await frame();
+ report("After");
+ done();
+ });
+</script>