| Line | |
|---|
| 1 | use strict; |
|---|
| 2 | use warnings; |
|---|
| 3 | use Moxy; |
|---|
| 4 | use HTTP::Request; |
|---|
| 5 | use Test::Base; |
|---|
| 6 | use FindBin; |
|---|
| 7 | use File::Spec::Functions; |
|---|
| 8 | use HTTP::Response; |
|---|
| 9 | |
|---|
| 10 | plan tests => 1*blocks; |
|---|
| 11 | |
|---|
| 12 | my $m = Moxy->new( |
|---|
| 13 | { |
|---|
| 14 | global => { |
|---|
| 15 | assets_path => catfile( $FindBin::Bin, '..', 'assets' ), |
|---|
| 16 | storage => { |
|---|
| 17 | module => 'DBM_File', |
|---|
| 18 | file => 't/testing.ndbm', |
|---|
| 19 | dbm_class => 'NDBM_File', |
|---|
| 20 | }, |
|---|
| 21 | }, |
|---|
| 22 | plugins => [ |
|---|
| 23 | { module => 'Filter::FlashUseImgTag' }, |
|---|
| 24 | ], |
|---|
| 25 | } |
|---|
| 26 | ); |
|---|
| 27 | |
|---|
| 28 | filters { |
|---|
| 29 | input => [qw/response response_filter fetch_content remove_space/], |
|---|
| 30 | expected => [qw/remove_space/], |
|---|
| 31 | }; |
|---|
| 32 | |
|---|
| 33 | sub response { |
|---|
| 34 | my $html = shift; |
|---|
| 35 | my $res = HTTP::Response->new(200); |
|---|
| 36 | $res->header('Content-Type' => 'text/html'); |
|---|
| 37 | $res->content($html); |
|---|
| 38 | $res; |
|---|
| 39 | } |
|---|
| 40 | |
|---|
| 41 | sub response_filter { |
|---|
| 42 | my $res = shift; |
|---|
| 43 | $m->run_hook('response_filter_E', { response => $res }); |
|---|
| 44 | $res; |
|---|
| 45 | } |
|---|
| 46 | |
|---|
| 47 | sub fetch_content { |
|---|
| 48 | my $res = shift; |
|---|
| 49 | $res->content; |
|---|
| 50 | } |
|---|
| 51 | |
|---|
| 52 | sub remove_space { my $x = shift; $x =~ s/^\s+//mg; $x =~ s/\n//g; $x } |
|---|
| 53 | |
|---|
| 54 | run_is input => 'expected'; |
|---|
| 55 | |
|---|
| 56 | __END__ |
|---|
| 57 | |
|---|
| 58 | === |
|---|
| 59 | --- input |
|---|
| 60 | <html><img src="http://example.com/hoge.swf" width="30" height="40" /></html> |
|---|
| 61 | --- expected |
|---|
| 62 | <html> |
|---|
| 63 | <object data="http://example.com/hoge.swf" width="30" height="40" |
|---|
| 64 | type="application/x-shockwave-flash"> |
|---|
| 65 | <param name="bgcolor" value="#ffffff" /> |
|---|
| 66 | <param name="loop" value="off" /> |
|---|
| 67 | <param name="quality" value="high" /> |
|---|
| 68 | <param name="salign" value="t" /> |
|---|
| 69 | </object> |
|---|
| 70 | </html> |
|---|
| 71 | |
|---|