File: html5_validation.t

package info (click to toggle)
ciderwebmail 1.05%2B20221106-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,392 kB
  • sloc: perl: 3,199; xml: 782; javascript: 675; sh: 42; makefile: 29
file content (49 lines) | stat: -rw-r--r-- 1,288 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use strict;
use warnings;
use Test::More;
use CiderWebmail::Test {login => 1};
use WWW::Mechanize;

use English qw(-no_match_vars);

return plan skip_all => 'Set VALIDATOR_URI to a server running the w3c validator for HTML5 validation tests' unless $ENV{VALIDATOR_URI};


$mech->get('http://localhost/mailbox/INBOX/compose');

my $unix_time = time();

$mech->submit_form(
    with_fields => {
        from        => $ENV{TEST_MAILADDR},
        to          => $ENV{TEST_MAILADDR},
        sent_folder => find_special_folder('sent'),
        subject     => 'utf8handling-'.$unix_time,
        body        => 'utf8handling',
    },
);

$mech->get( 'http://localhost/mailbox/INBOX?length=99999' );

# Find all message links:
# <a href="http://localhost/mailbox/INBOX/27668" onclick="return false" id="link_27668">

my @links = $mech->find_all_links(id_regex => qr{\Alink_\d+\z});

my $v = Test::WWW::Mechanize->new();
for my $link (@links) {
    $mech->get_ok($link->url);

    $v->get_ok($ENV{VALIDATOR_URI});
    $v->submit_form(
        with_fields => {
            fragment => $mech->content,
        }
    );

    $v->content_contains('This document was successfully checked as', "HTML5 validation OK for ".$link->url);
}

delete_messages(["utf8handling-$unix_time"]);

done_testing();