зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1587188 [wpt PR 19577] - Load Ahem as a web font in css-shapes tests., a=testonly
Automatic update from web-platform-tests Load Ahem as a web font in css-shapes tests. (#19577) This makes font setup/restoration explicit rather than per-subtest. This allows us to setup Ahem usage, then wait for fonts to load, and then run all computed tests as a discrete block. The previous method (which dynamically inserted Ahem prior to a subtest and removed it immediately after) didn't allow us to wait for the web fonts to be loaded because the test page would have no Ahem usage present at the time we waited for the fonts.ready event. -- wpt-commits: 4c1bbd4b27cfa527485d4f56609895c9df55212b wpt-pr: 19577
This commit is contained in:
Родитель
486e97beb0
Коммит
eef4a421ce
|
@ -10,10 +10,12 @@
|
||||||
<script src="/resources/testharness.js"></script>
|
<script src="/resources/testharness.js"></script>
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="support/parsing-utils.js"></script>
|
<script src="support/parsing-utils.js"></script>
|
||||||
|
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="log"></div>
|
<div id="log"></div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
setup({explicit_done: true});
|
||||||
var shape_margin_valid_unit_tests = [];
|
var shape_margin_valid_unit_tests = [];
|
||||||
ParsingUtils.validUnits.forEach(function(unit) {
|
ParsingUtils.validUnits.forEach(function(unit) {
|
||||||
test = "10"+unit;
|
test = "10"+unit;
|
||||||
|
@ -25,10 +27,16 @@
|
||||||
testCase["expected_computed"] = test;
|
testCase["expected_computed"] = test;
|
||||||
shape_margin_valid_unit_tests.push(testCase);
|
shape_margin_valid_unit_tests.push(testCase);
|
||||||
});
|
});
|
||||||
|
|
||||||
generate_tests( ParsingUtils.testShapeMarginInlineStyle,
|
generate_tests( ParsingUtils.testShapeMarginInlineStyle,
|
||||||
ParsingUtils.buildTestCases(shape_margin_valid_unit_tests, "inline"), true);
|
ParsingUtils.buildTestCases(shape_margin_valid_unit_tests, "inline"), true);
|
||||||
generate_tests( ParsingUtils.testShapeMarginComputedStyle,
|
ParsingUtils.setupFonts();
|
||||||
ParsingUtils.buildTestCases(shape_margin_valid_unit_tests, "computed"), true);
|
document.fonts.ready.then(()=> {
|
||||||
|
generate_tests( ParsingUtils.testShapeMarginComputedStyle,
|
||||||
|
ParsingUtils.buildTestCases(shape_margin_valid_unit_tests, "computed"), true);
|
||||||
|
ParsingUtils.restoreFonts();
|
||||||
|
done();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -13,14 +13,21 @@
|
||||||
<script src="/resources/testharness.js"></script>
|
<script src="/resources/testharness.js"></script>
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="support/parsing-utils.js"></script>
|
<script src="support/parsing-utils.js"></script>
|
||||||
|
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="log"></div>
|
<div id="log"></div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
setup({explicit_done: true});
|
||||||
generate_tests( ParsingUtils.testInlineStyle,
|
generate_tests( ParsingUtils.testInlineStyle,
|
||||||
ParsingUtils.buildPositionTests("circle", true, 'lengthUnit + inline', ParsingUtils.validUnits) );
|
ParsingUtils.buildPositionTests("circle", true, 'lengthUnit + inline', ParsingUtils.validUnits) );
|
||||||
generate_tests( ParsingUtils.testComputedStyle,
|
ParsingUtils.setupFonts();
|
||||||
ParsingUtils.buildPositionTests("circle", true, 'lengthUnit + computed', ParsingUtils.validUnits) );
|
document.fonts.ready.then(()=> {
|
||||||
|
generate_tests( ParsingUtils.testComputedStyle,
|
||||||
|
ParsingUtils.buildPositionTests("circle", true, 'lengthUnit + computed', ParsingUtils.validUnits) );
|
||||||
|
ParsingUtils.restoreFonts();
|
||||||
|
done();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -12,12 +12,19 @@
|
||||||
<script src="/resources/testharness.js"></script>
|
<script src="/resources/testharness.js"></script>
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="support/parsing-utils.js"></script>
|
<script src="support/parsing-utils.js"></script>
|
||||||
|
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="log"></div>
|
<div id="log"></div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
setup({explicit_done: true});
|
||||||
generate_tests(ParsingUtils.testInlineStyle, ParsingUtils.buildRadiiTests('circle', 'lengthUnit + inline', ParsingUtils.validUnits));
|
generate_tests(ParsingUtils.testInlineStyle, ParsingUtils.buildRadiiTests('circle', 'lengthUnit + inline', ParsingUtils.validUnits));
|
||||||
generate_tests(ParsingUtils.testComputedStyle, ParsingUtils.buildRadiiTests('circle', 'lengthUnit + computed', ParsingUtils.validUnits));
|
ParsingUtils.setupFonts();
|
||||||
|
document.fonts.ready.then(()=> {
|
||||||
|
generate_tests(ParsingUtils.testComputedStyle, ParsingUtils.buildRadiiTests('circle', 'lengthUnit + computed', ParsingUtils.validUnits));
|
||||||
|
ParsingUtils.restoreFonts();
|
||||||
|
done();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -13,14 +13,21 @@
|
||||||
<script src="/resources/testharness.js"></script>
|
<script src="/resources/testharness.js"></script>
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="support/parsing-utils.js"></script>
|
<script src="support/parsing-utils.js"></script>
|
||||||
|
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="log"></div>
|
<div id="log"></div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
setup({explicit_done: true});
|
||||||
generate_tests( ParsingUtils.testInlineStyle,
|
generate_tests( ParsingUtils.testInlineStyle,
|
||||||
ParsingUtils.buildPositionTests("ellipse", true, 'lengthUnit + inline', ParsingUtils.validUnits) );
|
ParsingUtils.buildPositionTests("ellipse", true, 'lengthUnit + inline', ParsingUtils.validUnits) );
|
||||||
generate_tests( ParsingUtils.testComputedStyle,
|
ParsingUtils.setupFonts();
|
||||||
ParsingUtils.buildPositionTests("ellipse", true, 'lengthUnit + computed', ParsingUtils.validUnits) );
|
document.fonts.ready.then(()=> {
|
||||||
|
generate_tests( ParsingUtils.testComputedStyle,
|
||||||
|
ParsingUtils.buildPositionTests("ellipse", true, 'lengthUnit + computed', ParsingUtils.validUnits) );
|
||||||
|
ParsingUtils.restoreFonts();
|
||||||
|
done();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -12,12 +12,20 @@
|
||||||
<script src="/resources/testharness.js"></script>
|
<script src="/resources/testharness.js"></script>
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="support/parsing-utils.js"></script>
|
<script src="support/parsing-utils.js"></script>
|
||||||
|
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="log"></div>
|
<div id="log"></div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
setup({explicit_done: true});
|
||||||
generate_tests(ParsingUtils.testInlineStyle, ParsingUtils.buildRadiiTests('ellipse', 'lengthUnit + inline', ParsingUtils.validUnits));
|
generate_tests(ParsingUtils.testInlineStyle, ParsingUtils.buildRadiiTests('ellipse', 'lengthUnit + inline', ParsingUtils.validUnits));
|
||||||
generate_tests(ParsingUtils.testComputedStyle, ParsingUtils.buildRadiiTests('ellipse', 'lengthUnit + computed', ParsingUtils.validUnits));
|
ParsingUtils.setupFonts();
|
||||||
|
document.fonts.ready.then(()=> {
|
||||||
|
generate_tests(ParsingUtils.testComputedStyle,
|
||||||
|
ParsingUtils.buildRadiiTests('ellipse', 'lengthUnit + computed', ParsingUtils.validUnits));
|
||||||
|
ParsingUtils.restoreFonts();
|
||||||
|
done();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -13,15 +13,22 @@
|
||||||
<script src="/resources/testharness.js"></script>
|
<script src="/resources/testharness.js"></script>
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="support/parsing-utils.js"></script>
|
<script src="support/parsing-utils.js"></script>
|
||||||
|
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="log"></div>
|
<div id="log"></div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
setup({explicit_done: true});
|
||||||
ParsingUtils.validUnits.forEach(function(unit) {
|
ParsingUtils.validUnits.forEach(function(unit) {
|
||||||
generate_tests(ParsingUtils.testInlineStyle, ParsingUtils.generateInsetRoundCases(unit, 'inline'));
|
generate_tests(ParsingUtils.testInlineStyle, ParsingUtils.generateInsetRoundCases(unit, 'inline'));
|
||||||
});
|
});
|
||||||
ParsingUtils.validUnits.forEach(function(unit) {
|
ParsingUtils.setupFonts();
|
||||||
generate_tests(ParsingUtils.testComputedStyle, ParsingUtils.generateInsetRoundCases(unit, 'computed'));
|
document.fonts.ready.then(()=> {
|
||||||
|
ParsingUtils.validUnits.forEach(function(unit) {
|
||||||
|
generate_tests(ParsingUtils.testComputedStyle, ParsingUtils.generateInsetRoundCases(unit, 'computed'));
|
||||||
|
});
|
||||||
|
ParsingUtils.restoreFonts();
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -13,10 +13,12 @@
|
||||||
<script src="/resources/testharness.js"></script>
|
<script src="/resources/testharness.js"></script>
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="support/parsing-utils.js"></script>
|
<script src="support/parsing-utils.js"></script>
|
||||||
|
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="log"></div>
|
<div id="log"></div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
setup({explicit_done: true});
|
||||||
var arg_length_units_tests = [
|
var arg_length_units_tests = [
|
||||||
['%', 'px', 'px'],
|
['%', 'px', 'px'],
|
||||||
['px', '%', 'px'],
|
['px', '%', 'px'],
|
||||||
|
@ -31,8 +33,13 @@
|
||||||
];
|
];
|
||||||
generate_tests( ParsingUtils.testInlineStyle,
|
generate_tests( ParsingUtils.testInlineStyle,
|
||||||
ParsingUtils.buildPolygonTests(arg_length_units_tests, 'inline') );
|
ParsingUtils.buildPolygonTests(arg_length_units_tests, 'inline') );
|
||||||
generate_tests( ParsingUtils.testComputedStyle,
|
ParsingUtils.setupFonts();
|
||||||
ParsingUtils.buildPolygonTests(arg_length_units_tests, 'computed') );
|
document.fonts.ready.then(()=> {
|
||||||
|
generate_tests( ParsingUtils.testComputedStyle,
|
||||||
|
ParsingUtils.buildPolygonTests(arg_length_units_tests, 'computed') );
|
||||||
|
ParsingUtils.restoreFonts();
|
||||||
|
done();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
<script src="/resources/testharness.js"></script>
|
<script src="/resources/testharness.js"></script>
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="support/parsing-utils.js"></script>
|
<script src="support/parsing-utils.js"></script>
|
||||||
|
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="log"></div>
|
<div id="log"></div>
|
||||||
|
@ -21,6 +22,7 @@
|
||||||
// fixed units: cm, mm, in, px, pt, pc
|
// fixed units: cm, mm, in, px, pt, pc
|
||||||
// percentage unit: %
|
// percentage unit: %
|
||||||
// zero length: 0
|
// zero length: 0
|
||||||
|
setup({explicit_done: true});
|
||||||
var basic_shape_args_tests = [
|
var basic_shape_args_tests = [
|
||||||
{
|
{
|
||||||
"name": "0-valued",
|
"name": "0-valued",
|
||||||
|
@ -53,10 +55,17 @@
|
||||||
"expected_computed": "polygon(1% 2%)"
|
"expected_computed": "polygon(1% 2%)"
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
generate_tests( ParsingUtils.testInlineStyle,
|
generate_tests( ParsingUtils.testInlineStyle,
|
||||||
ParsingUtils.buildTestCases(basic_shape_args_tests, "inline") );
|
ParsingUtils.buildTestCases(basic_shape_args_tests, "inline") );
|
||||||
generate_tests( ParsingUtils.testComputedStyle,
|
ParsingUtils.setupFonts();
|
||||||
ParsingUtils.buildTestCases(basic_shape_args_tests, "computed") );
|
document.fonts.ready.then(()=> {
|
||||||
|
generate_tests( ParsingUtils.testComputedStyle,
|
||||||
|
ParsingUtils.buildTestCases(basic_shape_args_tests, "computed") );
|
||||||
|
ParsingUtils.restoreFonts();
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -446,31 +446,32 @@ function each(object, func) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupFonts(func) {
|
/// For saving and restoring font properties
|
||||||
return function () {
|
var savedFontValues = { };
|
||||||
var fontProperties = {
|
|
||||||
'font-family': 'Ahem',
|
function setupFonts() {
|
||||||
'font-size': '16px',
|
var fontProperties = {
|
||||||
'line-height': '1'
|
'font-family': 'Ahem',
|
||||||
};
|
'font-size': '16px',
|
||||||
var savedValues = { };
|
'line-height': '1'
|
||||||
each(fontProperties, function (key, value) {
|
|
||||||
savedValues[key] = document.body.style.getPropertyValue(key);
|
|
||||||
document.body.style.setProperty(key, value);
|
|
||||||
});
|
|
||||||
try {
|
|
||||||
func.apply(this, arguments);
|
|
||||||
} finally {
|
|
||||||
each(savedValues, function (key, value) {
|
|
||||||
if (value) {
|
|
||||||
document.body.style.setProperty(key, value);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
document.body.style.removeProperty(key);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
savedFontValues = { };
|
||||||
|
each(fontProperties, function (key, value) {
|
||||||
|
savedFontValues[key] = document.body.style.getPropertyValue(key);
|
||||||
|
document.body.style.setProperty(key, value);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function restoreFonts() {
|
||||||
|
each(savedFontValues, function (key, value) {
|
||||||
|
if (value) {
|
||||||
|
document.body.style.setProperty(key, value);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
document.body.style.removeProperty(key);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
savedFontValues = { };
|
||||||
}
|
}
|
||||||
|
|
||||||
var validUnits = [
|
var validUnits = [
|
||||||
|
@ -819,11 +820,11 @@ var calcTestValues = [
|
||||||
|
|
||||||
return {
|
return {
|
||||||
testInlineStyle: testInlineStyle,
|
testInlineStyle: testInlineStyle,
|
||||||
testComputedStyle: setupFonts(testComputedStyle),
|
testComputedStyle: testComputedStyle,
|
||||||
testShapeMarginInlineStyle: testShapeMarginInlineStyle,
|
testShapeMarginInlineStyle: testShapeMarginInlineStyle,
|
||||||
testShapeMarginComputedStyle: setupFonts(testShapeMarginComputedStyle),
|
testShapeMarginComputedStyle: testShapeMarginComputedStyle,
|
||||||
testShapeThresholdInlineStyle: testShapeThresholdInlineStyle,
|
testShapeThresholdInlineStyle: testShapeThresholdInlineStyle,
|
||||||
testShapeThresholdComputedStyle: setupFonts(testShapeThresholdComputedStyle),
|
testShapeThresholdComputedStyle: testShapeThresholdComputedStyle,
|
||||||
buildTestCases: buildTestCases,
|
buildTestCases: buildTestCases,
|
||||||
buildRadiiTests: buildRadiiTests,
|
buildRadiiTests: buildRadiiTests,
|
||||||
buildPositionTests: buildPositionTests,
|
buildPositionTests: buildPositionTests,
|
||||||
|
@ -834,6 +835,7 @@ return {
|
||||||
validUnits: validUnits,
|
validUnits: validUnits,
|
||||||
calcTestValues: calcTestValues,
|
calcTestValues: calcTestValues,
|
||||||
roundResultStr: roundResultStr,
|
roundResultStr: roundResultStr,
|
||||||
setupFonts: setupFonts
|
setupFonts: setupFonts,
|
||||||
|
restoreFonts: restoreFonts,
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче