context: function TestLoop(commandFactory) {    this.commandFactory = commandFactory;    var self = this;    this.start = function() {        this.continueCurrentTest();    };    this.continueCurrentTest = function() {        var testStatus = this.kickoffNextCommandExecution();        if (testStatus == TEST_FINISHED) {            this.testComplete();        }        };    this.kickoffNextCommandExecution = function() {        var command;        if (starting_up == true) {            command = this.firstCommand();            starting_up = false;        } else {            command = this.nextCommand();        }        if (!command) return TEST_FINISHED;        // Make the current row blue        this.commandStarted(command);        LOG.debug("Executing: |" + command.command + " | " + command.target + " | " + command.value + " |");        var result;        try {            var handler = this.commandFactory.getCommandHandler(command.command);            if(handler == null) {                throw new Error("Unknown command: '" + command.command + "'");            }            result = handler.execute(selenium, command);        } catch (e) {            LOG.error(e);            // TODO: only throw typed errors from commands so that we can perform better error handling            // to differentiate between expected command errors and unexpected javascript errors.            if (e instanceof TypeError) {                // Not a command error.                throw e;            }            this.commandError(e.message);            return TEST_FINISHED;        }        // Record the result so that we can continue the execution using window.setTimeout()        this.lastCommandResult = result;        if (result.processState == SELENIUM_PROCESS_WAIT) {            // Since we're waiting for page to reload, we can't continue command execution            // directly, we need use a page load listener.            // TODO there is a potential race condition by attaching a load listener after            // the command has completed execution.            selenium.callOnNextPageLoad(function() {eval("testLoop.continueCommandExecutionWithDelay()");});        } else {            // Continue processing            this.continueCommandExecutionWithDelay();        }        // Test is not finished.        return TEST_CONTINUE;    };    /**    * Continues the command execution, after waiting for the specified delay.    */    this.continueCommandExecutionWithDelay = function() {        // Get the interval to use for this command execution, using the pauseInterval is        // specified. Reset the pause interval, since it's a one-off thing.        var interval = this.pauseInterval || this.getCommandInterval();        this.pauseInterval = undefined;        // Continue processing        if (interval >= 0) {            window.setTimeout("testLoop.finishCommandExecution()", interval);        }    };    /**    * Finishes the execution of the previous command, and continues the test    */    this.finishCommandExecution = function() {        this.commandComplete(this.lastCommandResult);        this.continueCurrentTest();    };}
meta: 3428	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/3428/2fcc52b4c36971bc80c8c53c7e2a4289ca8af0c0/selenium-executionloop.js/clean/code/javascript/selenium-executionloop.js