#QUALITY by cg
class: RegressionTests::HTMLParserTests
added:
#test04_style
#test05_textExtraction
--- a/RegressionTests__HTMLParserTests.st Fri Jun 15 16:39:56 2018 +0200
+++ b/RegressionTests__HTMLParserTests.st Wed Jun 27 15:29:14 2018 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"{ Package: 'stx:goodies/regression' }"
"{ NameSpace: RegressionTests }"
@@ -228,6 +230,66 @@
"
self new test03
"
+!
+
+test04_style
+ |doc headElement styleElement styleText|
+
+ "/ verify: no ampersand escaping in style elements
+
+ UserNotification ignoreIn:[
+ doc := HTML::HTMLParser parseText:'
+<!!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<style>foo bar &bla &froboz & & foo</style>
+</head>
+<body>
+</body>
+</html>
+'.
+ ].
+ headElement := doc children first.
+ self assert:(headElement tagName = 'head').
+ styleElement := headElement children first.
+ self assert:(styleElement tagName = 'style').
+ styleText := HTML::TextExtractor extractTextFromElement:styleElement.
+ self assert:(styleText = 'foo bar &bla &froboz & & foo').
+
+ "
+ self new test04_style
+ "
+
+ "Created: / 27-06-2018 / 12:58:48 / Claus Gittinger"
+ "Modified: / 27-06-2018 / 15:22:00 / Claus Gittinger"
+!
+
+test05_textExtraction
+ |doc bodyElement p|
+
+ "/ verify: no ampersand escaping in style elements
+
+ UserNotification ignoreIn:[
+ doc := HTML::HTMLParser parseText:'
+<!!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<body>
+<p>
+foo bar &bla &froboz & & foo
+</p>
+</body>
+</html>
+'.
+ ].
+ bodyElement := doc body.
+ p := bodyElement children first.
+ self assert:(p extractedText = 'foo bar &bla &froboz & & foo').
+
+ "
+ self new test05_textExtraction
+ "
+
+ "Created: / 27-06-2018 / 15:28:31 / Claus Gittinger"
! !
!HTMLParserTests class methodsFor:'documentation'!