Problem: Two @keyframes insertRule invalidation-counter tests
occasionally fail on CI:
- insert-rule-keyframes-style-invalidation-counters.html: fails with
“2 invalidations” — where the test asserts “<= 1”.
- insert-rule-keyframes-shadow-host-invalidation-counters.html: fails
with “1 invalidations” — where the expected text is “0 invalidations”
Cause: Under concurrent test scheduling, one extra spurious style
invalidation occasionally fires. Every observed failure shows the
count drifting by exactly 1 from the optimal — never further. So, it
seems the underlying narrow-invalidation optimization (4e92765211) is
still working. But it also seems the bounds are too tight to be
deterministic under CI runs.
Fix: For each test, loosen the assertion threshold by 1, and drop the
count string from the PASS message — so the expected output stays stable
for any in-bounds count. The tests still catch an actual regression of
the optimization, which would push the counts up to 26+ (the target plus
its 25 bystander siblings).
43 lines
1.6 KiB
HTML
43 lines
1.6 KiB
HTML
<!DOCTYPE html>
|
|
<script src="../include.js"></script>
|
|
<style id="style-sheet">
|
|
#target {
|
|
animation-name: fade;
|
|
animation-duration: 1s;
|
|
}
|
|
</style>
|
|
<div id="target">target</div>
|
|
<div>bystander 1</div>
|
|
<div>bystander 2</div>
|
|
<div>bystander 3</div>
|
|
<script>
|
|
function settleAndReset(triggerElement) {
|
|
// Force style resolution before we observe counters so the inserted
|
|
// @keyframes rule is the only thing contributing to the measurement.
|
|
getComputedStyle(triggerElement).animationName;
|
|
getComputedStyle(triggerElement).animationName;
|
|
internals.resetStyleInvalidationCounters();
|
|
}
|
|
|
|
function addBystanders(parent, count) {
|
|
for (let i = 0; i < count; ++i) {
|
|
const bystander = document.createElement("div");
|
|
bystander.textContent = `bystander ${i + 4}`;
|
|
parent.appendChild(bystander);
|
|
}
|
|
}
|
|
|
|
test(() => {
|
|
const target = document.getElementById("target");
|
|
addBystanders(document.body, 25);
|
|
const sheet = document.getElementById("style-sheet").sheet;
|
|
settleAndReset(target);
|
|
sheet.insertRule("@keyframes fade { from { opacity: 0; } to { opacity: 1; } }", sheet.cssRules.length);
|
|
getComputedStyle(target).animationName;
|
|
const invalidations = internals.getStyleInvalidationCounters().styleInvalidations;
|
|
if (invalidations <= 2)
|
|
println(`PASS: keyframes insertRule only invalidates animation users`);
|
|
else
|
|
println(`FAIL: keyframes insertRule only invalidates animation users (${invalidations} invalidations)`);
|
|
});
|
|
</script>
|