HTML-Inspect

 view release on metacpan or  search on metacpan

t/11_collect_links.t  view on Meta::CPAN

is_deeply(
    $refs =>
        {
        'a_href' => [
            'https://whatwg.org/',
            'https://html.spec.whatwg.org/multipage/structured-data.html',
            'https://html.spec.whatwg.org/multipage/',
            'https://html.spec.whatwg.org/multipage/semantics.html',
            'https://html.spec.whatwg.org/multipage/dom.html',
            'https://html.spec.whatwg.org/multipage/references.html',
            'https://dom.spec.whatwg.org/'
        ],
        'area_href' => [
            'https://mozilla.org/',
            'https://developer.mozilla.org/',
            'https://developer.mozilla.org/docs/Web/Guide/Graphics',
            'https://developer.mozilla.org/docs/Web/CSS'
        ],
        'base_href' => [
            'https://html.spec.whatwg.org/multipage/'
        ],
        'embed_src' => [
            'https://html.spec.whatwg.org/media/cc0-videos/flower.mp4'
        ],
        'form_action' => [
            'https://html.spec.whatwg.org/multipage/'
        ],
        'iframe_src' => [
            'https://www.openstreetmap.org/export/embed.html?bbox=-0.004017949104309083,51.47612752641776,0.00030577182769775396,51.478569861898606&layer=mapnik'
        ],
        'img_src' => [
            'https://resources.whatwg.org/logo.svg',
            'https://html.spec.whatwg.org/media/examples/mdn-info.png'
        ],
        'link_href' => [
            'https://resources.whatwg.org/spec.css',
            'https://resources.whatwg.org/standard.css',
            'https://resources.whatwg.org/standard-shared-with-dev.css',
            'https://resources.whatwg.org/logo.svg',
            'https://html.spec.whatwg.org/styles.css'
        ],
        'script_src' => [
            'https://html.spec.whatwg.org/link-fixup.js',
            'https://html.spec.whatwg.org/html-dfn.js',
            'https://resources.whatwg.org/file-issue.js'
        ]
        },
    'all references are collected'
);

###
### collectLinks
###

my $links = $inspector->collectLinks;
#note explain $links;

is_deeply $links,
  {
    'icon' => [
        {'crossorigin' => 'use-credentials', 'href' => 'https://resources.whatwg.org/logo.svg'},
        {'href'        => 'https://resources.whatwg.org/logo.svg'}
    ],
    'stylesheet' => [
        {'crossorigin' => 'anonymous', 'href' => 'https://resources.whatwg.org/spec.css'},
        {'crossorigin' => '',          'href' => 'https://resources.whatwg.org/standard.css'},
        {'href'        => 'https://resources.whatwg.org/standard-shared-with-dev.css'},
        {'href'        => 'https://resources.whatwg.org/standard-shared-with-dev.css'},
        {'crossorigin' => '', 'href' => 'https://html.spec.whatwg.org/styles.css'}
    ]
  },
  'all link elements are collected';

done_testing;



( run in 0.415 second using v1.01-cache-2.11-cpan-ad19def0cd9 )