Skip to content

Commit

Permalink
Reland "FontAccess: Sort fonts in lexicographical order"
Browse files Browse the repository at this point in the history
This is a reland of 404b7cc426e259c11276d673630c9f094628259f

The original CL failed some tests because the code assumes that
platform-specific APIs called returned unique data. This was a false
assumption.

This reland follows another CL: https://crrev.com/c/2438875, which
ensures that fonts are not duplicated.

Original change's description:
> FontAccess: Sort fonts in lexicographical order
>
> This change ensures fonts are sorted before being cached. This change is
> due to a concern about fingerprinting:
> w3ctag/design-reviews#399 (comment)
>
> This change ensures that fonts are sorted in lexicographical order.
>
> Bug: 1043306
> Change-Id: Ia3acf2a45cb473124df4e489683bdc7bac15dde4
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2427040
> Commit-Queue: Olivier Yiptong <[email protected]>
> Reviewed-by: Joshua Bell <[email protected]>
> Cr-Commit-Position: refs/heads/master@{#810519}

Bug: 1043306
Change-Id: Ic3d70744661a838d82349c017a1cb0e8c23a3654
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2432815
Commit-Queue: Olivier Yiptong <[email protected]>
Reviewed-by: Joshua Bell <[email protected]>
Cr-Commit-Position: refs/heads/master@{#812965}
GitOrigin-RevId: 20b437f14f2d7abc556a00e1486aa95b15fc77e6
  • Loading branch information
oyiptong authored and Copybara-Service committed Oct 1, 2020
1 parent dba2489 commit 3eb4fb3
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,32 @@ font_access_test(async t => {

assert_fonts_exist(availableFonts, getEnumerationTestSet());
}, 'query(): standard fonts returned');

font_access_test(async t => {
const iterator = navigator.fonts.query();

if (!isPlatformSupported()) {
await promise_rejects_dom(t, 'NotSupportedError', (async () => {
for await (const f of iterator) {
}
})());
return;
}

// The following tests that fonts are sorted. Postscript names are expected to
// be encoded in a subset of the ASCII character set.
// See: https://docs.microsoft.com/en-us/typography/opentype/spec/name
// Should the Postscript name contain characters that are multi-byte, this
// test may erroneously fail.
let previousFont = null;
for await (const font of iterator) {
if (previousFont) {
assert_true(
previousFont.postscriptName < font.postscriptName,
`font is not in expected order. expected: ${
previousFont.postscriptName} < ${font.postscriptName}`);
}

previousFont = font;
}
}, 'query(): fonts are sorted');

0 comments on commit 3eb4fb3

Please sign in to comment.