Skip to content

Commit

Permalink
Bug 1555718 [wpt PR 17100] - Add new tests for CSS properties math-st…
Browse files Browse the repository at this point in the history
…yle and math-script-level , a=testonly

Automatic update from web-platform-tests
Add new tests for CSS properties math-style and math-script-level  (#17100)

* Add tests for new CSS property math-style.

* Add tests for CSS property math-script-level

* Add tests using scaling factors from the MATH table.

* Improve coverage of math-script-level-004:
- Test scaling without MATH font.
- Test scaling up and down.
- Test all transitions between levels -3, -1, 0, 1, 2, 3, 5.

* Add tests to check issue #3739 and interaction with script-level.

* Add a tentative reftest to check how math-script-level and font-family interacts on font-size change. This is related to w3c/csswg-drafts#3906

--

wp5At-commits: 90d09993c72864735e76cf4d5f152436273ffdcd
wpt-pr: 17100

UltraBlame original commit: ea29e77dd7357d8fa1f8b317acca8153c3455489
  • Loading branch information
marco-c committed Oct 4, 2019
1 parent 4a11773 commit 55adb33
Show file tree
Hide file tree
Showing 30 changed files with 1,228 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<!DOCTYPE html>
<html>
<head>
<title>math-script-level</title>
<meta charset="utf-8">
<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/3746">
<meta name="assert" content="Check the resolved value of math-script-level">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function mathScriptLevel(id) {
return window.getComputedStyle(document.getElementById(id)).
getPropertyValue("math-script-level");
}
setup({ explicit_done: true });
window.addEventListener("load", function() {
test(function() {
assert_equals(mathScriptLevel("initial"), "0");
assert_equals(mathScriptLevel("initialFrom11"), "0");
}, "Initial value of math-script-level");
test(function() {
assert_equals(mathScriptLevel("inherited11"), "11");
assert_equals(mathScriptLevel("inherited-7"), "-7");
}, "Inherited values of math-script-level");
test(function() {
assert_equals(mathScriptLevel("inherited9specifiedAutoInline"), "10");
assert_equals(mathScriptLevel("inherited9specifiedAutoDisplay"), "9");
}, "Specified math-script-level: auto");
test(function() {
assert_equals(mathScriptLevel("specified11"), "11");
assert_equals(mathScriptLevel("specified-7"), "-7");
}, "Specified math-script-level: <integer>");
test(function() {
assert_equals(mathScriptLevel("specifiedAdd10From5"), "15");
assert_equals(mathScriptLevel("specifiedAdd-15From5"), "-10");
}, "Specified math-script-level: add(<integer>)");
done();
});
</script>
</head>
<body>
<div id="log"></div>
<div id="initial"></div>
<div id="specified11" style="math-script-level: 11">
<div id="initialFrom11" style="math-script-level: initial"></div>
<div id="inherited11"></div>
</div>
<div id="specified-7" style="math-script-level: -7">
<div id="inherited-7"></div>
</div>
<div style="math-script-level: 9">
<div style="math-style: inline">
<div id="inherited9specifiedAutoInline" style="math-script-level: auto" ></div>
</div>
<div style="math-style: display">
<div id="inherited9specifiedAutoDisplay" style="math-script-level: auto" ></div>
</div>
</div>
<div style="math-script-level: 5">
<div id="specifiedAdd10From5" style="math-script-level: add(10)"></div>
<div id="specifiedAdd-15From5" style="math-script-level: add(-15)"></div>
</div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
<!DOCTYPE html>
<html>
<head>
<title>math-script-level</title>
<meta charset="utf-8">
<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/3746">
<meta name="assert" content="Verify effect of math-script-level auto | add(<integer>) | <integer>, starting from different values of math-script-level.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
.container {
/* Ahem font does not have a MATH table so the font-size scale factor
is always 0.71^{computed - inherited math script level} */
font: 20px/1 Ahem;
}
</style>
<script>
function fontSize(id) {
return parseFloat((/(.+)px/).exec(getComputedStyle(document.getElementById(id)).getPropertyValue("font-size"))[1]);
}
setup({ explicit_done: true });
window.addEventListener("load", function() {
test(function() {
assert_equals(fontSize("autoDisplay"), 200);
assert_equals(fontSize("autoInline"), 355);
}, "auto");
test(function() {
assert_equals(fontSize("autoDisplayFrom7"), 200);
assert_equals(fontSize("autoInlineFrom7"), 355);
}, "auto ; starting from level 7");
test(function() {
assert_equals(fontSize("add0"), 200);
assert_equals(fontSize("add-1"), 100);
assert_equals(fontSize("add1"), 355);
assert_approx_equals(fontSize("add-2"), 397, 1);
assert_approx_equals(fontSize("add2"), 504, 1);
assert_approx_equals(fontSize("add-9"), 654, 1);
assert_approx_equals(fontSize("add9"), 92, 1);
}, "add(<integer>)");
test(function() {
assert_equals(fontSize("add0from3"), 200);
assert_equals(fontSize("add-1from3"), 100);
assert_equals(fontSize("add1from3"), 355);
assert_approx_equals(fontSize("add-2from3"), 397, 1);
assert_approx_equals(fontSize("add2from3"), 504, 1);
assert_approx_equals(fontSize("add-9from3"), 654, 1);
assert_approx_equals(fontSize("add9from3"), 92, 1);
}, "add(<integer>) ; starting from level 3");
test(function() {
assert_equals(fontSize("set0"), 200);
assert_equals(fontSize("set-1"), 100);
assert_equals(fontSize("set1"), 355);
assert_approx_equals(fontSize("set-2"), 397, 1);
assert_approx_equals(fontSize("set2"), 504, 1);
assert_approx_equals(fontSize("set-9"), 654, 1);
assert_approx_equals(fontSize("set9"), 92, 1);
}, "<integer>");
test(function() {
assert_equals(fontSize("set50"), 200);
assert_equals(fontSize("set49"), 100);
assert_equals(fontSize("set51"), 355);
assert_approx_equals(fontSize("set48"), 397, 1);
assert_approx_equals(fontSize("set52"), 504, 1);
assert_approx_equals(fontSize("set41"), 654, 1);
assert_approx_equals(fontSize("set59"), 92, 1);
}, "<integer> ; starting from level 50");
done();
});
</script>
</head>
<body>
<div id="log"></div>
<div>
<div class="container">
<div>
<div style="font-size: 200px; math-style: display">
<div id="autoDisplay" style="math-script-level: auto"></div>
</div>
<div style="font-size: 500px; math-style: inline">
<div id="autoInline" style="math-script-level: auto"></div>
</div>
</div>
<div>
<div style="font-size: 200px; math-style: display; math-script-level: 7">
<div id="autoDisplayFrom7" style="math-script-level: auto"></div>
</div>
<div style="font-size: 500px; math-style: inline; math-script-level: 7">
<div id="autoInlineFrom7" style="math-script-level: auto"></div>
</div>
</div>
<div>
<div style="font-size: 200px">
<div id="add0" style="math-script-level: add(0)"></div>
</div>
<div style="font-size: 71px">
<div id="add-1" style="math-script-level: add(-1)"></div>
</div>
<div style="font-size: 500px">
<div id="add1" style="math-script-level: add(1)"></div>
</div>
<div style="font-size: 200px">
<div id="add-2" style="math-script-level: add(-2)"></div>
</div>
<div style="font-size: 1000px">
<div id="add2" style="math-script-level: add(2)"></div>
</div>
<div style="font-size: 30px">
<div id="add-9" style="math-script-level: add(-9)"></div>
</div>
<div style="font-size: 2000px">
<div id="add9" style="math-script-level: add(9)"></div>
</div>
</div>
<div>
<div style="font-size: 200px; math-script-level: 3;">
<div id="add0from3" style="math-script-level: add(0)"></div>
</div>
<div style="font-size: 71px; math-script-level: 3;">
<div id="add-1from3" style="math-script-level: add(-1)"></div>
</div>
<div style="font-size: 500px; math-script-level: 3;">
<div id="add1from3" style="math-script-level: add(1)"></div>
</div>
<div style="font-size: 200px; math-script-level: 3;">
<div id="add-2from3" style="math-script-level: add(-2)"></div>
</div>
<div style="font-size: 1000px; math-script-level: 3;">
<div id="add2from3" style="math-script-level: add(2)"></div>
</div>
<div style="font-size: 30px; math-script-level: 3;">
<div id="add-9from3" style="math-script-level: add(-9)"></div>
</div>
<div style="font-size: 2000px; math-script-level: 3;">
<div id="add9from3" style="math-script-level: add(9)"></div>
</div>
</div>
<div>
<div style="font-size: 200px">
<div id="set0" style="math-script-level: 0"></div>
</div>
<div style="font-size: 71px">
<div id="set-1" style="math-script-level: -1"></div>
</div>
<div style="font-size: 500px">
<div id="set1" style="math-script-level: 1"></div>
</div>
<div style="font-size: 200px">
<div id="set-2" style="math-script-level: -2"></div>
</div>
<div style="font-size: 1000px">
<div id="set2" style="math-script-level: 2"></div>
</div>
<div style="font-size: 30px">
<div id="set-9" style="math-script-level: -9"></div>
</div>
<div style="font-size: 2000px">
<div id="set9" style="math-script-level: 9"></div>
</div>
</div>
</div>
<div>
<div style="font-size: 200px; math-script-level: 50">
<div id="set50" style="math-script-level: 50"></div>
</div>
<div style="font-size: 71px; math-script-level: 50">
<div id="set49" style="math-script-level: 49"></div>
</div>
<div style="font-size: 500px; math-script-level: 50">
<div id="set51" style="math-script-level: 51"></div>
</div>
<div style="font-size: 200px; math-script-level: 50">
<div id="set48" style="math-script-level: 48"></div>
</div>
<div style="font-size: 1000px; math-script-level: 50">
<div id="set52" style="math-script-level: 52"></div>
</div>
<div style="font-size: 30px; math-script-level: 50">
<div id="set41" style="math-script-level: 41"></div>
</div>
<div style="font-size: 2000px; math-script-level: 50">
<div id="set59" style="math-script-level: 59"></div>
</div>
</div>
</div>
</div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html>
<head>
<title>math-script-level</title>
<meta charset="utf-8">
<style>
.container {
/* Ahem font does not have a MATH table so the font-size scale factor
is always 0.71^{computed - inherited math script level} */
font: 100px/1 Ahem;
}
</style>
</head>
<body>
<p>Test passes if you see two squares of side 100px.</p>
<div class="container">
<div>X</div>
</div>
<br/>
<div class="container">
<div>X</div>
</div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html>
<head>
<title>math-script-level</title>
<meta charset="utf-8">
<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/3746">
<meta name="assert" content="If font-size is specified or if the specified value of math-script-level is initial then math-script-level does not affect the computed value of font-size.">
<link rel="match" href="math-script-level-003.tentative-ref.html">
<style>
.container {
/* Ahem font does not have a MATH table so the font-size scale factor
is always 0.71^{computed - inherited math script level} */
font: 100px/1 Ahem;
}
</style>
</head>
<body>
<p>Test passes if you see two squares of side 100px.</p>
<div class="container" style="math-script-level: 3;">
<div style="math-script-level: 9; font-size: 100px;">X</div>
</div>
<br/>
<div class="container" style="math-script-level: 3;">
<div style="math-script-level: initial;">X</div>
</div>
</body>
</html>
Loading

0 comments on commit 55adb33

Please sign in to comment.