Skip to content

Commit

Permalink
Update Mac trak table test to SFNSText on Mac OS 10.13
Browse files Browse the repository at this point in the history
Disable the test for older Mac OS as we can't maintain multiple
versions.

Bug: 817930
Change-Id: I42d7cc1c84e0e02618b69fddcab7c73f93396c1c
Reviewed-on: https://chromium-review.googlesource.com/945729
Reviewed-by: Koji Ishii <kojii@chromium.org>
Commit-Queue: Dominik Röttsches <drott@chromium.org>
Cr-Commit-Position: refs/heads/master@{#540492}
  • Loading branch information
drott authored and Commit Bot committed Mar 2, 2018
1 parent 48526a7 commit a013693
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 43 deletions.
3 changes: 2 additions & 1 deletion third_party/WebKit/LayoutTests/NeverFixTests
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ fast/harness/results.html [ WontFix ]
[ Win Linux ] fast/dom/partial-layout-overlay-scrollbars.html [ WontFix ]

# Tests trak table support / letter spacing specific to Mac system font
[ Win Linux Android Mac10.10 Mac10.11 ] fast/text/mac-system-ui-trak.html [ WontFix ]
# Only maintain this for latest Mac OS
[ Win Linux Android Mac10.10 Mac10.11 Mac10.12 ] fast/text/mac-system-ui-trak.html [ WontFix ]

# Mac's popup behavior is different.
[ Mac ] fast/forms/select/menulist-onchange-fired-with-key-up-down.html [ WontFix ]
Expand Down
2 changes: 0 additions & 2 deletions third_party/WebKit/LayoutTests/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -1699,8 +1699,6 @@ crbug.com/803200 external/wpt/websockets/opening-handshake/005.html?wss [ Pass F

crbug.com/805463 external/wpt/acid/acid3/numbered-tests.html [ Skip ]

crbug.com/817930 [ Mac10.13 ] fast/text/mac-system-ui-trak.html [ Failure ]

# ====== New tests from wpt-importer added here ======
crbug.com/626703 [ Android ] external/wpt/bluetooth/requestDevice/canonicalizeFilter/no-arguments.https.html [ Crash ]
crbug.com/626703 external/wpt/css/css-text/line-break/line-break-strict-018b.xht [ Failure ]
Expand Down
101 changes: 61 additions & 40 deletions third_party/WebKit/LayoutTests/fast/text/mac-system-ui-trak.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,48 +9,69 @@
</style>
<div id="testDivs"></div>
<script>
setup({ explicit_done: true });
test(function() {
setup({
explicit_done: true
});

for (var i = 10; i < 120; i += 10) {
containerDiv = document.createElement('div');
el = document.createElement('span');
el.classList += "macsystemfont";
el.style.fontSize = i + "px";
el.appendChild(document.createTextNode('YouWebTorrentVa'));
containerDiv.appendChild(el);
testDivs.appendChild(containerDiv);
}
test(function() {

// Width to font size ratios from Safari for ".SF NS Text". If the ratio
// is not constant, this means letter spacing is not linearly changing
// with font size, which means varying tracking is applied. At font sizes
// above 78px, the tracking table ends and values become constant again.
var expectedRatios = [ 11.358723958333334,
10.4921875,
10.375,
10.31640625,
10.267578125,
10.208984375,
10.16015625,
10.130859375,
10.130859375,
10.130859375,
10.130859375,
10.130859375 ];
// SFNSText's trak table cutoff boundaries are as follow, let's measure width to
// font size ratio at these font sizes.
// We expect to observe a non linear increase in width, due to tracking.
var trakTableFontSizes = [6.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0,
16.0, 17.0, 20.0, 22.0, 28.0, 32.0, 36.0, 50.0, 64.0, 80.0, 100.0, 138.0 ];

var theDivs = document.querySelectorAll(".macsystemfont");
assert_equals(theDivs.length, 11);
var kCssPixelsPerPoint = 96 / 72;
for (oneDiv of theDivs) {
var fontSize = parseFloat(getComputedStyle(oneDiv)['fontSize'],10);
var width = oneDiv.getBoundingClientRect().width;
var ptSize = fontSize / kCssPixelsPerPoint;
var ratio = width/ptSize;
var expectation = expectedRatios[fontSize / 10 - 1];
assert_less_than(Math.abs(ratio - expectation), 0.01);
}
testDivs.style.display = "none";
}, "Font size to width ratio should match Safari and stay constant above 78px, according to the font's trak table.");
for (var i = 0; i < trakTableFontSizes.length; i++) {
containerDiv = document.createElement('div');
el = document.createElement('span');
el.classList += "macsystemfont";
el.style.fontSize = trakTableFontSizes[i] + "px";
el.appendChild(document.createTextNode('YouWebTorrentVa'));
containerDiv.appendChild(el);
testDivs.appendChild(containerDiv);
}

// Width to font size ratios from Safari for ".SF NS Text". If the ratio
// is not constant, this means letter spacing is not linearly changing
// with font size, which means varying tracking is applied. At font sizes
// above 78px, the tracking table ends and values become constant again.
var expectedRatios = [11.873046875,
11.443359375,
11.306640625,
11.189453125,
11.072265625,
10.955078125,
10.857421875,
10.759765625,
10.681640625,
10.61328125,
10.159505208333334,
10.110677083333334,
10.052083333333334,
10.032552083333334,
10.013020833333334,
9.934895833333334,
9.856770833333334,
9.798177083333334,
9.798177083333334,
9.798177083333334
];

var theDivs = document.querySelectorAll(".macsystemfont");
assert_equals(theDivs.length, expectedRatios.length);
var kCssPixelsPerPoint = 96 / 72;
for (var i = 0; i < theDivs.length; ++i) {
var fontSize = parseFloat(getComputedStyle(theDivs[i])[
'fontSize'], 10);
var width = theDivs[i].getBoundingClientRect().width;
var ptSize = fontSize / kCssPixelsPerPoint;
var ratio = width / ptSize;
var expectation = expectedRatios[i];
assert_less_than(Math.abs(ratio - expectation), 0.01);
}
testDivs.style.display = "none";
},
"Font size to width ratio should match Safari and stay constant above 80px, according to the font's trak table."
);
done();
</script>

0 comments on commit a013693

Please sign in to comment.