====== Test Format ======
This page describes the test format. The requirements are explained below; to make things easier we've also provided a template that you can copy.
The recommended structure for CSS tests is a [[test:selftest|self-describing]] [[test:reftest|reftest]]. If it's possible for a test to be a [[test:reftest|reftest]], it must be a reftest. (We prefer reftests to also be self-describing or otherwise easy for humans to interpret, but this is not a requirement.)
Additional guidelines on designing the content of the test can be found in the [[http://www.w3.org/Style/CSS/Test/guidelines.html|CSS2.1 Test Case Authoring Guidelines]].
===== Template for New Tests =====
The submission format for CSS2.1 tests is XHTML in UTF-8. Images must be in PNG format. A set of scripts will generate the various formats from this source version. Tests must be //valid// XHTML, so please [[http://validator.w3.org/|validate your tests]] before submission.
A template for new tests follows. Copy and paste the code below into a new file or save {{test:css2.1:test-topic-000.xht|this template file}} and replace the capitalized parts as described below.
===== Template Details =====
==== Title element ====
The title appears in the generated index, so make sure it is //concise//, //unique// and //descriptive//. The role of the title is to identify what specific detail of a feature or combination of features is being tested, so that someone looking through an index can see quickly what's tested in which file. In most cases, this description should not require more than 5 or 6 words. There is no need to provide the chapter or section in the title.
We have 100+ tests on "Border Conflict Resolution".
Good example:
Credits provide a way to identify the person or organization that created the test and/or holds copyright in the test. This is useful for reviewing purposes and for asking questions about the individual test. A test can have multiple author credits if necessary.
Example 2:
Example 3:
If a test has passed review, then the reviewer should note this by adding his or her name as a reviewer, along with the date of the review. A test can have multiple reviewers if necessary. A reviewer must be a person, not an organization.
Example 2:
This test was written by Bert Bos, then reviewed by Boris Zbarsky, who made some corrections before deeming it acceptable. Those corrections were then reviewed and accepted by Bert Bos.
The specification link elements provide a way to align test with information in the CSS 2.1 specification.
* Links should link to relevant sections within the CSS 2.1 Specification
* Use the anchors from the CSS 2.1 Specification [[http://www.w3.org/TR/CSS21/#toc|Table of Contents]]
* A test can have multiple specification links
* Always list the primary section that is being tested as the first item in the list of specification links
* Order the list from the most used/specific to least used/specific
* There is no need to list common incidental features like the color green if it is being used to validate the test unless the case is specifically testing the color green
* If the test is part of multiple test suites, link to the relevant sections of each spec.
Example 2:
The reference link elements are used in [[test/reftest|reftests]] and provide the list of reference file(s) that the test should be compared to.
* ''match'' references must be files that render identically to the test, but use an alternate means to do so
* Multiple ''match'' references are used when the test can match **any** of the reference files
* If a test requires multiple ''match'' references that all need to match (for example, to catch when a reference fails in the same way the test does), then chain the references together, i.e.: place reference links to the additional ''match'' references in the reference files. It is recommended that the chained reference files form a loop (e.g.: a -> b -> c -> a) so that a test linking to any reference in the chain will find all the references.
* ''mismatch'' references are files that render differently than the test file. A test may have any number of ''mismatch'' references.
* Reference files may be dedicated reference files, images, or other tests
Example 2:
Flags document the test’s prerequisites, for example, the Ahem font, or a paged presentation. Multiple tokens are space separated.
All flags documented elsewhere are deprecated except the following:
^ Token ^ Description ^
| ahem | Requires the [[http://www.w3.org/Style/CSS/Test/Ahem/|Ahem font]] |
| animated | Test is animated in final state. (Cannot be verified using reftests/screenshots.) |
| combo | Test, which must have an unsuffixed filename number, is strictly the union of all the suffixed tests with the same name and number. (See File name format, below.) |
| dom | Requires support for JavaScript and the Document Object Model (DOM) |
| font | Requires a specific font to be installed. (Details must be provided and/or the font linked to in the test description) |
| history | User agent session history is required. Testing '':visited'' is a good example where this may be used. |
| http | Requires HTTP headers |
| HTMLonly | Test case is only valid for HTML |
| image | Requires support for bitmap graphics and the graphic to load |
| interact | Requires human interaction (such as for testing scrolling behavior) |
| invalid | Tests handling of invalid CSS. Note: This case contains CSS properties and syntax that may not validate. |
| namespace | Requires support for XML Namespaces |
| nonHTML | Test case is only valid for formats besides HTML (e.g. XHTML or arbitrary XML) |
| may | Behavior tested is //preferred// but OPTIONAL. %%[%%[[http://www.ietf.org/rfc/rfc2119.txt|RFC2119]]] (These tests must be reviewed by a test suite owner or peer.) |
| paged | Only valid for paged media |
| should | Behavior tested is RECOMMENDED, but not REQUIRED. %%[%%[[http://www.ietf.org/rfc/rfc2119.txt|RFC2119]]] |
| scroll | Only valid for continuous (scrolling) media |
| svg | Requires support for vector graphics (SVG) |
| userstyle | Requires a user style sheet to be set |
| 32bit | Assumes a 32-bit integer as the minimum (-2147483648) or maximum (2147483647) value |
| 96dpi | Assumes 96dpi display |
Example 2 (multiple tokens apply):
Example 3 (no tokens apply):
This element should contain a complete detailed statement expressing what specifically the test is attempting to prove. If the assertion is only valid in certain cases, those conditions should be described in the statement.
The assertion should //not// be:
* A copy of the title text
* A copy of the test verification instructions
* A duplicate of another assertion in the test suite
* A line or reference from the CSS specification unless that line is a complete assertion when taken out of context.
The test assertion is **optional**. It helps the reviewer understand the goal of the test so that he or she can make sure it is being tested correctly. Also, in case a problem is found with the test later, the testing method (e.g. using 'color' to determine pass/fail) can be changed (e.g. to using 'background-color') while preserving the intent of the test (e.g. testing support for ID selectors).
==== Style Element (embedded styles) ====
When creating styles primarily use ID or Class selectors. Inline styles should not be used unless the case is specifically testing this scenario.
==== Script type (embedded script) ====
Some testcases require support for javascript and the Document Object Model (DOM).
Although type="application/javascript" and type="application/ecmascript" are recommended by %%[%%[[http://www.ietf.org/rfc/rfc4329.txt|RFC4329]]], the CSS 2.1 test suite only accepts type="text/javascript".
==== ''body'' Content ====
CONTENT OF TEST
* When creating content use : ''
'', ''''
* Beware! ''
'' has margins by default! * Use other elements only to test the interaction with those elements' features (or other namespaces' features) * Test ''table'' features with both HTML table elements and ''
#user-stylesheet-indication
{
/* Used by the harness to display and indication there is a user style sheet applied */
display: block!important;
}
The rule ''#user-stylesheet-indication'' is to be used by any harness running the test suite.
A harness should identify test that need a user style sheet by looking at their flags meta tag. It then should display appropriate messages indicating if a style sheet is applied or if a style sheet should not be applied.
#userstyle
{
color: green;
display: none;
}
#nouserstyle
{
color: red;
display: none;
}
Harness ''userstyle'' flag found:
A user style sheet is applied.
Harness ''userstyle'' flag NOT found:
A user style sheet is applied.
#cascade /* ID name should match user style sheet file name */
{
/* Used by the test to hide the prerequisite */
display: none;
}
The rule ''#cascade'' in the example above is used by the test page to hid the prerequisite text. The rule name should match the user style sheet CSS file name in order to keep this orderly.
Examples: (code for the cascade-### XHTML files)
PREREQUISITE: The "cascade.css" file is enabled as the user agent's user style sheet.
The ''id'' value should match the user style sheet CSS file name and the user style sheet rule that is used to hide this text when the style sheet is properly applied.