EV-WebKit

 view release on metacpan or  search on metacpan

t/97-user-styles.t  view on Meta::CPAN

    $b->go($url, sub { $b->find('#h', sub { $_[0]->is_visible(sub { $vis = $_[0]; EV::break }) }) });
    TWK::run_with_timeout(15);
    return $vis;
}

# a user-level stylesheet beats the page's own CSS and hides the element;
# ->remove restores it on the next navigation.
{
    my $b = EV::WebKit->new(window => [200,150]);
    # the page rule is author-origin !important, so ONLY a user-origin !important
    # (level => 'user') can override it in the cascade. This makes the test
    # actually distinguish user from author: a user->author regression leaves the
    # element visible and fails here.
    $b->mock_scheme('sty', sub {
        ('<html><head><style>h1{display:block !important}</style></head><body><h1 id=h>Hi</h1></body></html>','text/html');
    });
    my $h = $b->add_user_style('h1 { display:none !important }', level => 'user');
    isa_ok($h, 'EV::WebKit::UserContent', 'add_user_style returns a handle');
    is(visible_at($b, 'sty://host/p'), 0, 'user-level style beat an author !important rule (proves level=user, not author)');
    $h->remove;
    ok(visible_at($b, 'sty://host/p2'), 'element visible again after the style was removed');



( run in 1.070 second using v1.01-cache-2.11-cpan-e7c6538aa59 )