Update web-platform-tests to revision e079873c1f30f13e23388a86b2b5beeddd349c78

This commit is contained in:
WPT Sync Bot 2019-07-28 10:24:18 +00:00
parent b52bfbe68a
commit a61792a8c1
32 changed files with 585 additions and 130 deletions

View file

@ -0,0 +1,51 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>border</title>
<link rel="help" href="https://mathml-refresh.github.io/mathml-core/#layout-algorithms">
<meta name="assert" content="Verify that border is taken into account.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/mathml/support/mathml-fragments.js"></script>
<script src="helper.js"></script>
<script>
var epsilon = 1;
setup({ explicit_done: true });
window.addEventListener("load", runTests);
function runTests() {
for (tag in MathMLFragments) {
if (!FragmentHelper.isValidChildOfMrow(tag))
continue;
var style = "border-left: 30px solid; border-right: 40px solid; border-top: 50px solid; border-bottom: 60px solid;";
if (FragmentHelper.isEmpty(tag)) {
test(function() {
var s = compareSizeWithAndWithoutStyle(tag, style);
assert_approx_equals(s.width_delta, 30 + 40, epsilon, "left/right border");
assert_approx_equals(s.height_delta, 50 + 60, epsilon, "top/bottom border");
}, `Border properties on ${tag}`);
continue;
}
test(function() {
var s = compareSpaceWithAndWithoutStyle(tag, style);
assert_approx_equals(s.left_delta, 30, epsilon, "left border");
assert_approx_equals(s.right_delta, 40, epsilon, "right border");
assert_approx_equals(s.top_delta, 50, epsilon, "top border");
assert_approx_equals(s.bottom_delta, 60, epsilon, "bottom border");
}, `Border properties on ${tag}`);
}
done();
}
</script>
</head>
<body>
<div id="log"></div>
</body>
</html>

View file

