Skip to content

Commit

Permalink
Bug 1570007 [wpt PR 18170] - MathML: Add tests for margin-collapsing.…
Browse files Browse the repository at this point in the history
…, a=testonly

Automatic update from web-platform-tests
MathML: Add tests for margin-collapsing. (#18170)

See w3c/mathml#42
--

wpt-commits: bf7e393610c462cd671feb88952330db442f8499
wpt-pr: 18170
  • Loading branch information
fred-wang authored and moz-wptsync-bot committed Aug 5, 2019
1 parent 82546c5 commit f07d1c5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,21 @@ function measureSpaceAround(id) {
return spaceBetween(childBox, parentBox);
}

function compareSpaceWithAndWithoutStyle(tag, style) {
function compareSpaceWithAndWithoutStyle(tag, style, parentStyle) {
if (!FragmentHelper.isValidChildOfMrow(tag) ||
FragmentHelper.isEmpty(tag))
throw `Invalid argument: ${tag}`;

document.body.insertAdjacentHTML("beforeend", `<div>\
<math>${MathMLFragments[tag]}</math>\
<math>${MathMLFragments[tag]}</math>\
<math><mrow>${MathMLFragments[tag]}</mrow></math>\
<math><mrow>${MathMLFragments[tag]}</mrow></math>\
</div>`);
var div = document.body.lastElementChild;

var styleMath = div.firstElementChild;
var styleParent = styleMath.firstElementChild;
if (parentStyle)
styleParent.setAttribute("style", parentStyle);
var styleElement = FragmentHelper.element(styleMath);
styleElement.setAttribute("style", style);
var styleChild = FragmentHelper.forceNonEmptyElement(styleElement);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@
assert_approx_equals(s.element_width_delta, 0, epsilon, "element width");
assert_approx_equals(s.element_height_delta, 0, epsilon, "element height");
}, `Margin properties on ${tag} (rtl)`);

test(function() {
// Apply the same margin style on the parent mrow.
// The margins are not collapsed so they should be added twice.
var s = compareSpaceWithAndWithoutStyle(tag, style, style);
assert_approx_equals(s.left_delta, 30 * 2, epsilon, "left margin");
assert_approx_equals(s.right_delta, 40 * 2, epsilon, "right margin");
assert_approx_equals(s.top_delta, 50 * 2, epsilon, "top margin");
assert_approx_equals(s.bottom_delta, 60 * 2, epsilon, "bottom margin");
assert_approx_equals(s.element_width_delta, 0, epsilon, "element width");
assert_approx_equals(s.element_height_delta, 0, epsilon, "element height");
}, `Margin properties on ${tag} (no margin-collapsing)`);
}

done();
Expand Down

0 comments on commit f07d1c5

Please sign in to comment.