Update web-platform-tests to revision cfada7e6cb379699fa94c7ed8fcb97082327e10c

This commit is contained in:
WPT Sync Bot 2019-07-31 10:22:21 +00:00
parent 87e7e3d429
commit 06b00da16b
179 changed files with 6103 additions and 1186 deletions

View file

@ -0,0 +1,90 @@
function spaceBetween(childBox, parentBox) {
return {
left: childBox.left - parentBox.left,
right: parentBox.right - childBox.right,
top: childBox.top - parentBox.top,
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, parentStyle) {
if (!FragmentHelper.isValidChildOfMrow(tag) ||
FragmentHelper.isEmpty(tag))
throw `Invalid argument: ${tag}`;
document.body.insertAdjacentHTML("beforeend", `<div>\
<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);
var styleMathBox = styleMath.getBoundingClientRect();
var styleElementBox = styleElement.getBoundingClientRect();
var styleChildBox = styleChild.getBoundingClientRect();
var styleSpace = spaceBetween(styleChildBox, styleMathBox);
var noStyleMath = div.lastElementChild;
var noStyleElement = FragmentHelper.element(noStyleMath);
var noStyleChild = FragmentHelper.forceNonEmptyElement(noStyleElement);
var noStyleMathBox = noStyleMath.getBoundingClientRect();
var noStyleElementBox = noStyleElement.getBoundingClientRect();
var noStyleChildBox = noStyleChild.getBoundingClientRect();
var noStyleSpace = spaceBetween(noStyleChildBox, noStyleMathBox);
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,
element_width_delta: styleElementBox.width - noStyleElementBox.width,
element_height_delta: styleElementBox.height - noStyleElementBox.height
};
}
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 styleMathBox = styleMath.getBoundingClientRect();
var styleElementBox = styleElement.getBoundingClientRect();
var noStyleMath = div.lastElementChild;
var noStyleElement = FragmentHelper.element(noStyleMath);
var noStyleMathBox = noStyleMath.getBoundingClientRect();
var noStyleElementBox = noStyleElement.getBoundingClientRect();
div.style = "display: none;"; // Hide the div after measurement.
return {
width_delta: styleMathBox.width - noStyleMathBox.width,
height_delta: styleMathBox.height - noStyleMathBox.height,
element_width_delta: styleElementBox.width - noStyleElementBox.width,
element_height_delta: styleElementBox.height - noStyleElementBox.height
};
};

View file

@ -0,0 +1,95 @@
function getWritingMode(element, reference) {
var style = window.getComputedStyle(reference);
if (style.getPropertyValue("writing-mode") !== "horizontal-tb" ||
style.getPropertyValue("direction") !== "ltr")
throw "Reference should have writing mode horizontal-tb and ltr";
style = window.getComputedStyle(element);
var param = {
rtl: style.getPropertyValue("direction") === "rtl",
mode: style.getPropertyValue("writing-mode")
};
return param;
}
function compareSize(element, reference, epsilon) {
var param = getWritingMode(element, reference);
var elementBox = element.getBoundingClientRect();
var referenceBox = reference.getBoundingClientRect();
switch(param.mode) {
case "horizontal-tb":
assert_approx_equals(elementBox.width, referenceBox.width, epsilon,
"inline size");
assert_approx_equals(elementBox.height, referenceBox.height, epsilon,
"block size");
break;
case "vertical-lr":
case "vertical-rl":
assert_approx_equals(elementBox.width, referenceBox.height, epsilon,
"inline size");
assert_approx_equals(elementBox.height, referenceBox.width, epsilon,
"block size");
break;
default:
throw "compareSize: Unrecognized writing-mode value";
}
}
function compareLayout(element, reference, epsilon) {
if (element.children.length != reference.children.length)
throw "Reference should have the same number of children."
// Compare sizes of elements and children.
var param = getWritingMode(element, reference);
compareSize(element, reference, epsilon);
var elementBox = element.getBoundingClientRect();
var referenceBox = reference.getBoundingClientRect();
for (var i = 0; i < element.children.length; i++) {
var childDisplay = window.
getComputedStyle(element.children[i]).getPropertyValue("display");
var referenceChildDisplay = window.
getComputedStyle(reference.children[i]).getPropertyValue("display");
if (referenceChildDisplay !== childDisplay)
throw "compareLayout: children of reference should have the same display values.";
if (childDisplay === "none")
continue;
compareSize(element.children[i], reference.children[i], epsilon);
var childBox = element.children[i].getBoundingClientRect();
var referenceChildBox = reference.children[i].getBoundingClientRect();
switch(param.mode) {
case "horizontal-tb":
if (!param.rtl)
throw "compareLayout: unexpected writing-mode value";
assert_approx_equals(elementBox.right - childBox.right,
referenceChildBox.left - referenceBox.left,
epsilon,
`inline position (child ${i})`);
assert_approx_equals(childBox.top - elementBox.top,
referenceChildBox.top - referenceBox.top,
epsilon,
`block position (child ${i})`);
break;
case "vertical-lr":
case "vertical-rl":
assert_approx_equals(param.rtl ?
elementBox.bottom - childBox.bottom :
childBox.top - elementBox.top,
referenceChildBox.left - referenceBox.left,
epsilon,
`inline position (child ${i})`);
assert_approx_equals(elementBox.right - childBox.right,
referenceChildBox.top - referenceBox.top,
epsilon,
`block position (child ${i})`);
break;
default:
throw "compareLayout: Unrecognized writing-mode value";
}
}
}

View file

@ -55,18 +55,18 @@ var MathMLFragments = {
"msqrt": "<msqrt class='element mathml-container'></msqrt>",
"mstyle": "<mstyle class='element mathml-container'></mstyle>",
"msub": "\
<msub class='element mathml-container'>\
<msub class='element'>\
<mrow class='mathml-container'></mrow>\
<mrow class='mathml-container'></mrow>\
</msub>",
"msubsup": "\
<msubsup class='element mathml-container'>\
<msubsup class='element'>\
<mrow class='mathml-container'></mrow>\
<mrow class='mathml-container'></mrow>\
<mrow class='mathml-container'></mrow>\
</msubsup>",
"msup": "\
<msup class='element mathml-container'>\
<msup class='element'>\
<mrow class='mathml-container'></mrow>\
<mrow class='mathml-container'></mrow>\
</msup>",