forked from mirrors/gecko-dev
Automatic update from web-platform-tests blink: adds test for overflow-clip-margin and intersection observer This verifies intersection observer properly reflects overflow-clip-margin on an ancestor. BUG=1157843 TEST=test only change Change-Id: I9c9839294df8ffb88b42947aa87c7cc5222f5a6d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2593812 Reviewed-by: Stefan Zager <szager@chromium.org> Reviewed-by: vmpstr <vmpstr@chromium.org> Commit-Queue: Scott Violet <sky@chromium.org> Cr-Commit-Position: refs/heads/master@{#838232} -- wpt-commits: 7e7eb272d56b9e1f9f2b7336c03ada50b584b45c wpt-pr: 26908
55 lines
1.8 KiB
HTML
55 lines
1.8 KiB
HTML
<!doctype html>
|
|
<meta charset="utf-8">
|
|
<title>Overflow: intersection observer with overflow-clip-margin</title>
|
|
<link rel="help" href="https://www.w3.org/TR/css-overflow-3/#propdef-overflow-clip-margin">
|
|
<link rel="author" title="Scott Violet" href="mailto:sky@chromium.org">
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<style>
|
|
#clipped_container {
|
|
overflow: clip;
|
|
width: 100px;
|
|
height: 100px;
|
|
border: solid;
|
|
overflow-clip-margin: 50px;
|
|
}
|
|
#big_green_div {
|
|
position: relative;
|
|
width: 1000px;
|
|
height: 1000px;
|
|
background: green;
|
|
left: -200px;
|
|
top: -200px;
|
|
}
|
|
/* These values ensure the element is vertically offscreen. */
|
|
.spacer { width: 150px; height: calc(100vh + 10px); }
|
|
</style>
|
|
<div class="spacer"></div>
|
|
<div id="clipped_container">
|
|
<div id="big_green_div"></div>
|
|
</div>
|
|
|
|
<script>
|
|
let t = async_test("ParentWithOverflowClipMargin");
|
|
let options = {
|
|
threshold: 0,
|
|
rootMargin: '0px'
|
|
}
|
|
// The 'big_green_div' is initially on screen due to
|
|
// overflow-clip-margin of the parent. Once the observer is notified, the
|
|
// overflow-clip-margin is reduced so that 'big_green_div' is no longer
|
|
// on screen, and the observer should again be notified.
|
|
let gotIntersects = false;
|
|
let intersectionObserver = new IntersectionObserver((entries, observer) => {
|
|
t.step(function() { assert_equals(1, entries.length); });
|
|
let entry = entries[0];
|
|
if (!gotIntersects) {
|
|
t.step(function() { assert_true(entry.isIntersecting); });
|
|
gotIntersects = true;
|
|
document.getElementById('clipped_container').style.overflowClipMargin = "0px";
|
|
} else {
|
|
t.step(function() { assert_false(entry.isIntersecting); });
|
|
t.done();
|
|
}}, options);
|
|
intersectionObserver.observe(document.getElementById('big_green_div'));
|
|
</script>
|