Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /css/cssom-view/scrollintoview-zero-height-item.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<title>CSSOM View - scrollIntoView does not scroll to zero height item</title>
<meta charset="UTF-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<div style="border: 1px solid black; height: 300px; width: 200px; overflow-y: auto;visibility: hidden" id="box">
<div>text</div>
<div>text</div>
<div>text</div>
<div>text</div>
<div id="text">--- Clicking here should NOT scroll to top ---</div>
<div>text</div>
<div>text</div>
<div>text</div>
<div>text</div>
<div>text</div>
<div>text</div>
<div>text</div>
<div>text</div>
<div>text</div>
<div>text</div>
<div>text</div>
<div>text</div>
<div>text</div>
<div>text</div>
<div>text</div>
<div>text</div>
<div>text</div>
<div>text</div>
<div>text</div>
<div>text</div>
</div>
<script>
test(() => {
box.scrollTop = 40;
let div = document.createElement("div");
div.textContent = "div";
text.parentNode.insertBefore(div, text);
let span = document.createElement("span");
span.tabIndex = 0;
div.append(span);
span.scrollIntoViewIfNeeded();
assert_equals(box.scrollTop, 40, 'box.scrollTop');
}, `scrollIntoView on zero height item`);
</script>
</body>