TestPlan20-UserAgent

From Fonts WG

Plan for testing all the assertions which apply to User Agents for WOFF 2.0. All of these can be tested with a web page consisting of content (HTML, SVG), stylesheet (CSS), a WOFF (which may contain errors, for some tests.) and a font that must be installed locally.

Text color highlights on this page are as follows: red text indicates questions that need to be addressed by the Working Group, gray text indicates portions of the test suite that are not yet implemented and blue text indicates initial ideas about how the tests can be presented to User Agents.

Testable Assertions

css3font-available

Testable, needs a master page with two subpages (iframe, etc) one of which references a woff file with @font-face and the other references it just by name. Pass if the second subpage does not use the font. The font needs to have both PASS and FAIL glyphs, one iframe uses PASS and the second uses FAIL.

extraneous-reject

There are four potential locations for extraneous data: between header and table directory, between table data and metadata, between metadata and private data, and after private data. For each the locations where extraneous data could occur, make a test font file. Create one page showing a test string using the WOFF2 font. Fall back to a locally installed font that renders differently than the WOFF2. The string should look like "FAIL" when displayed with the WOFF file (because it must be rejected) and "PASS" when displayed with the locally installed font.

overlap-reject

For each of these, create one page showing a test string in the font. Fall back to a locally installed font that renders differently than the WOFF2. The string should look like "FAIL" when displayed with the WOFF file and "PASS" when displayed with the locally installed font.

mustAccept255UInt16

Create a font with one glyph that says "PASS" and another glyph containing a special purpose outline with the three possible encodings of 506 mentioned in the spec, in a glyph that uses this value in multiple increments, such as a square using relative coordinates, and ensure the UA accepts them all. If the font is accepted, UA will pass the test and the string should look like "PASS" when displayed with the WOFF2 file and "FAIL" when displayed with the locally installed font. This would need to be made with a specially modified font converter.

mustRejectInvalidBase128

Create a font with one glyph that says "FAIL" containing a UintBase128-encoded value with leading zeros (a value that starts with the byte 0x80), which must be rejected.

Create a font with one glyph that says "FAIL" containing a UintBase128-encoded sequence which is longer than 5 bytes, which must be rejected.

Create a font with one glyph that says "FAIL" containing a UintBase128-encoded value exceeds (2^32)-1, which must be rejected.

NOTE: Second and third subtests can only be implemented if the encoded value is not relied upon by the decoder implementations. The only values that are used as a reference only are origLength of the transformed tables; therefore it is possible to create a mal-formatted test font where the original lengths of the transformed tables are modified to exploit incorrect UIntBase128 encoding.

For each of these, create one page showing a test string in the font. Fall back to a locally installed font that renders differently than the WOFF2. The string should look like "FAIL" when displayed with the WOFF file and "PASS" when displayed with the locally installed font.

noMagicNumber-reject

Create a font with invalid header signature field (e.g. "XXXX"). Test is passed if the UA rejects the font

mustNotUseReservedValue

Create two fonts, one with 0 as reserved value and one with some other value. Test passes if both fonts are displayed.

mustNotRejectIncorrectTotalSize

Create two fonts, each with a single glyph that says "PASS", one with "totalSfntSize" value in the WOFF2 Header set to be much smaller than the uncompressed font file size and the other one that has "totalSfntSize" set to very large value. Test passes if both fonts are correctly decoded and the text "PASS" is displayed. (Standard "PASS" / "FAIL" approach using downloaded and fallback fonts.)

NOTE: To avoid changing offsets the easiest way to do this is to create the smallest/largest UIntBase128 of the same length.

mayAcceptKnownTagsAsCustom

Create a font with two known tables using custom tag instead of known table flag. Test passes if the font is correctly decoded and the text "PASS" is displayed. (Standard "PASS" / "FAIL" approach using downloaded and fallback fonts.)

mustAcceptAllTransforms

Create a font file with 'hmtx' and 'glyf' tables that have matching metrics to allow hmtx transform be applied. Produce a WOFF2 file with the all table transforms applied. Test passes if the font is consumed by the UA. (Standard "PASS" / "FAIL" approach using downloaded and fallback fonts.)

mustBeRejected-FailTransform

This case will be covered with two test inputs:

  1. Create an input font file with 'head' table indicating transform number "1" applied - should be rejected.
  2. Create an input font with 'glyf' table indicating transform number "1" applied - should be rejected.

mustCheckRejectMismatchedTables

Create a font collection file with two pairs of 'glyf'/'loca' tables that are not shared. Produce a WOFF2 file with the tables mismatched between two pairs. Test passes if the font is rejected. (Standard "PASS" / "FAIL" approach using downloaded and fallback fonts.)

