mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-12 06:08:24 +02:00
Automatic update from web-platform-testsposition:sticky - add test for overflow:hidden ancestor Bug: 879428 Change-Id: If92ac26be1fbf71be3e4a6040b764a09bc460eac Reviewed-on: https://chromium-review.googlesource.com/1207190 Reviewed-by: Robert Flack <flackr@chromium.org> Commit-Queue: Stephen McGruer <smcgruer@chromium.org> Cr-Commit-Position: refs/heads/master@{#588918} -- wpt-commits: 29717275b4d723b1159f41b072df84a390034fd9 wpt-pr: 12851
86 lines
2.9 KiB
HTML
86 lines
2.9 KiB
HTML
<!DOCTYPE html>
|
|
<title>position:sticky elements should respect an overflow:hidden ancestor</title>
|
|
<link rel="help" href="https://www.w3.org/TR/css-position-3/#sticky-pos" />
|
|
<meta name="assert" content="This test checks that position:sticky elements adhere to an overflow:hidden ancestor" />
|
|
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
|
|
<script src="resources/sticky-util.js"></script>
|
|
|
|
<body></body>
|
|
|
|
<script>
|
|
test(() => {
|
|
const outer_scroller = document.createElement('div');
|
|
outer_scroller.style.width = '100px';
|
|
outer_scroller.style.height = '100px';
|
|
outer_scroller.style.overflow = 'scroll';
|
|
|
|
const inner_scroller = document.createElement('div');
|
|
inner_scroller.style.width = '80%';
|
|
inner_scroller.style.height = '200px';
|
|
inner_scroller.style.overflow = 'hidden';
|
|
|
|
const sticky = document.createElement('div');
|
|
sticky.style.width = '20px';
|
|
sticky.style.height = '20px';
|
|
sticky.style.position = 'sticky';
|
|
sticky.style.top = '0';
|
|
sticky.style.background = 'red';
|
|
|
|
const spacer = document.createElement('div');
|
|
spacer.style.height = '500px';
|
|
|
|
inner_scroller.appendChild(sticky);
|
|
inner_scroller.appendChild(spacer);
|
|
outer_scroller.appendChild(inner_scroller);
|
|
document.body.appendChild(outer_scroller);
|
|
|
|
outer_scroller.scrollTop = 50;
|
|
|
|
// The sticky should attach to the inner scroller, and so should not stick.
|
|
assert_equals(sticky.offsetTop, inner_scroller.offsetTop);
|
|
}, 'A sticky element should attach to an overflow:hidden ancestor');
|
|
|
|
// This tests a specific bug in Firefox where the sticky element incorrectly
|
|
// started sticking when inside a table. See https://bugzilla.mozilla.org/show_bug.cgi?id=1488810
|
|
test(() => {
|
|
const outer_scroller = document.createElement('div');
|
|
outer_scroller.style.width = '100px';
|
|
outer_scroller.style.height = '100px';
|
|
outer_scroller.style.overflow = 'scroll';
|
|
|
|
const table = document.createElement('div');
|
|
table.style.display = 'table';
|
|
|
|
const tr = document.createElement('div');
|
|
tr.style.display = 'table-row';
|
|
|
|
const inner_scroller = document.createElement('div');
|
|
inner_scroller.style.display = 'table-cell';
|
|
inner_scroller.style.overflow = 'hidden';
|
|
|
|
const sticky = document.createElement('div');
|
|
sticky.style.width = '20px';
|
|
sticky.style.height = '20px';
|
|
sticky.style.position = 'sticky';
|
|
sticky.style.top = '0';
|
|
sticky.style.background = 'red';
|
|
|
|
const spacer = document.createElement('div');
|
|
spacer.style.height = '500px';
|
|
|
|
inner_scroller.appendChild(sticky);
|
|
inner_scroller.appendChild(spacer);
|
|
tr.append(inner_scroller);
|
|
table.appendChild(tr);
|
|
outer_scroller.appendChild(table);
|
|
document.body.appendChild(outer_scroller);
|
|
|
|
outer_scroller.scrollTop = 50;
|
|
|
|
// The sticky should attach to the inner scroller, and so should not stick.
|
|
assert_equals(sticky.offsetTop, inner_scroller.offsetTop);
|
|
}, 'A sticky element should attach to an overflow:hidden ancestor inside a table');
|
|
</script>
|