Skip to content

Commit

Permalink
When suppressing anchoring on an scrollframe, forward to the frame th…
Browse files Browse the repository at this point in the history
…at actually maintains the anchor as needed.

The test-case is position-change-heuristic.html but with body and #space
having overflow: hidden, which makes it fail on Nightly.

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

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1538537
gecko-commit: bd3a170fc984a92ff6478480b16e3d8ce9cb2f68
gecko-integration-branch: autoland
gecko-reviewers: dholbert
  • Loading branch information
emilio authored and jgraham committed May 20, 2020
1 parent af0bd2c commit 2341d4b
Showing 1 changed file with 85 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="help" href="https://drafts.csswg.org/css-scroll-anchoring/#suppression-triggers">
<style>
#space {
height: 4000px;
overflow: hidden;
}
#header {
background-color: #F5B335;
height: 50px;
width: 100%;
}
#content {
background-color: #D3D3D3;
height: 400px;
}
.scroller {
overflow: scroll;
position: relative;
width: 600px;
height: 600px;
}
body {
overflow: hidden;
}
</style>
<div id="maybeScroller">
<div id="space">
<div id="header"></div>
<div id="before"></div>
<div id="content"></div>
</div>
</div>
<script>

// Tests that scroll anchoring is suppressed when an element in the scroller
// changes its in-flow state.

var scroller;

function runCase(oldPos, newPos, expectSuppression, skipInverse) {
var header = document.querySelector("#header");
var before = document.querySelector("#before");

header.style.position = oldPos;
before.style.height = "0";
scroller.scrollTop = 200;

header.style.position = newPos;
before.style.height = "25px";

var expectedTop = expectSuppression ? 200 : 225;
assert_equals(scroller.scrollTop, expectedTop);

if (!skipInverse)
runCase(newPos, oldPos, expectSuppression, true);
}

test(() => {
scroller = document.scrollingElement;
document.querySelector("#maybeScroller").className = "";

runCase("static", "fixed", true);
runCase("static", "absolute", true);
runCase("static", "relative", false);
runCase("fixed", "absolute", false);
runCase("fixed", "relative", true);
runCase("absolute", "relative", true);
}, "Position changes in document scroller.");

test(() => {
scroller = document.querySelector("#maybeScroller");
scroller.className = "scroller";

runCase("static", "fixed", true);
runCase("static", "absolute", true);
runCase("static", "relative", false);
runCase("fixed", "absolute", false);
runCase("fixed", "relative", true);
runCase("absolute", "relative", true);
}, "Position changes in scrollable <div>.");

</script>

0 comments on commit 2341d4b

Please sign in to comment.