mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
script: Clamp table spans according to the HTML specification (#36703)
Previously, spans were partially clamped during layout, but this means that accessing and setting these properties via script wouldn't behave according to the HTML specification. In addition, the value wasn't floored in layout, so could lead to panics. This change improves clamping and moves it to script. Testing: This change includes a new WPT test. Fixes #36699. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
b10fc49e8a
commit
0d21992edd
9 changed files with 177 additions and 75 deletions
11
tests/wpt/meta/MANIFEST.json
vendored
11
tests/wpt/meta/MANIFEST.json
vendored
|
@ -4916,6 +4916,13 @@
|
|||
{}
|
||||
]
|
||||
],
|
||||
"colspan-zero-crash.html": [
|
||||
"a50586a5bfa7551724b838a0438339a34b4930fb",
|
||||
[
|
||||
null,
|
||||
{}
|
||||
]
|
||||
],
|
||||
"crashtests": {
|
||||
"caption-repaint-crash.html": [
|
||||
"6a024d0c1d7ef58da06a489d80d187bcb2a3e350",
|
||||
|
@ -739709,14 +739716,14 @@
|
|||
],
|
||||
"processing-model-1": {
|
||||
"col-span-limits.html": [
|
||||
"a4a425b9c1f70926c77ad3eb1b8a8a87a4655de9",
|
||||
"2a1ac80e65ad37a0e15ca383e67889b79f2308d0",
|
||||
[
|
||||
null,
|
||||
{}
|
||||
]
|
||||
],
|
||||
"span-limits.html": [
|
||||
"cdfa61bbcdc06ea62b80d042440d55fb0c89a186",
|
||||
"798639b387562a54965d5283673a50773c2a3c49",
|
||||
[
|
||||
null,
|
||||
{
|
||||
|
|
|
@ -1487,9 +1487,6 @@
|
|||
[colgroup.tabIndex: IDL set to -2147483648]
|
||||
expected: FAIL
|
||||
|
||||
[colgroup.span: setAttribute() to 2147483647]
|
||||
expected: FAIL
|
||||
|
||||
[colgroup.span: setAttribute() to 2147483648]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -1499,9 +1496,6 @@
|
|||
[colgroup.span: setAttribute() to 4294967296]
|
||||
expected: FAIL
|
||||
|
||||
[colgroup.span: setAttribute() to 1001]
|
||||
expected: FAIL
|
||||
|
||||
[colgroup.span: IDL set to 0]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -2276,9 +2270,6 @@
|
|||
[col.tabIndex: IDL set to -2147483648]
|
||||
expected: FAIL
|
||||
|
||||
[col.span: setAttribute() to 2147483647]
|
||||
expected: FAIL
|
||||
|
||||
[col.span: setAttribute() to 2147483648]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -2288,9 +2279,6 @@
|
|||
[col.span: setAttribute() to 4294967296]
|
||||
expected: FAIL
|
||||
|
||||
[col.span: setAttribute() to 1001]
|
||||
expected: FAIL
|
||||
|
||||
[col.span: IDL set to 0]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -5657,9 +5645,6 @@
|
|||
[td.tabIndex: IDL set to -2147483648]
|
||||
expected: FAIL
|
||||
|
||||
[td.colSpan: setAttribute() to 2147483647]
|
||||
expected: FAIL
|
||||
|
||||
[td.colSpan: setAttribute() to 2147483648]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -5669,9 +5654,6 @@
|
|||
[td.colSpan: setAttribute() to 4294967296]
|
||||
expected: FAIL
|
||||
|
||||
[td.colSpan: setAttribute() to 1001]
|
||||
expected: FAIL
|
||||
|
||||
[td.colSpan: IDL set to 0]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -5684,9 +5666,6 @@
|
|||
[td.colSpan: IDL set to 1001]
|
||||
expected: FAIL
|
||||
|
||||
[td.rowSpan: setAttribute() to 2147483647]
|
||||
expected: FAIL
|
||||
|
||||
[td.rowSpan: setAttribute() to 2147483648]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -5696,9 +5675,6 @@
|
|||
[td.rowSpan: setAttribute() to 4294967296]
|
||||
expected: FAIL
|
||||
|
||||
[td.rowSpan: setAttribute() to 65535]
|
||||
expected: FAIL
|
||||
|
||||
[td.rowSpan: IDL set to 2147483647]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -7157,9 +7133,6 @@
|
|||
[th.tabIndex: IDL set to -2147483648]
|
||||
expected: FAIL
|
||||
|
||||
[th.colSpan: setAttribute() to 2147483647]
|
||||
expected: FAIL
|
||||
|
||||
[th.colSpan: setAttribute() to 2147483648]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -7169,9 +7142,6 @@
|
|||
[th.colSpan: setAttribute() to 4294967296]
|
||||
expected: FAIL
|
||||
|
||||
[th.colSpan: setAttribute() to 1001]
|
||||
expected: FAIL
|
||||
|
||||
[th.colSpan: IDL set to 0]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -7184,9 +7154,6 @@
|
|||
[th.colSpan: IDL set to 1001]
|
||||
expected: FAIL
|
||||
|
||||
[th.rowSpan: setAttribute() to 2147483647]
|
||||
expected: FAIL
|
||||
|
||||
[th.rowSpan: setAttribute() to 2147483648]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -7196,9 +7163,6 @@
|
|||
[th.rowSpan: setAttribute() to 4294967296]
|
||||
expected: FAIL
|
||||
|
||||
[th.rowSpan: setAttribute() to 65535]
|
||||
expected: FAIL
|
||||
|
||||
[th.rowSpan: IDL set to 2147483647]
|
||||
expected: FAIL
|
||||
|
||||
|
|
10
tests/wpt/tests/css/css-tables/colspan-zero-crash.html
vendored
Normal file
10
tests/wpt/tests/css/css-tables/colspan-zero-crash.html
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<link rel="help" href="https://github.com/servo/servo/issues/36699">
|
||||
<link rel="author" href="mailto:fwang@igalia.com" title="Frédéric Wang">
|
||||
<span id="span"></span>
|
||||
<script>
|
||||
let th = document.createElement("th");
|
||||
span.replaceWith(th);
|
||||
th.colSpan = 0;
|
||||
</script>
|
||||
|
|
@ -39,12 +39,21 @@ These two must look the same, each having 2 cells in one row:
|
|||
</table>
|
||||
<br>
|
||||
<table id=table3>
|
||||
<col span=1001>
|
||||
<col id="colspan-3" span=1001>
|
||||
<tr>
|
||||
<td colspan=1000><div class="square"></div></td>
|
||||
<td><div class="square"></div></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table>
|
||||
<tr>
|
||||
<td id="colspan-limit-test1" colspan=5></td>
|
||||
<td id="colspan-limit-test2" colspan=0></td>
|
||||
<td id="colspan-limit-test3" colspan=1000></td>
|
||||
<td id="colspan-limit-test4" colspan=1001></td>
|
||||
<td id="colspan-limit-test5" colspan=5555555></td>
|
||||
</tr>
|
||||
</table>
|
||||
</main>
|
||||
|
||||
<script>
|
||||
|
@ -56,4 +65,48 @@ test(() => {
|
|||
assert_equals(table2.offsetWidth, 51, "table2 width");
|
||||
assert_equals(table3.offsetWidth, 51, "table3 width");
|
||||
}, "col span of 1001 must be treated as 1000");
|
||||
|
||||
test(() => {
|
||||
let td = document.createElement("td");
|
||||
td.colSpan = 5;
|
||||
assert_equals(td.colSpan, 5);
|
||||
|
||||
td.colSpan = 0;
|
||||
assert_equals(td.colSpan, 1);
|
||||
|
||||
td.colSpan = 1000;
|
||||
assert_equals(td.colSpan, 1000);
|
||||
|
||||
td.colSpan = 1001;
|
||||
assert_equals(td.colSpan, 1000);
|
||||
|
||||
td.colSpan = 555555;
|
||||
assert_equals(td.colSpan, 1000);
|
||||
}, "colspan must be clamped to [1, 1000] when set via script");
|
||||
|
||||
test(() => {
|
||||
assert_equals(document.getElementById("colspan-limit-test1").colSpan, 5);
|
||||
assert_equals(document.getElementById("colspan-limit-test2").colSpan, 1);
|
||||
assert_equals(document.getElementById("colspan-limit-test3").colSpan, 1000);
|
||||
assert_equals(document.getElementById("colspan-limit-test4").colSpan, 1000);
|
||||
assert_equals(document.getElementById("colspan-limit-test5").colSpan, 1000);
|
||||
}, "colspan must be clamped to [1, 1000] when parsing attributes");
|
||||
|
||||
test(() => {
|
||||
let column = document.getElementById("colspan-3");
|
||||
column.span = 5;
|
||||
assert_equals(column.span, 5);
|
||||
|
||||
column.span = 0;
|
||||
assert_equals(column.span, 1);
|
||||
|
||||
column.span = 1000;
|
||||
assert_equals(column.span, 1000);
|
||||
|
||||
column.span = 1001;
|
||||
assert_equals(column.span, 1000);
|
||||
|
||||
column.span = 555555;
|
||||
assert_equals(column.span, 1000);
|
||||
}, "column span must be clamped to [1, 1000] when set via script");
|
||||
</script>
|
||||
|
|
|
@ -29,6 +29,17 @@
|
|||
<!-- We'll add another 65534 rows later -->
|
||||
</table>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td id="rowspan-limit-test1" rowspan=5></td>
|
||||
<td id="rowspan-limit-test2" rowspan=0></td>
|
||||
<td id="rowspan-limit-test3" rowspan=1000></td>
|
||||
<td id="rowspan-limit-test4" rowspan=65534></td>
|
||||
<td id="rowspan-limit-test5" rowspan=65535></td>
|
||||
<td id="rowspan-limit-test6" rowspan=5555555></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<script>
|
||||
var $ = document.querySelector.bind(document);
|
||||
|
||||
|
@ -63,4 +74,34 @@ test(() => {
|
|||
assert_equals($("#d1").getBoundingClientRect().bottom,
|
||||
$("#d2").getBoundingClientRect().bottom);
|
||||
}, "rowspan of 65535 must be treated as 65534");
|
||||
|
||||
test(() => {
|
||||
let td = document.createElement("td");
|
||||
td.rowSpan = 5;
|
||||
assert_equals(td.rowSpan, 5);
|
||||
|
||||
td.rowSpan = 0;
|
||||
assert_equals(td.rowSpan, 0);
|
||||
|
||||
td.rowSpan = 1000;
|
||||
assert_equals(td.rowSpan, 1000);
|
||||
|
||||
td.rowSpan = 65534;
|
||||
assert_equals(td.rowSpan, 65534);
|
||||
|
||||
td.rowSpan = 65535;
|
||||
assert_equals(td.rowSpan, 65534);
|
||||
|
||||
td.rowSpan = 555555;
|
||||
assert_equals(td.rowSpan, 65534);
|
||||
}, "rowspan must be clamped to [0, 65534] when set via script");
|
||||
|
||||
test(() => {
|
||||
assert_equals(document.getElementById("rowspan-limit-test1").rowSpan, 5);
|
||||
assert_equals(document.getElementById("rowspan-limit-test2").rowSpan, 0);
|
||||
assert_equals(document.getElementById("rowspan-limit-test3").rowSpan, 1000);
|
||||
assert_equals(document.getElementById("rowspan-limit-test4").rowSpan, 65534);
|
||||
assert_equals(document.getElementById("rowspan-limit-test5").rowSpan, 65534);
|
||||
assert_equals(document.getElementById("rowspan-limit-test6").rowSpan, 65534);
|
||||
}, "rowspan must be clamped to [0, 65534] when parsing attributes");
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue