fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2011-02-15 04:07 am

[dw-free] http://bugs.dwscoalition.org/show_bug.cgi?id=3438

[commit: http://hg.dwscoalition.org/dw-free/rev/bf94c5f272c4]

http://bugs.dwscoalition.org/show_bug.cgi?id=3438

Add tests for font size handling in comments.

Patch by [personal profile] fu.

Files modified:
  • t/clean-comment.t
--------------------------------------------------------------------------------
diff -r 9135a526692e -r bf94c5f272c4 t/clean-comment.t
--- a/t/clean-comment.t	Mon Feb 07 16:47:39 2011 +0800
+++ b/t/clean-comment.t	Tue Feb 15 11:32:10 2011 +0800
@@ -2,7 +2,7 @@
 
 use strict;
 use Test::More;
-plan tests => 10;
+plan tests => 13;
 
 use lib "$ENV{LJHOME}/cgi-bin";
 require 'ljlib.pl';
@@ -59,6 +59,25 @@ ok($orig_comment =~/^$clean_comment$/, "
 $clean->({ remove_positioning => 1 });
 ok($orig_comment =~ /^$clean_comment$/, "Padding not removed; of reasonable size.");
 
+note( "Clean absolute sizes" );
+{
+    $orig_comment  = qq{<span style="font-size: larger">foo</span>};
+    $clean_comment = qq{<span style="font-size: larger">foo</span>};
+    $clean->();
+    is( $orig_comment, $clean_comment, "Retain relative font sizes" );
+
+    $orig_comment  = qq{<span style="font-size:   10px  ">foo</span>};
+    $clean_comment = qq{<span style="">foo</span>};
+    $clean->();
+    is( $orig_comment, $clean_comment, "Strip absolute font sizes" );
+
+    $orig_comment  = qq{<span style="font-size:0.2em; font-weight: bold">foo</span>};
+    $clean_comment = qq{<span style=" font-weight: bold">foo</span>};
+    $clean->();
+    is( $orig_comment, $clean_comment, "Strip absolute font sizes" );
+
+
+}
 
 # remove background urls from logged out users
 $orig_comment = qq{<span style="background: url('http://www.example.com/example.gif');"></span>};
--------------------------------------------------------------------------------