gecko-dev/testing/web-platform/tests/css/css-scroll-anchoring/exclude-sticky.html
Ryan Hunt 2866d20a40 Bug 1518626 - Add scroll-anchoring tests for excluding certain elements from anchor selection. r=dholbert
This commit adds two tests around anchor selection.

The first tests that 'position: sticky' is an invalid subtree, which is new to
the spec. The second tests that implementations respect 'overflow-anchor' on
the table element, and don't get confused with the boxes generated by tables.

Differential Revision: https://phabricator.services.mozilla.com/D16274

--HG--
extra : rebase_source : 3c2e74a5765d3409a57aa892fe20aa208c5c0e84
extra : intermediate-source : 55addc12904b79f7300e47da96b1d33780a4cbfb
extra : source : 306393539feb1a3391c3a03baaee43e7058bc44a
2019-01-08 13:02:41 -06:00

28 lines
905 B
HTML

<!DOCTYPE html>
<meta charset="utf-8">
<link rel="help" href="https://drafts.csswg.org/css-scroll-anchoring-1/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
body { height: 400vh; margin: 0; }
#sticky, #content { width: 200px; height: 100px; }
#sticky { position: sticky; left: 100px; top: 50px; }
#before { height: 50px; }
#content { margin-top: 100px; }
</style>
<div id="sticky">sticky</div>
<div id="before"></div>
<div id="content">content</div>
<script>
// Tests that the anchor selection algorithm skips sticky-positioned elements.
test(() => {
document.scrollingElement.scrollTop = 150;
document.querySelector("#before").style.height = "100px";
assert_equals(document.scrollingElement.scrollTop, 200);
}, "Sticky-positioned headers shouldn't be chosen as scroll anchors (we should use 'content' instead)");
</script>