Please declare your tests as UTF-8

54 views
Skip to first unread message

Henri Sivonen

unread,
Sep 27, 2021, 8:27:47 AM9/27/21
to dev-platform
Short version:

Please remember to declare your test cases as UTF-8 using <meta
charset="utf-8"> as the first child of <head> unless you are
specifically intending to test legacy encoding behavior.

Long version:

Even if a test case is all-ASCII, there are still operations that are
sensitive to what the encoding of the document is. Notably, when an
external style sheet doesn't have an encoding declaration of its own,
it inherits from the document. For speculative CSS parsing, we assume
the modern happy case: UTF-8. However, for legacy reasons, undeclared
ASCII-only HTML ends up as windows-1252, which is not UTF-8 for CSS
inheritance purposes.

Due to https://bugzilla.mozilla.org/show_bug.cgi?id=1727750 we not
only reparse but refetch on the unhappy case where the speculatively
inherited encoding doesn't match the time-of-use inherited encoding.

If tests that observe either via .sjs or WPT server-side Python or via
window.performance what HTTP requests specifically take place, the
tests may end up seeing something unintended even if they were written
with the assumption that encoding declarations don't matter when
everything is ASCII.

Since newly-authored content these days is UTF-8, it makes sense to
test the UTF-8 scenario for new features.

--
Henri Sivonen
hsiv...@mozilla.com
Reply all
Reply to author
Forward
0 new messages