puff has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w # this site has a large number of popup tests # http://www.kephyr.com/popupkillertest/test/index.html # http://www.kephyr.com/popupkillertest/test/test1.html ... 23 use strict; use Data::Dumper; use Win32::OLE qw( EVENTS ); use Time::HiRes qw(gettimeofday); my $self = {}; my $ie = Win32::OLE->new( 'InternetExplorer.Application' ) or die "error"; $ie->{visible} = 1; Win32::OLE->WithEvents( $ie, \&ie_events, 'DWebBrowserEvents2' ); $self->{ie} = $ie; $self->{popups} = []; $self->{ts} = $self->{tle} = gettimeofday; print "self after initialization\n" . Dumper( $self ); $|=1; # do not buffer sub navto($); # causes popup on 1st 2 loads #navto( 'http://www.cnn.com/' ); # no popup navto( 'http://www.google.com/' ); # single popup navto( 'http://www.kephyr.com/popupkillertest/test/test1.html' ); # two popups navto( 'http://www.gozer.org/mozilla/popup_tester/' ); # no popup navto( 'http://www.whitehouse.gov/' ); print "\n"; print "--------------------------------------------\n"; print "--------------------------------------------\n"; print "should see this if all is OK\n"; print "--------------------------------------------\n"; print "--------------------------------------------\n"; sub navto($){ my $url = shift; @{$self->{popups}} = (); $self->{ts} = $self->{tle} = gettimeofday; print "\n===================================================\n"; print "navigate to $url\n" . Dumper($self); $ie->navigate( $url ); while(gettimeofday - $self->{ts} < 60){ Win32::OLE->SpinMessageLoop; # check for events last if( gettimeofday - $self->{tle} > 10 ); } print "done $url\n" . Dumper( $self ); } sub ie_events(){ my( $ie, $event, @args ) = @_; my $tn = gettimeofday(); $self->{tle} = $tn; my $te = sprintf '%6.2f', $tn - $self->{ts}; print "$self $ie $te [$event]\n"; if( $event eq 'NewWindow2' ) { print "self before new window handling\n"; print Dumper($self); my $popupself = {}; my $ie = Win32::OLE->new( 'InternetExplorer.Application' ) or die( 'could not start IE on allowed NewWindow2' ); print "self after new IE application\n"; print Dumper($self); $popupself->{ie} = $ie; my $xx = $self->{popups}; push @{$xx}, $popupself; #works when commented out print "self after push\n"; print Dumper($self); #$args[0]->Put( $ie->{application}); $args[0]->Put( $ie ); $args[1]->Put( 0 ); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: perl crash, Win32::OLE
by diotalevi (Canon) on Dec 29, 2005 at 19:31 UTC | |
by puff (Beadle) on Dec 29, 2005 at 19:46 UTC | |
|
Re: perl crash, Win32::OLE
by kwaping (Priest) on Dec 29, 2005 at 19:17 UTC | |
by puff (Beadle) on Dec 29, 2005 at 19:42 UTC | |
by spiritway (Vicar) on Dec 30, 2005 at 10:06 UTC | |
by puff (Beadle) on Dec 30, 2005 at 15:40 UTC | |
|
Re: perl crash, Win32::OLE
by pKai (Priest) on Dec 29, 2005 at 19:34 UTC | |
by puff (Beadle) on Dec 29, 2005 at 19:48 UTC |