I used the following, slightly changed, script, but it works very well for me. I've removed the superfluous event setting and parameters that WWW::Mechanize::Firefox doesn't support:

#!/usr/bin/perl -w use strict; use WWW::Mechanize::Firefox; my $www=WWW::Mechanize::Firefox->new( #stack_depth=>5, autodie=>1, timeout=>60, #tab=>qr/$tabregex/, bufsize => 50_000_000, ); #$www->events(['load','onload','loaded','DOMFrameContentLoaded','DOMCo +ntentLoaded','error','abort','stop']); print time." get #1\n"; $www->get('http://cmcc.deviantart.com/'); print time." after get #1\n"; print time." content #1\n"; my $con=$www->content(); print time." after content #1\n"; print time." get #2\n"; $www->get('http://cmcc.deviantart.com/#/d1a8l1t'); print time." after get #2\n"; print time." content #2\n"; $con=$www->content(); print time." after content #2\n";

Note that I had to allow Javascript in the Noscript plugin for deviantart.net, as the second URL uses Javascript to display a single image. Other than that, I get the following (relatively quick) output:

1291386396 get #1 1291386398 after get #1 1291386398 content #1 1291386398 after content #1 1291386398 get #2 1291386399 after get #2 1291386399 content #2 1291386399 after content #2

If you are feeling adventurous, you can use the following, changed Javascript to make Firefox display an alert box whenever it captures an event:

sub _addEventListener { my ($self,$browser,$events) = @_; $events ||= $self->events; $events = [$events] unless ref $events; # This registers multiple events for a one-shot event my $make_semaphore = $self->repl->declare(<<'JS'); function(browser,events) { var lock = {}; lock.busy = 0; var b = browser; var listeners = []; for( var i = 0; i < events.length; i++) { var evname = events[i]; var callback = (function(listeners,evname){ return function(e) { if (! lock.busy) { lock.busy++; lock.event = evname; lock.js_event = {}; lock.js_event.target = e.originalTarget; lock.js_event.type = e.type; alert("Caught first event " + e.type + " " + e.mes +sage); } else { alert("Caught duplicate event " + e.type + " " + e +.message); }; for( var j = 0; j < listeners.length; j++) { b.removeEventListener(listeners[j][0],listeners[j] +[1],true); }; }; })(listeners,evname); listeners.push([evname,callback]); b.addEventListener(evname,callback,true); }; return lock } JS return $make_semaphore->($browser,$events); };

In reply to Re^9: WWW::Mechanize::Firefox delayed returns / slow by Corion
in thread WWW::Mechanize::Firefox delayed returns / slow by tcordes

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.