summaryrefslogtreecommitdiffstats
path: root/tkhtml1/tests/html3.test
blob: f804f56954527346f11089758491c0cea1b86fe7 (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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
#
# Test script for the Tk HTML widget
#
wm withdraw .
if {[lsearch [namespace children] ::tcltest] == -1} {
  source [file dirname $argv0]/engine.tcl
  namespace import ::tcltest::*
}

::tcltest::test html-3.1 {Check the HTML parser for sanity} {
  set h [tkhtml_test_widget]
  $h clear
  $h parse "<p align=center>Test1 \nEnd\n"
  $h token list 1.0 end
} {0 {{Markup p align center} {Text Test1} {Space 1 1} {Text End} {Space 1 1}}}

::tcltest::test html-3.2 {Check that markup arguments are parsed correctly} {
  set h [tkhtml_test_widget]
  $h clear
  $h parse {<p align="center" id='"5"' id2 = "'4'">}
  $h token list 1.0 end
} {0 {{Markup p align center id {"5"} id2 '4'}}}

::tcltest::test html-3.3 {Check that comments are ignored} {
  set h [tkhtml_test_widget]
  $h clear
  $h parse {<p><!-- This is comment --></p>}
  $h token list 1.0 end
} {0 {{Markup p} {Markup /p}}}

::tcltest::test html-3.4 {Check that entities are resolved} {
  set h [tkhtml_test_widget]
  $h clear
  $h parse {&amp;&nbsp;&lt;&gt;&#72;<p>}
  $h token list 1.0 end
} {0 {{Text {& <>H}} {Markup p}}}

::tcltest::test html-3.5 {Check that spacing is recorded properly} {
  set h [tkhtml_test_widget]
  $h clear
  $h parse "<pre>\n\tHi\tThere\n</pre>"
  $h token list 1.0 end
} {0 {{Markup pre} {Space 1 1} {Space 8 0} {Text Hi} {Space 6 0} {Text There} {Space 1 1} {Markup /pre}}}

::tcltest::test html-3.6 {Script markup should become a single token} {
  set h [tkhtml_test_widget]
  $h clear
  $h parse "<script>Contents of script are not tokenized</script>\n"
  $h token list 1.0 end
} {0 {{Markup script} {Space 1 1}}}

::tcltest::test html-3.6b {Style markup should become a single token} {
  set h [tkhtml_test_widget]
  $h clear
  $h parse "<style>Contents of style are not tokenized</style>\n"
  $h token list 1.0 end
} {0 {{Markup style} {Space 1 1}}}

::tcltest::test html-3.7 {All markup within listing is normal text} {
  set h [tkhtml_test_widget]
  $h clear
  $h parse "<listing><p>Hello</p></listing>\n"
  $h token list 1.0 end
} {0 {{Markup listing} {Text <p>Hello} {Text </p>} {Markup /listing} {Space 1 1}}}

::tcltest::test html-3.8 {All markup within xmp is normal text} {
  set h [tkhtml_test_widget]
  $h clear
  $h parse "<xmp><p>Hello</p></xmp>\n"
  $h token list 1.0 end
} {0 {{Markup xmp} {Text <p>Hello} {Text </p>} {Markup /xmp} {Space 1 1}}}

::tcltest::test html-3.9 {All markup within textarea is treated as normal
text. This is not valid HTML, but it is what Netscape does.} {
  set h [tkhtml_test_widget]
  $h clear
  $h parse "<textarea><p>Hello</p></textarea>\n"
  $h token list 1.0 end
} {0 {{Markup textarea} {Text <p>Hello} {Text </p>} {Markup /textarea} {Space 1 1}}}

::tcltest::test html-3.10 {All markup after plaintext become normal text} {
  set h [tkhtml_test_widget]
  $h clear
  $h parse "<plaintext><p>Hello</p></plaintext>\n"
  $h token list 1.0 end
} {0 {{Markup plaintext} {Text <p>Hello} {Text </p>} {Text </plaintext>} {Space 1 1}}}

::tcltest::test html-3.11 {Unrecognized markup is ignored} {
  set h [tkhtml_test_widget]
  $h clear
  $h parse "<unknown>Text\n"
  $h token list 1.0 end
} {0 {{Text Text} {Space 1 1}}}

::tcltest::test html-3.12 {Entities are resolved within markup arguments} {
  set h [tkhtml_test_widget]
  $h clear
  $h parse {<p id="&lt;hi&gt;">}
  $h token list 1.0 end
} {0 {{Markup p id <hi>}}}

::tcltest::test html-3.13 {Entites are resolved within markup arguments} {
  set h [tkhtml_test_widget]
  $h clear
  $h parse {<p id=&lt;hi&gt;>}
  $h token list 1.0 end
} {0 {{Markup p id <hi>}}}

::tcltest::test html-3.14 {White space within markup is ignored} {
  set h [tkhtml_test_widget]
  $h clear
  $h parse {<br >}
  $h token list 1.0 end
} {0 {{Markup br}}}

::tcltest::test html-3.15 {Whitespace within markup is ignored} {
  set h [tkhtml_test_widget]
  $h clear
  $h parse {<br id = 5>}
  $h token list 1.0 end
} {0 {{Markup br id 5}}}

::tcltest::test html-3.16 {Whitespace in markup is ignored} {
  set h [tkhtml_test_widget]
  $h clear
  $h parse {<br id = 5 >}
  $h token list 1.0 end
} {0 {{Markup br id 5}}}

::tcltest::test html-3.17 {Whitespace in markup is ignored} {
  set h [tkhtml_test_widget]
  $h clear
  $h parse {<br id =5>}
  $h token list 1.0 end
} {0 {{Markup br id 5}}}

::tcltest::test html-3.18 {Whitespace in markup is ignored} {
  set h [tkhtml_test_widget]
  $h clear
  $h parse {<br id= 5 >}
  $h token list 1.0 end
} {0 {{Markup br id 5}}}

::tcltest::test html-3.19 {Whitespace in markup is ignored, except when quoted} {
  set h [tkhtml_test_widget]
  $h clear
  $h parse {<br id= " 5 " >}
  $h token list 1.0 end
} {0 {{Markup br id { 5 }}}}

::tcltest::test html-3.20 {Tabs in markup are treated like whitespace} {
  set h [tkhtml_test_widget]
  $h clear
  $h parse "<br id\t=\t' 5 '\t>"
  $h token list 1.0 end
} {0 {{Markup br id { 5 }}}}

::tcltest::test html-3.21 {Newlines in  markup are treated like whitespace} {
  set h [tkhtml_test_widget]
  $h clear
  $h parse "<br id\n=\n\" 5 \"\n>"
  $h token list 1.0 end
} {0 {{Markup br id { 5 }}}}

::tcltest::test html-3.22 {Markup arguments without values} {
  set h [tkhtml_test_widget]
  $h clear
  $h parse "<br clear >"
  $h token list 1.0 end
} {0 {{Markup br clear {}}}}

::tcltest::test html-3.23 {Markup arguments without values} {
  set h [tkhtml_test_widget]
  $h clear
  $h parse "<br clear id=9>"
  $h token list 1.0 end
} {0 {{Markup br clear {} id 9}}}

::tcltest::test html-3.24 {XHTML style / at the end of markup} {
  set h [tkhtml_test_widget]
  $h clear
  $h parse {<br clear="both"/>}
  $h token list 1.0 end
} {0 {{Markup br clear both}}}

::tcltest::test html-3.25 {XHTML style / at the end of markup} {
  set h [tkhtml_test_widget]
  $h clear
  $h parse {<br />}
  $h token list 1.0 end
} {0 {{Markup br}}}

::tcltest::test html-3.26 {XHTML style / at the end of markup} {
  set h [tkhtml_test_widget]
  $h clear
  $h parse {<br/>}
  $h token list 1.0 end
} {0 {{Markup br}}}

::tcltest::test html-3.27 {/ At the end of markup adds a second token} {
  set h [tkhtml_test_widget]
  $h clear
  $h parse {<p />}
  $h token list 1.0 end
} {0 {{Markup p} {Markup /p}}}

::tcltest::test html-3.28 {/ at the end of markup adds a second token} {
  set h [tkhtml_test_widget]
  $h clear
  $h parse {<p/>}
  $h token list 1.0 end
} {0 {{Markup p} {Markup /p}}}

::tcltest::test html-3.29 {/ not at the end of markup still work} {
  set h [tkhtml_test_widget]
  $h clear
  $h parse "<A href=\"\" /privacy.html=\"/privacy.html\">\n"
  $h token list 1.0 end
} {0 {{Markup a href {} /privacy.html /privacy.html} {Space 1 1}}}

::tcltest::test html-3.30 {Incremental parsing} {
  set h [tkhtml_test_widget]
  $h clear
  set txt {<a href="" /privacy.html="none"/>Hello&amp;<p>}
  set len [string length $txt]
  for {set i 0} {$i<$len} {incr i} {
    $h parse [string index $txt $i]
  }
  $h token list 1.0 end
} {0 {{Markup a href {} /privacy.html none} {Markup /a} {Text Hello&} {Markup p}}}

::tcltest::test html-3.31 {Searching for anchors} {
  set h [tkhtml_test_widget]
  $h clear
  $h parse {
    <a name="one">One</a>
    <a id="two">Two</a>
    <a href="three">Three</a>
    <a name="four" id="vier">Four</a>
  }
  update
  $h names
} {0 {one two four}}