001: /*
002: * Java HTML Tidy - JTidy
003: * HTML parser and pretty printer
004: *
005: * Copyright (c) 1998-2000 World Wide Web Consortium (Massachusetts
006: * Institute of Technology, Institut National de Recherche en
007: * Informatique et en Automatique, Keio University). All Rights
008: * Reserved.
009: *
010: * Contributing Author(s):
011: *
012: * Dave Raggett <dsr@w3.org>
013: * Andy Quick <ac.quick@sympatico.ca> (translation to Java)
014: * Gary L Peskin <garyp@firstech.com> (Java development)
015: * Sami Lempinen <sami@lempinen.net> (release management)
016: * Fabrizio Giustina <fgiust at users.sourceforge.net>
017: *
018: * The contributing author(s) would like to thank all those who
019: * helped with testing, bug fixes, and patience. This wouldn't
020: * have been possible without all of you.
021: *
022: * COPYRIGHT NOTICE:
023: *
024: * This software and documentation is provided "as is," and
025: * the copyright holders and contributing author(s) make no
026: * representations or warranties, express or implied, including
027: * but not limited to, warranties of merchantability or fitness
028: * for any particular purpose or that the use of the software or
029: * documentation will not infringe any third party patents,
030: * copyrights, trademarks or other rights.
031: *
032: * The copyright holders and contributing author(s) will not be
033: * liable for any direct, indirect, special or consequential damages
034: * arising out of any use of the software or documentation, even if
035: * advised of the possibility of such damage.
036: *
037: * Permission is hereby granted to use, copy, modify, and distribute
038: * this source code, or portions hereof, documentation and executables,
039: * for any purpose, without fee, subject to the following restrictions:
040: *
041: * 1. The origin of this source code must not be misrepresented.
042: * 2. Altered versions must be plainly marked as such and must
043: * not be misrepresented as being the original source.
044: * 3. This Copyright notice may not be removed or altered from any
045: * source or altered source distribution.
046: *
047: * The copyright holders and contributing author(s) specifically
048: * permit, without fee, and encourage the use of this source code
049: * as a component for supporting the Hypertext Markup Language in
050: * commercial products. If you use this source code in a product,
051: * acknowledgment is not required but would be appreciated.
052: *
053: */
054: package org.w3c.tidy;
055:
056: /**
057: * Testcase for Tidy resolved bugs (Tidy warning and errors).
058: * <p>
059: * see <code>http://sourceforge.net/support/tracker.php?aid=(item number)</code>
060: * </p>
061: * @author fgiust
062: * @version $Revision: 1.16 $ ($Author: fgiust $)
063: */
064: public class TidyWarningBugsTest extends TidyTestCase {
065:
066: /**
067: * Instantiate a new Test case.
068: * @param name test name
069: */
070: public TidyWarningBugsTest(String name) {
071: super (name);
072: }
073:
074: /**
075: * test for Tidy [427810] : Proprietary elements not reported as err.
076: * @throws Exception any exception generated during the test
077: */
078: public void test427810() throws Exception {
079: // line 1 column 1 - Warning: missing <!DOCTYPE> declaration
080: // line 8 column 1 - Warning: <blink> is not approved by W3C
081: // line 9 column 1 - Warning: <wbr> is not approved by W3C
082: // line 10 column 1 - Warning: <nobr> is not approved by W3C
083: // Info: Document content looks like HTML Proprietary
084: // 4 warnings, 0 errors were found!
085:
086: executeTidyTest("427810.html");
087: assertWarnings(4);
088: }
089:
090: /**
091: * test for Tidy [431874] : Nested anchors not detected.
092: * @throws Exception any exception generated during the test
093: */
094: public void test431874() throws Exception {
095: executeTidyTest("431874.html");
096: assertWarnings(2);
097: }
098:
099: /**
100: * test for Tidy [427827] : Nested anchor elements allowed.
101: * @throws Exception any exception generated during the test
102: */
103: public void test427827() throws Exception {
104: // line 6 column 1 - Warning: missing </a> before <a>
105: // line 7 column 6 - Warning: discarding unexpected </a>
106: // 2 warnings, 0 errors were found!
107:
108: executeTidyTest("427827.html");
109: assertWarnings(2);
110: }
111:
112: /**
113: * test for Tidy [427834] : Warning given for newline in DOCTYPE.
114: * @throws Exception any exception generated during the test
115: */
116: public void test427834() throws Exception {
117: // no warnings
118: executeTidyTest("427834.html");
119: assertNoWarnings();
120: }
121:
122: /**
123: * test for Tidy [427844] : End tags containing whitespace warning.
124: * @throws Exception any exception generated during the test
125: */
126: public void test427844() throws Exception {
127: executeTidyTest("427844.html");
128:
129: assertNoWarnings();
130: }
131:
132: /**
133: * test for Tidy [431719] : Spec want "HTML 3.2 Final", but everyone in the world, including Tidy, uses "HTML 3.2".
134: * So the software has to recognize both FPI's as equivalent.
135: * @throws Exception any exception generated during the test
136: */
137: public void test431719() throws Exception {
138: // line 11 column 3 - Warning: <table> lacks "summary" attribute
139: // Info: Doctype given is "-//W3C//DTD HTML 3.2//EN"
140: // Info: Document content looks like HTML 3.2
141: // 1 warning, 0 errors were found!
142:
143: // still bad in tidy?
144:
145: executeTidyTest("431719.html");
146: assertNoWarnings();
147: }
148:
149: /**
150: * test for Tidy [431883] : Given doctype reported incorrectly.
151: * @throws Exception any exception generated during the test
152: */
153: public void test431883() throws Exception {
154: executeTidyTest("431883.html");
155:
156: assertLogContains("Doctype given is \"-//W3C//DTD HTML 4.0");
157: }
158:
159: /**
160: * test for Tidy [431956] : Well formed XSL xsl:text gives error.
161: * @throws Exception any exception generated during the test
162: */
163: public void test431956() throws Exception {
164: // No warnings or errors were found. (-xml)
165:
166: executeTidyTest("431956.xml");
167: assertNoWarnings();
168: }
169:
170: /**
171: * test for Tidy [431964] : table height="" not flagged as error.
172: * @throws Exception any exception generated during the test
173: */
174: public void test431964() throws Exception {
175: // line 7 column 1 - Warning: <table> attribute "height" lacks value
176: // line 7 column 1 - Warning: <table> proprietary attribute "height"
177: // Info: Doctype given is "-//W3C//DTD HTML 4.01 Transitional//EN"
178: // Info: Document content looks like HTML Proprietary
179: // 2 warnings, 0 errors were found!
180:
181: executeTidyTest("431964.html");
182: assertWarnings(2);
183: }
184:
185: /**
186: * test for Tidy [433021] : Identify attribute whose value is bad.
187: * @throws Exception any exception generated during the test
188: */
189: public void test433021() throws Exception {
190: executeTidyTest("433021.html");
191: assertLogContains("align");
192: assertLogContains("valign");
193: assertWarnings(5);
194: }
195:
196: /**
197: * test for Tidy [433607] : No warning for omitted end tag with -xml.
198: * @throws Exception any exception generated during the test
199: */
200: public void test433607() throws Exception {
201: // No warnings or errors were found. (-xml)
202:
203: // still bad in tidy?
204: executeTidyTest("433607.xml");
205:
206: assertWarnings(1);
207: }
208:
209: /**
210: * test for Tidy [433670] : &apos not recognized as valid XML entity.
211: * @throws Exception any exception generated during the test
212: */
213: public void test433670() throws Exception {
214: // No warnings or errors were found. (-xml)
215: executeTidyTest("433670.xml");
216: assertNoWarnings();
217: }
218:
219: /**
220: * test for Tidy [434047] : Mixed content in 4.01 Strict not allowed.
221: * @throws Exception any exception generated during the test
222: */
223: public void test434047() throws Exception {
224: // Info: Doctype given is "-//W3C//DTD HTML 4.01//EN"
225: // Info: Document content looks like HTML 4.01 Strict
226: // No warnings or errors were found.
227:
228: executeTidyTest("434047.html");
229:
230: assertLogContains("HTML 4.01 Strict");
231:
232: }
233:
234: /**
235: * test for Tidy [434100] : Error actually reported as a warning (-xml).
236: * @throws Exception any exception generated during the test
237: */
238: public void test434100() throws Exception {
239: // -xml
240: // line 13 column 1 - Error: unexpected </head> in <link>
241: // 0 warnings, 1 error were found!
242:
243: executeTidyTest("434100.html");
244: assertErrors(1);
245: assertNoWarnings();
246: }
247:
248: /**
249: * test for Tidy [435917] : <input onfocus=""> reported unknown attr.
250: * @throws Exception any exception generated during the test
251: */
252: public void test435917() throws Exception {
253: // should not report: invalid attribute "onfocus"
254:
255: executeTidyTest("435917.html");
256: assertWarnings(1);
257: }
258:
259: /**
260: * test for Tidy [435917] : missing "=" in attribute confuses tidy.
261: * @throws Exception any exception generated during the test
262: */
263: public void test435917b() throws Exception {
264: // line 11 column 1 - Warning: <input> attribute with missing trailing quote mark
265:
266: // should not report:
267: // line 11 column 2 - Warning: <input> unknown attribute value "null"
268:
269: executeTidyTest("435917.html");
270: assertLogDoesntContains("null");
271: }
272:
273: /**
274: * test for Tidy [435922] : Missing <form> around <input> no warning.
275: * @throws Exception any exception generated during the test
276: */
277: public void test435922() throws Exception {
278: // line 6 column 1 - Warning: <input> isn't allowed in <body> elements
279: // line 7 column 3 - Warning: inserting implicit <form>
280: // line 7 column 3 - Warning: missing </form>
281: // line 7 column 3 - Warning: <form> lacks "action" attribute
282: // Info: Doctype given is "-//W3C//DTD HTML 4.01 Transitional//EN"
283: // Info: Document content looks like HTML 4.01 Transitional
284: // 4 warnings, 0 errors were found!
285:
286: executeTidyTest("435922.html");
287: assertWarnings(4);
288: }
289:
290: /**
291: * test for Tidy [438956] : Bad head-endtag reported incorrectly.
292: * @throws Exception any exception generated during the test
293: */
294: public void test438956() throws Exception {
295: // line 3 column 1 - Warning: plain text isn't allowed in <head> elements
296: // line 6 column 1 - Warning: discarding unexpected <body>
297: // Info: Doctype given is "-//W3C//DTD HTML 4.01 Transitional//EN"
298: // Info: Document content looks like HTML 4.01 Transitional
299: // 2 warnings, 0 errors were found!
300:
301: executeTidyTest("438956.html");
302:
303: assertWarnings(2);
304: }
305:
306: /**
307: * test for Tidy [446019] : <img name="foo"> allowed in XTHML-Strict.
308: * @throws Exception any exception generated during the test
309: */
310: public void test446019() throws Exception {
311: // Info: Doctype given is "-//W3C//DTD XHTML 1.0 Strict//EN"
312: // Info: Document content looks like XHTML 1.0 Transitional
313: // No warnings or errors were found.
314:
315: executeTidyTest("446019.xhtml");
316:
317: assertLogContains("XHTML 1.0 Transitional");
318: }
319:
320: /**
321: * test for Tidy [450389] : Color attval check allows only black/#.
322: * @throws Exception any exception generated during the test
323: */
324: public void test450389() throws Exception {
325: // line 1 column 1 - Warning: missing <!DOCTYPE> declaration
326: // line 44 column 1 - Warning: <font> attribute "color" has invalid value "reddish"
327: // line 72 column 1 - Warning: <font> attribute "color" has invalid value "#FF"
328: // line 76 column 1 - Warning: <font> attribute "color" has invalid value "grurple"
329: // line 77 column 1 - Warning: <font> attribute "color" has invalid value "#grurple"
330: // line 78 column 1 - Warning: <font> attribute "color" has invalid value "#1234567"
331: // Info: Document content looks like HTML 3.2
332:
333: executeTidyTest("450389.html");
334: assertWarnings(6);
335: }
336:
337: /**
338: * test for Tidy [501230] : "0" (Zero) has to be lower case.
339: * @throws Exception any exception generated during the test
340: */
341: public void test501230() throws Exception {
342: executeTidyTest("501230.xhtml");
343: assertLogDoesntContains("lower case");
344: }
345:
346: /**
347: * test for Tidy [501669] : width="n*" marked invalid on <COL>.
348: * @throws Exception any exception generated during the test
349: */
350: public void test501669() throws Exception {
351: // Info: Doctype given is "-//W3C//DTD HTML 4.01 Transitional//EN"
352: // Info: Document content looks like HTML 4.01 Strict
353: // No warnings or errors were found.
354:
355: executeTidyTest("501669.html");
356:
357: assertNoWarnings();
358: }
359:
360: /**
361: * test for Tidy [516370] : Invalid ID value.
362: * @throws Exception any exception generated during the test
363: */
364: public void test516370() throws Exception {
365: // line 10 column 1 - Warning: <h2> ID "_ValidID2" uses XML ID syntax
366: // line 11 column 1 - Warning: <h2> ID ":ValidID3" uses XML ID syntax
367: // line 13 column 1 - Warning: <h2> attribute "id" has invalid value ".InvalidID1"
368: // line 14 column 1 - Warning: <h2> attribute "id" has invalid value "2InvalidID2"
369: // line 15 column 1 - Warning: <h2> attribute "id" lacks value
370:
371: executeTidyTest("516370.xhtml");
372: assertWarnings(5);
373: assertLogContains("XML ID syntax");
374: }
375:
376: /**
377: * test for Tidy [517528] : Parser complains about xml:lang.
378: * @throws Exception any exception generated during the test
379: */
380: public void test517528() throws Exception {
381: executeTidyTest("517528.html");
382:
383: assertNoWarnings();
384: }
385:
386: /**
387: * test for Tidy [525081] : frameset rows attr. not recognized.
388: * @throws Exception any exception generated during the test
389: */
390: public void test525081() throws Exception {
391: // Info: Doctype given is "-//W3C//DTD HTML 4.01 Frameset//EN"
392: // Info: Document content looks like HTML 4.01 Frameset
393: // No warnings or errors were found.
394:
395: executeTidyTest("525081.html");
396: assertNoWarnings();
397: }
398:
399: /**
400: * test for Tidy [538536] : Extra endtags not detected.
401: * @throws Exception any exception generated during the test
402: */
403: public void test538536() throws Exception {
404: // line 5 column 1 - Warning: content occurs after end of body
405: // line 9 column 1 - Warning: discarding unexpected </html>
406: // Info: Doctype given is "-//W3C//DTD HTML 4.01//EN"
407: // Info: Document content looks like HTML 4.01 Strict
408: // 2 warnings, 0 errors were found!
409:
410: executeTidyTest("538536.html");
411: assertNoErrors();
412: assertWarnings(2);
413: }
414:
415: /**
416: * test for Tidy [545067] : Implicit closing of head broken.
417: * @throws Exception any exception generated during the test
418: */
419: public void test545067() throws Exception {
420: // should NOT output:
421: // line 3 column 1 - Warning: <p> isn't allowed in <head> elements
422: // since body tags implicitly terminate the <head> section
423:
424: // ok in jtidy r7
425:
426: executeTidyTest("545067.html");
427: assertLogDoesntContains("<head>");
428: }
429:
430: /**
431: * test for Tidy [552861] : <td with=""> not recognized.
432: * @throws Exception any exception generated during the test
433: */
434: public void test552861() throws Exception {
435: executeTidyTest("552861.html");
436: // should complain about invalid "with" attribute
437: assertWarnings(1);
438: }
439:
440: /**
441: * test for Tidy [553414] : XHTML strict accept '_target' attribute.
442: * @throws Exception any exception generated during the test
443: */
444: public void test553414() throws Exception {
445: executeTidyTest("553414.html");
446: assertLogContains("given is \"-//W3C//DTD XHTML 1.0 Strict//EN\"");
447: assertLogContains("looks like XHTML 1.0 Transitional");
448: assertWarnings(1);
449: }
450:
451: /**
452: * test for Tidy [553468] : Doesn't warn about <u> in XHTML strict.
453: * @throws Exception any exception generated during the test
454: */
455: public void test553468() throws Exception {
456:
457: // Info: Doctype given is "-//W3C//DTD XHTML 1.0 Strict//EN"
458: // Info: Document content looks like XHTML 1.0 Transitional
459: // No warnings or errors were found.
460:
461: executeTidyTest("553468.xhtml");
462:
463: assertLogContains("XHTML 1.0 Transitional");
464: }
465:
466: /**
467: * test for Tidy [559774] : tidy version rejects all id values.
468: * @throws Exception any exception generated during the test
469: */
470: public void test559774() throws Exception {
471: executeTidyTest("559774.html");
472: assertNoWarnings();
473: }
474:
475: /**
476: * test for Tidy [706260] : size not accepted for input.
477: * @throws Exception any exception generated during the test
478: */
479: public void test706260() throws Exception {
480: // Info: Doctype given is "-//W3C//DTD XHTML 1.0 Strict//EN"
481: // Info: Document content looks like XHTML 1.0 Transitional
482: // No warnings or errors were found.
483:
484: executeTidyTest("706260.html");
485: assertNoWarnings();
486: }
487:
488: }
|