Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Element::has_css_layout_box()
Calling scroll() on an element which is not rendered (by a parent with display: none) would previously cause a crash. In fact, we should terminate the algorithm [https://drafts.csswg.org/cssom-view/#dom-element-scroll] at step 10 in this situation. The fix hinges on implementing Element::has_css_layout_box() correctly, rather than just returning true in all cases as we did previously. Fixes #19430.
- Loading branch information
1 parent
9f2b33c
commit 902edb9
Showing
3 changed files
with
36 additions
and
4 deletions.
There are no files selected for viewing
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
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
21 changes: 21 additions & 0 deletions
21
tests/wpt/web-platform-tests/css/cssom-view/scroll-no-layout-box.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,21 @@ | ||
<!DOCTYPE html> | ||
<meta charset=utf-8> | ||
<title>cssom-view - Scrolling element with no layout box</title> | ||
<link rel="help" href="https://drafts.csswg.org/cssom-view/#dom-element-scroll"> | ||
<link rel="help" href="https://drafts.csswg.org/cssom-view/#css-layout-box"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
|
||
<div style="display: none"> | ||
<div id="elem"></div> | ||
</div> | ||
|
||
<script> | ||
test(() => { | ||
const elem = document.getElementById('elem'); | ||
elem.scroll(1, 2); | ||
|
||
assert_equals(elem.scrollTop, 0, "scrollTop should be unchanged"); | ||
assert_equals(elem.scrollLeft, 0, "scrollLeft should be unchanged"); | ||
}, "scrolling an element with no CSS layout box should have no effect"); | ||
</script> |