|
4 | 4 | <meta charset="utf-8">
|
5 | 5 | <title>width, height, inline-size and block-size</title>
|
6 | 6 | <link rel="help" href="https://w3c.github.io/mathml-core/#layout-algorithms">
|
7 |
| -<meta name="assert" content="Verify that width, height, inline-size and block-size properties are ignored."> |
| 7 | +<meta name="assert" content="Verify that width, height, inline-size and block-size properties set the size of the content box."> |
8 | 8 | <script src="/resources/testharness.js"></script>
|
9 | 9 | <script src="/resources/testharnessreport.js"></script>
|
10 | 10 | <script src="/mathml/support/feature-detection.js"></script>
|
|
30 | 30 | document.body.insertAdjacentHTML("beforeend", `<div style="position: absolute;"><math><mrow>${MathMLFragments[tag]}</mrow></math></div>`);
|
31 | 31 | let div = document.body.lastElementChild;
|
32 | 32 | let element = FragmentHelper.element(div.firstElementChild);
|
| 33 | + FragmentHelper.forceNonEmptyDescendants(element); |
33 | 34 |
|
34 | 35 | test(function() {
|
35 | 36 | assert_true(MathMLFeatureDetection[`has_${tag}`](), `${tag} is supported`);
|
|
49 | 50 | assert_approx_equals(box.height, 700, epsilon, "height");
|
50 | 51 | }, `inline-size and block-size properties on ${tag}`);
|
51 | 52 |
|
| 53 | + // Test that if we specify a size smaller than the content, then |
| 54 | + // it is used too. Note that we skip mtable, which follows CSS |
| 55 | + // tables rules and behave differently in that case. |
| 56 | + if (tag != "mtable") { |
| 57 | + test(function() { |
| 58 | + assert_true(MathMLFeatureDetection[`has_${tag}`](), `${tag} is supported`); |
| 59 | + var style = `width: 2px; height: 1px;`; |
| 60 | + element.setAttribute("style", style); |
| 61 | + let box = element.getBoundingClientRect(); |
| 62 | + assert_approx_equals(box.width, 2, epsilon, "width"); |
| 63 | + assert_approx_equals(box.height, 1, epsilon, "height"); |
| 64 | + }, `width and height properties on ${tag} (content overflowing)`); |
| 65 | + } |
| 66 | + |
| 67 | + div.style = "display: none;"; // Hide the div after measurement. |
| 68 | + |
| 69 | + document.body.insertAdjacentHTML("beforeend", `<div style="position: absolute;"><div style="display: inline-block"><math><mrow>${MathMLFragments[tag]}</mrow></math></div></div>`); |
| 70 | + let shrinkWrapDiv = document.body.lastElementChild.firstElementChild; |
| 71 | + element = FragmentHelper.element(shrinkWrapDiv.firstElementChild); |
| 72 | + FragmentHelper.forceNonEmptyDescendants(element); |
| 73 | + |
| 74 | + test(function() { |
| 75 | + assert_true(MathMLFeatureDetection[`has_${tag}`](), `${tag} is supported`); |
| 76 | + var style = `width: 300px;`; |
| 77 | + element.setAttribute("style", style); |
| 78 | + let box = shrinkWrapDiv.getBoundingClientRect(); |
| 79 | + assert_approx_equals(box.width, 300, epsilon); |
| 80 | + }, `width property on ${tag} (preferred width)`); |
| 81 | + |
52 | 82 | div.style = "display: none;"; // Hide the div after measurement.
|
53 | 83 | }
|
54 | 84 |
|
|
0 commit comments