blob: cf7a4fba585a1d1ad495e3155cef82aa127e0cf5 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<style>
iframe {
position: fixed;
margin-left: 5vw;
margin-top: 60vh;
width: 90vw;
height: 40vh;
border: 0px;
}
div.bottom {
position: absolute;
top: 10000px;
left: 0px;
width: 1px;
height: 1px;
}
p {
position: fixed;
}
</style>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="resources/large-sticky-ad-testharness.js"></script>
</head>
<body marginwidth="0" marginheight="0">
<!-- To trigger the first contentful paint at the very start -->
<p>some content</p>
<!-- To be positioned further down in the main page to make the page scrollable -->
<div class="bottom"></div>
<script>
promise_test(async function(t) {
// Create the large-sticky-ad.
appendAdFrameTo(document.body);
// After 1500ms, force a layout update so that the sticky ad detector is
// aware of the sticky ad candidate.
await timeout(1500);
await forceLayoutUpdate();
assert_false(internals.isUseCounted(document, kLargeStickyAd));
// Scroll down to 1px.
window.scrollTo(0, 1);
// After 1500ms, force a layout update. At this point the scrolling
// position hasn't changed much since the detector first saw the
// candidate, so we expect no use counter for kLargeStickyAd.
await timeout(1500);
await forceLayoutUpdate();
assert_false(internals.isUseCounted(document, kLargeStickyAd));
// Scroll down to 5000px.
window.scrollTo(0, 5000);
// After 1500ms, force a layout update. At this point the scrolling
// position has changed by a distance greater than the candidate's height,
// so the use counter kLargeStickyAd should be recorded.
await timeout(1500);
await forceLayoutUpdate();
assert_true(internals.isUseCounted(document, kLargeStickyAd));
}, "Test UseCounter for large-sticky-ad at the bottom when the frame itself has a fixed position.");
</script>
</body>
</html>