@ -1,8 +1,4 @@
function measureSpaceAround(id) {
var mrow = document.getElementById(id);
var mrowBox = mrow.getBoundingClientRect();
var parentBox = mrow.parentNode.getBoundingClientRect();
var childBox = mrow.firstElementChild.getBoundingClientRect();
function spaceBetween(childBox, parentBox) {
return {
left: childBox.left - parentBox.left,
right: parentBox.right - childBox.right,
@ -10,3 +6,74 @@ function measureSpaceAround(id) {
bottom: parentBox.bottom - childBox.bottom
};
}
function measureSpaceAround(id) {
var mrow = document.getElementById(id);
var mrowBox = mrow.getBoundingClientRect();
var parentBox = mrow.parentNode.getBoundingClientRect();
var childBox = mrow.firstElementChild.getBoundingClientRect();
return spaceBetween(childBox, parentBox);
}
function compareSpaceWithAndWithoutStyle(tag, style) {
if (!FragmentHelper.isValidChildOfMrow(tag) ||
FragmentHelper.isEmpty(tag))
throw `Invalid argument: ${tag}`;
document.body.insertAdjacentHTML("beforeend", `<div>\
<math>${MathMLFragments[tag]}</math>\
<math>${MathMLFragments[tag]}</math>\
</div>`);
var div = document.body.lastElementChild;
var styleMath = div.firstElementChild;
var styleElement = FragmentHelper.element(styleMath);
styleElement.setAttribute("style", style);
var styleChild = FragmentHelper.forceNonEmptyElement(styleElement);
var styleBox = styleMath.getBoundingClientRect();
var styleChildBox = styleChild.getBoundingClientRect();
var styleSpace = spaceBetween(styleChildBox, styleBox);
var noStyleMath = div.lastElementChild;
var noStyleElement = FragmentHelper.element(noStyleMath);
var noStyleChild = FragmentHelper.forceNonEmptyElement(noStyleElement);
var noStyleBox = noStyleMath.getBoundingClientRect();
var noStyleChildBox = noStyleChild.getBoundingClientRect();
var noStyleSpace = spaceBetween(noStyleChildBox, noStyleBox);
div.style = "display: none;"; // Hide the div after measurement.
return {
left_delta: styleSpace.left - noStyleSpace.left,
right_delta: styleSpace.right - noStyleSpace.right,
top_delta: styleSpace.top - noStyleSpace.top,
bottom_delta: styleSpace.bottom - noStyleSpace.bottom
};
}
function compareSizeWithAndWithoutStyle(tag, style) {
if (!FragmentHelper.isValidChildOfMrow(tag))
throw `Invalid argument: ${tag}`;
document.body.insertAdjacentHTML("beforeend", `<div>\
<math>${MathMLFragments[tag]}</math>\
<math>${MathMLFragments[tag]}</math>\
</div>`);
var div = document.body.lastElementChild;
var styleMath = div.firstElementChild;
var styleElement = FragmentHelper.element(styleMath);
styleElement.setAttribute("style", style);
var styleBox = styleMath.getBoundingClientRect();
var noStyleMath = div.lastElementChild;
var noStyleElement = FragmentHelper.element(noStyleMath);
var noStyleBox = noStyleMath.getBoundingClientRect();
div.style = "display: none;"; // Hide the div after measurement.
return {
width_delta: styleBox.width - noStyleBox.width,
height_delta: styleBox.height - noStyleBox.height
};
};

View file

@ -0,0 +1,51 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>margin</title>
<link rel="help" href="https://mathml-refresh.github.io/mathml-core/#layout-algorithms">
<meta name="assert" content="Verify that margin is taken into account.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/mathml/support/mathml-fragments.js"></script>
<script src="helper.js"></script>
<script>
var epsilon = 1;
setup({ explicit_done: true });
window.addEventListener("load", runTests);
function runTests() {
for (tag in MathMLFragments) {
if (!FragmentHelper.isValidChildOfMrow(tag))
continue;
var style = "margin-left: 30px; margin-right: 40px; margin-top: 50px; margin-bottom: 60px;";
if (FragmentHelper.isEmpty(tag)) {
test(function() {
var s = compareSizeWithAndWithoutStyle(tag, style);
assert_approx_equals(s.width_delta, 30 + 40, epsilon, "left/right margin");
assert_approx_equals(s.height_delta, 50 + 60, epsilon, "top/bottom margin");
}, `Margin properties on ${tag}`);
continue;
}
test(function() {
var s = compareSpaceWithAndWithoutStyle(tag, style);
assert_approx_equals(s.left_delta, 30, epsilon, "left margin");
assert_approx_equals(s.right_delta, 40, epsilon, "right margin");
assert_approx_equals(s.top_delta, 50, epsilon, "top margin");
assert_approx_equals(s.bottom_delta, 60, epsilon, "bottom margin");
}, `Margin properties on ${tag}`);
}
done();
}
</script>
</head>
<body>
<div id="log"></div>
</body>
</html>

View file

@ -0,0 +1,51 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>padding</title>
<link rel="help" href="https://mathml-refresh.github.io/mathml-core/#layout-algorithms">
<meta name="assert" content="Verify that padding is taken into account.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/mathml/support/mathml-fragments.js"></script>
<script src="helper.js"></script>
<script>
var epsilon = 1;
setup({ explicit_done: true });
window.addEventListener("load", runTests);
function runTests() {
for (tag in MathMLFragments) {
if (!FragmentHelper.isValidChildOfMrow(tag))
continue;
var style = "padding-left: 30px; padding-right: 40px; padding-top: 50px; padding-bottom: 60px;";
if (FragmentHelper.isEmpty(tag)) {
test(function() {
var s = compareSizeWithAndWithoutStyle(tag, style);
assert_approx_equals(s.width_delta, 30 + 40, epsilon, "left/right padding");
assert_approx_equals(s.height_delta, 50 + 60, epsilon, "top/bottom padding");
}, `Padding properties on ${tag}`);
continue;
}
test(function() {
var s = compareSpaceWithAndWithoutStyle(tag, style);
assert_approx_equals(s.left_delta, 30, epsilon, "left padding");
assert_approx_equals(s.right_delta, 40, epsilon, "right padding");
assert_approx_equals(s.top_delta, 50, epsilon, "top padding");
assert_approx_equals(s.bottom_delta, 60, epsilon, "bottom padding");
}, `Padding properties on ${tag}`);
}
done();
}
</script>
</head>
<body>
<div id="log"></div>
</body>
</html>

View file

@ -0,0 +1,39 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>padding</title>
<link rel="help" href="https://mathml-refresh.github.io/mathml-core/#layout-algorithms">
<meta name="assert" content="Verify that padding is taken into account.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/mathml/support/mathml-fragments.js"></script>
<script src="helper.js"></script>
<script>
var epsilon = 1;
setup({ explicit_done: true });
window.addEventListener("load", runTests);
function runTests() {
for (tag in MathMLFragments) {
if (!FragmentHelper.isEmpty(tag))
continue;
test(function() {
var style = "padding-left: 10px; padding-right: 20px; padding-top: 15px; padding-bottom: 25px;";
var s = compareSizeWithAndWithoutStyle(tag, style);
assert_approx_equals(s.width_delta, 10 + 20, epsilon, "padding left/right");
assert_approx_equals(s.height_delta, 15 + 25, epsilon, "padding top/bottom");
}, `Padding properties on ${tag}`);
}
done();
}
</script>
</head>
<body>
<div id="log"></div>
</body>
</html>