-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[css-position] Added 4 new sticky tests (#32612)
- Loading branch information
Showing
5 changed files
with
262 additions
and
20 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
css/css-position/sticky/position-sticky-fixed-ancestor-002.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<!DOCTYPE html> | ||
|
||
<meta charset="UTF-8"> | ||
|
||
<title>CSS Positioned Layout Test: a sticky element inside a fixed ancestor</title> | ||
|
||
<link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/"> | ||
<link rel="match" href="reference/position-sticky-fixed-ancestor-002-ref.html"> | ||
<link rel="help" href="https://www.w3.org/TR/css-position-3/#sticky-pos"> | ||
|
||
<meta name="flags" content=""> | ||
|
||
<style> | ||
html, body, div | ||
{ | ||
height: 100%; | ||
margin: 0; | ||
width: 100%; | ||
} | ||
|
||
div#positioned-container | ||
{ | ||
background-color: red; | ||
color: yellow; | ||
font-size: 40vh; | ||
position: absolute; | ||
} | ||
|
||
div#sticky | ||
{ | ||
background-color: green; | ||
bottom: 0; | ||
color: white; | ||
position: sticky; | ||
} | ||
</style> | ||
|
||
<script type="text/javascript"> | ||
function startTest() | ||
{ | ||
document.getElementById("positioned-container").style.position = "fixed"; | ||
} | ||
</script> | ||
|
||
<body onload="startTest();"> | ||
|
||
<div id="positioned-container"> | ||
|
||
<div id="vertical-spacer">FAIL</div> | ||
|
||
<div id="sticky">PASS</div> | ||
|
||
</div> |
44 changes: 44 additions & 0 deletions
44
css/css-position/sticky/position-sticky-fixed-ancestor-003.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<!DOCTYPE html> | ||
|
||
<meta charset="UTF-8"> | ||
|
||
<title>CSS Positioned Layout Test: a sticky element inside a fixed ancestor</title> | ||
|
||
<link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/"> | ||
<link rel="match" href="reference/position-sticky-fixed-ancestor-002-ref.html"> | ||
<link rel="help" href="https://www.w3.org/TR/css-position-3/#sticky-pos"> | ||
|
||
<meta name="flags" content=""> | ||
|
||
<style> | ||
html, body, div | ||
{ | ||
height: 100%; | ||
margin: 0; | ||
width: 100%; | ||
} | ||
|
||
div#fixed-container | ||
{ | ||
background-color: red; | ||
color: yellow; | ||
font-size: 40vh; | ||
position: fixed; | ||
} | ||
|
||
div#sticky | ||
{ | ||
background-color: green; | ||
bottom: 0; | ||
color: white; | ||
position: sticky; | ||
} | ||
</style> | ||
|
||
<div id="fixed-container"> | ||
|
||
<div id="vertical-spacer">FAIL</div> | ||
|
||
<div id="sticky">PASS</div> | ||
|
||
</div> |
118 changes: 98 additions & 20 deletions
118
css/css-position/sticky/position-sticky-scrolled-remove-sibling.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,99 @@ | ||
<!DOCTYPE html> | ||
<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org"> | ||
<link rel="help" href="https://www.w3.org/TR/css-position-3/#sticky-pos"> | ||
<p>Test passes if there is a filled green square, and no scrollbars</p> | ||
<div id="container" style="overflow:auto; width:100px; height:100px; background:red;"> | ||
<div style="position:sticky; top:0; height:100px; background:green;"></div> | ||
<div id="bigItem" style="height:600px;"></div> | ||
</div> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
container.scrollTop = 600; | ||
requestAnimationFrame(()=>{ | ||
requestAnimationFrame(()=>{ | ||
bigItem.style.display = "none"; | ||
test(()=> { | ||
assert_equals(container.scrollHeight, 100); | ||
}, "Sticky position and its overflow contribution"); | ||
}); | ||
}); | ||
</script> | ||
|
||
<meta charset="UTF-8"> | ||
|
||
<title>CSS Positioned Layout Test: element with 'position: sticky' and removing a sibling in the vertical axis and in the horizontal axis</title> | ||
|
||
<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org"> | ||
<link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/"> | ||
<link rel="help" href="https://www.w3.org/TR/css-position-3/#sticky-pos"> | ||
|
||
<meta name="flags" content=""> | ||
|
||
<style> | ||
div#scrollingContainerVert | ||
{ | ||
background-color: red; | ||
height: 100px; | ||
overflow: auto; | ||
width: 200px; | ||
} | ||
|
||
div#scrollingContainerHoriz | ||
{ | ||
background-color: red; | ||
height: 100px; | ||
overflow-x: auto; | ||
overflow-y: hidden; | ||
width: 200px; | ||
} | ||
|
||
div#elemStickyVert | ||
{ | ||
background-color: green; | ||
height: 100px; | ||
position: sticky; | ||
top: 0px; | ||
} | ||
|
||
div#scrollingContainerHoriz > div | ||
{ | ||
display: inline-block; | ||
height: 100%; | ||
} | ||
|
||
div#elemStickyHoriz | ||
{ | ||
background-color: green; | ||
left: 0px; | ||
position: sticky; | ||
width: 200px; | ||
} | ||
|
||
div#tallItem | ||
{ | ||
height: 600px; | ||
} | ||
|
||
div#wideItem | ||
{ | ||
width: 600px; | ||
} | ||
</style> | ||
|
||
|
||
<script src="/resources/testharness.js"></script> | ||
|
||
<script src="/resources/testharnessreport.js"></script> | ||
|
||
<p>Test passes if there is a filled green square and <strong>no scrollbar</strong>. | ||
|
||
<div id="scrollingContainerVert"> | ||
|
||
<div id="elemStickyVert"></div> | ||
|
||
<div id="tallItem"></div> | ||
|
||
</div> | ||
|
||
|
||
<div id="scrollingContainerHoriz"> | ||
|
||
<div id="elemStickyHoriz"></div><div id="wideItem"></div> | ||
|
||
</div> | ||
|
||
|
||
<script> | ||
test(()=> { | ||
scrollingContainerVert.scrollTop = 600; | ||
tallItem.style.display = "none"; | ||
assert_equals(scrollingContainerVert.scrollHeight, 100); | ||
}, "Sticky position and its overflow contribution in the vertical axis"); | ||
|
||
test(()=> { | ||
scrollingContainerHoriz.scrollLeft = 600; | ||
wideItem.style.display = "none"; | ||
assert_equals(scrollingContainerHoriz.scrollWidth, 200); | ||
}, "Sticky position and its overflow contribution in the horizontal axis"); | ||
</script> |
47 changes: 47 additions & 0 deletions
47
css/css-position/sticky/position-sticky-stacking-context-002.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<!DOCTYPE html> | ||
|
||
<meta charset="UTF-8"> | ||
|
||
<title>CSS Positioned Layout Test: an element with 'position: sticky' creates a stacking context</title> | ||
|
||
<link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/"> | ||
<link rel="match" href="../../reference/ref-filled-green-100px-square.xht"> | ||
<link rel="help" href="https://www.w3.org/TR/css-position-3/#sticky-pos"> | ||
|
||
<meta name="assert" content="This test checks that an element with 'position: sticky' creates a stacking context. In this test, the first 2 divs have the same 'auto' z-index value but since div#sticky is last in document tree order, then it must overlap div#overlapped-red. The final div#overlap-bottom-half-of-sticky exists to make sure that the div#sticky is squeezed, is 'sandwiched' between the other 2."> | ||
|
||
<style> | ||
div | ||
{ | ||
height: 100px; | ||
width: 100px; | ||
} | ||
|
||
div#overlapped-red | ||
{ | ||
background-color: red; | ||
position: absolute; | ||
} | ||
|
||
div#sticky | ||
{ | ||
background: linear-gradient(to bottom, green 51%, red 49%); | ||
position: sticky; | ||
} | ||
|
||
div#overlap-bottom-half-of-sticky | ||
{ | ||
background-color: green; | ||
bottom: 50px; | ||
height: 50px; | ||
position: relative; | ||
} | ||
</style> | ||
|
||
<p>Test passes if there is a filled green square and <strong>no red</strong>. | ||
|
||
<div id="overlapped-red"></div> | ||
|
||
<div id="sticky"></div> | ||
|
||
<div id="overlap-bottom-half-of-sticky"></div> |
20 changes: 20 additions & 0 deletions
20
css/css-position/sticky/reference/position-sticky-fixed-ancestor-002-ref.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!DOCTYPE html> | ||
|
||
<meta charset="UTF-8"> | ||
|
||
<title>CSS Reference File</title> | ||
|
||
<link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/"> | ||
|
||
<style> | ||
html, body, div | ||
{ | ||
background-color: green; | ||
color: white; | ||
font-size: 40vh; | ||
height: 100%; | ||
margin: 0; | ||
} | ||
</style> | ||
|
||
<div>PASS</div> |