mustLoadFontCollection

The test itself will be using a valid font collection file with two fonts (e.g. serif and sans), each having a single "PASS" glyph supported. We need to test loading of both fonts within the collection by using an appropriate test content to make sure that the font collection file is properly parsed; however we'd have to rely on CSS fragment identifier to be supported to make sure that both fonts can be selected properly.

mustRejectExtraData

Run this test using the same font file that was created for font format test that has extraneous binary data inserted in the compressed data stream. Test passes if the font is rejected.

mustBeInvalidated-FailDecompress

Create three tests. One has garbage instread of Brotli. One starts as Brotli but is then corrupt. the third says it is Brotli but is in fact gzip. All must be rejected to pass.

mustBeInvalidated-FailSize

Create a font , then edit some of the lengths defined in an untransformed table in the directory so they no longer match the actual compressed data. Test passes if the font is rejected.

Create a font , then edit some of the lengths defined in an transformed table in the directory so they no longer match the actual compressed data. Test passes if the font is rejected.

mustNotRejectGlyfSizeMismatch

  1. Create two fonts (each containing a glyph that says "PASS" and a number of additional glyphs), one with UIntBase128 "origLength" value in the 'glyf' table entry of WOFF2 Table Directory set to be smaller possible value (utilizing the same number of UIntBase128 bytes) than the actual table size and the other one that has "origLength" set to largest possible UIntBase128 value. Test passes if both fonts are correctly decoded and the text "PASS" is displayed. [For this test to work, the encoded 'glyf' table MUST be transformed with optimizing transform; otherwise, the test files will fail the previously defined "mustBeInvalidated-FailSize" test.]
  2. Create a fonts with one glyph that says "PASS" and a number of '0-contour' glyphs, each of them represented with a glyph table entry containing numContours and bounding box values (xMin, xMax, yMin and yMax) all equal to '0'. [For this test to work, the encoded 'glyf' table MUST be transformed with optimizing transform. Upon decoding, all '0-contour' glyph records will be replaced with empty glyph entries resulting in a reconstructed glyph table of much smaller size (losing 10 bytes per every original '0-contour' glyph entry).] Test passes if a font is correctly decoded and the text "PASS" is displayed.
    (Standard "PASS" / "FAIL" approach using downloaded and fallback fonts.)

mustCalculateBBox

Create a font with a single PASS glyphs, which has no bbox, so it has to be recalculated for the glyph to be displayed.

mustRejectNoCompositeBBox

Create a font with a single composite glyph which says FAIL, with no bounding box, and individual F A I L which are just used to make the composite. Test passes if the font is rejected.

mustRejectNonEmptyBBox2

Create a font with a single FAIL glyph, compress with an instrumented WOFF2 encoder that adds e.g. a <space> character with non-empty BBOX. Test passes if the font is not used.

mustRejectLoca

Create a font with non-zero loca transformLength.
Create a font with loca origLength smaller than the calculated size.
Create a font with loca origLength bigger than the calculated size.
In all three cases, the WOFF2 font should be rejected and the local fallback font should be used as "PASS" indicator.

mustReconstructLoca

Create a font with three simple glyphs 'A', 'P' and 'S', and a composite glyph that says "PASS". If a font is properly constructed and not rejected the test result will say "PASS". The assumption is that font is good and that 'loca' table is reconstructed properly if all four glyphs in a font have properly calculated offsets that allow the font rendering engine to create a composite glyph using three simple glyphs.

mustCheckLSBFlags

This case will be covered with three test inputs:

  1. Create an input woff2 font file with transformed 'hmtx' table indicating a valid transform number "1" applied where the transform Flags field indicates a valid transform (as applicable) - should be accepted.
  2. Create an input woff2 font file with transformed 'hmtx' table indicating a valid transform number "1" applied where the transform Flags field indicates an invalid transform (with non-zero reserved bits) - should be rejected.
  3. Create an input woff2 font file with transformed 'hmtx' table indicating a valid transform number "1" applied where the transform Flags field indicates an invalid transform (with all Flags bits set to zero) - should be rejected.

(Standard "PASS" / "FAIL" approach using downloaded and fallback fonts.)

metadata-noeffect

Two tests, one with metadata and one without. For each, create one page showing a test string in the font. Fall back to a locally installed font that renders differently than the WOFF. The string should look like "PASS" when displayed with the WOFF file and "FAIL" when displayed with the locally installed font.

private-noeffect

Two tests, one with private and one without. For each, create one page showing a test string in the font. Fall back to a locally installed font that renders differently than the WOFF. The string should look like "PASS" when displayed with the WOFF file and "FAIL" when displayed with the locally installed font.