summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/docs/test-templates.md
blob: 3738ebf13eb5c0cd1eba3f7115f6f5b7405401ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
This page contains templates for creating tests. The template syntax
is compatible with several popular editors including TextMate, Sublime
Text, and emacs' YASnippet mode.

Each template is given in two forms, one minimal and one including
[extra metadata](css-metadata.html). Usually the metadata is required
by CSS tests and optional for other tests.

Templates for filenames are also given. In this case `{}` is used to
delimit text to be replaced and `#` represents a digit.

## Reftests

### Minimal Reftest

``` html
<!DOCTYPE html>
<meta charset="utf-8">
<title>${1:Test title}</title>
<link rel="match" href="${2:URL of match}">
<style>
    ${3:Test CSS}
</style>
<body>
    ${4:Test content}
</body>
```

Filename: `{test-topic}-###.html`

### Reftest Including Metadata

``` html
<!DOCTYPE html>
<meta charset="utf-8">
<title>${1:Test area}: ${2:Scope of test}</title>
<link rel="author" title="${3:Author's name}" href="${4:Contact link}">
<link rel="help" href="${5:Link to tested section}">
<link rel="match" href="${6:URL of match}">
<meta name="flags" content="${7:Requirement flags}">
<meta name="assert" content="${8:Description of what you're trying to test}">
<style>
    ${9:Test CSS}
</style>
<body>
    ${10:Test content}
</body>
```

Filename: `{test-topic}-###.html`

### Minimal Reftest Reference:

``` html
<!DOCTYPE html>
<meta charset="utf-8">
<title>${1:Reference title}</title>
<style>
    ${2:Reference CSS}
</style>
<body>
    ${3:Reference content}
</body>
```

Filename: `{description}.html` or `{test-topic}-###-ref.html`

### Reference Including Metadata

``` html
<!DOCTYPE html>
<meta charset="utf-8">
<title>${1:Reference title}</title>
<link rel="author" title="${2:Author's name}" href="${3:Contact link}">
<style>
    ${4:Reference CSS}
</style>
<body>
    ${5:Reference content}
</body>
```

Filename: `{description}.html` or `{test-topic}-###-ref.html`

## testharness.js tests

### Minimal Script Test

``` html
<!DOCTYPE html>
<meta charset="utf-8">
<title>${1:Test title}</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
${2:Test body}
</script>
```

Filename: `{test-topic}-###.html`

### Script Test With Metadata

``` html
<!DOCTYPE html>
<meta charset="utf-8">
<title>${1:Test title}</title>
<link rel="author" title="${2:Author's name}" href="${3:Contact link}">
<link rel="help" href="${4:Link to tested section}">
<meta name="flags" content="${5:Requirement flags}">
<meta name="assert" content="${6:Description of what you're trying to test}">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
${7:Test body}
</script>
```

Filename: `{test-topic}-###.html`

### Manual Test

``` html
<!DOCTYPE html>
<meta charset="utf-8">
<title>${1:Test title}</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
setup({explicit_timeout: true});
${2:Test body}
</script>
```

Filename: `{test-topic}-###-manual.html`