Changeset 735

Show
Ignore:
Timestamp:
07/23/07 14:25:21 (1 year ago)
Author:
kindlund
Message:

Improved implemented browser driver support (experimental).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • honeyclient/branches/exp/kindlund-firefox/lib/HoneyClient/Agent/Driver/Browser/IE.pm

    r723 r735  
    251251    # Sanity check. 
    252252    if (!defined($job)) { 
    253         $LOG->error("Error: Unable to spawn new job - " . $^E . "."); 
    254         Carp::croak "Error: Unable to spawn new job - " . $^E . ".\n"; 
     253        $LOG->error("Error: Unable to spawn a new process - " . $^E . "."); 
     254        Carp::croak "Error: Unable to spawn a new process - " . $^E . ".\n"; 
    255255    } 
    256256 
    257257    # Spawn the job. 
    258     $job->spawn(undef, "\"C:\\Program Files\\Internet Explorer\\iexplore.exe\"" . $args{'url'}); 
    259  
    260     # TODO: check to see if spawn fails. 
     258    #$job->spawn(undef, "\"C:\\Program Files\\Internet Explorer\\iexplore.exe\"" . $args{'url'}); 
     259    my $processExec = getVar(name => "process_exec"); 
     260    my $processName = getVar(name => "process_name"); 
     261    my $status = $job->spawn($processExec, $processName . " " . $args{'url'}); 
     262 
     263    # Sanity check. 
     264    if (!defined($status)) { 
     265        $LOG->error("Error: Unable to spawn a new browser - " . $^E . "."); 
     266        Carp::croak "Error: Unable to spawn a new browser - " . $^E . ".\n"; 
     267    } 
    261268 
    262269    # Run the job. 
     
    264271 
    265272    # TODO: check to see if run fails. 
     273    $status = $job->status(); 
     274 
     275    # Sanity check. 
     276    if (!defined($status) || 
     277        !scalar(%{$status})) { 
     278        $LOG->error("Error: Unable to retrieve job status from spawned process."); 
     279        Carp::croak "Error: Unable to retrieve job status from spawned process.\n"; 
     280    } 
     281 
     282    # Figure out the correct Process ID. 
     283    my @keys = keys(%{$status}); 
     284    my $processID = pop(@keys); 
     285 
     286    # Sanity checks. 
     287    if (!defined($processID) || 
     288        !exists($status->{$processID}->{'exitcode'}) || 
     289        !defined($status->{$processID}->{'exitcode'})) { 
     290        $LOG->error("Error: Unable to retrieve job status from spawned process."); 
     291        Carp::croak "Error: Unable to retrieve job status from spawned process.\n"; 
     292    } 
     293 
     294    # Check to make sure the exitcode is '293', meaning, that the 
     295    # application didn't unexpectedly die early. 
     296    if ($status->{$processID}->{'exitcode'} != 293) { 
     297        $LOG->warn("'" . $processName . "' process (ID = " . $processID . ") unexpectedly terminated early!"); 
     298    } 
    266299 
    267300    # Return the modified object state.