[Htmlparser-cvs] htmlparser/src/org/htmlparser/tests/utilTests BeanTest.java,1.31,1.32
Brought to you by:
derrickoswald
From: <der...@us...> - 2003-07-17 00:56:50
|
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/utilTests In directory sc8-pr-cvs1:/tmp/cvs-serv24819/org/htmlparser/tests/utilTests Modified Files: BeanTest.java Log Message: More tests. testOutputWithPreAndScriptTags is now correct, I think. The overarching goal of StringBean is to return the text, and only the text, that a user would see in a browser. When I open this html in Netscape I see nothing: <body><pre> <script language=\"javascript\"> if(navigator.appName.indexOf(\"Netscape\") != -1) document.write ('xxx'); else document.write ('yyy'); </script> </pre></body> That's what StringBean says too. Although this points out a flaw in the specification (such as it is, see the StringBean javadoc): * Text within <SCRIPT></SCRIPT> tags is removed. * The text within <PRE></PRE> tags is not altered. So what happens when there's both? The 'not altered' means, not collapsed, not that the HTML is returned literally. To test this out, see how Netscape handles: <body><pre> <b>Hello World</b> </pre></body> For me it shows: Hello World which means it consumes (and honours) the bold tags even though it is within <pre></pre> So the StringBean <pre> handling is correct, or so it seems. I guess that most questions can be answered by submitting it to a browser. Index: BeanTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/utilTests/BeanTest.java,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** BeanTest.java 16 Jul 2003 20:05:07 -0000 1.31 --- BeanTest.java 17 Jul 2003 00:56:47 -0000 1.32 *************** *** 405,413 **** check (sb, "<body>"+sampleScript+"</body>", ""); } ! /** * Test output with pre and script tags */ ! public void xtestOutputWithPreAndScriptTags() { StringBean sb; sb = new StringBean (); --- 405,469 ---- check (sb, "<body>"+sampleScript+"</body>", ""); } ! ! /* ! * Test output with pre and any tag. ! */ ! public void testOutputWithPreAndAnyTag() ! { ! StringBean sb; ! ! sb = new StringBean (); ! sb.setLinks (false); ! sb.setReplaceNonBreakingSpaces (true); ! sb.setCollapse (false); ! check (sb, "<html><head></head><body><pre><hello></pre></body></html>", ""); ! } ! ! /* ! * Test output with pre and any tag and text. ! */ ! public void testOutputWithPreAndAnyTagPlusText() ! { ! StringBean sb; ! ! sb = new StringBean (); ! sb.setLinks (false); ! sb.setReplaceNonBreakingSpaces (true); ! sb.setCollapse (false); ! check (sb, "<html><head></head><body><pre><hello>dogfood</hello></pre></body></html>", "dogfood"); ! } ! ! /* ! * Test output with pre and any tag and text. ! */ ! public void testOutputWithPreAndAnyTagPlusTextWithWhitespace() ! { ! StringBean sb; ! ! sb = new StringBean (); ! sb.setLinks (false); ! sb.setReplaceNonBreakingSpaces (true); ! sb.setCollapse (true); ! check (sb, "<html><head></head><body><pre><hello>dog food</hello></pre></body></html>", "dog food"); ! } ! ! /* ! * Test output without pre and any tag and text. ! */ ! public void testOutputWithoutPreAndAnyTagPlusTextWithWhitespace() ! { ! StringBean sb; ! ! sb = new StringBean (); ! sb.setLinks (false); ! sb.setReplaceNonBreakingSpaces (true); ! sb.setCollapse (true); ! check (sb, "<html><head></head><body><hello>dog food</hello></body></html>", "dog food"); ! } ! /** * Test output with pre and script tags */ ! public void testOutputWithPreAndScriptTags() { StringBean sb; sb = new StringBean (); *************** *** 421,425 **** + "</script>\r\n"; ! check (sb, "<body><pre>"+sampleScript+"</pre></body>", sampleScript); } --- 477,481 ---- + "</script>\r\n"; ! check (sb, "<body><pre>"+sampleScript+"</pre></body>", ""); } |