'Start the headless browser tests in a separate process and use both
the subprocess return code and the stdout output (formatted as JSON)
to determine which tests failed and which passed.'

def run_js_script(self, rel_script_path, *args, **kwargs):

    log.debug('beginning    headless    browser    tests:    %s', rel_script_path)
    process_command_list = self.build_command_line(rel_script_path, *args, **kwargs)
    log.debug('process_command_list:    %s', str(process_command_list))
    try:
        process = subprocess.Popen(process_command_list, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        while (process.poll() is None):
            stderr_msg = process.stderr.readline()
            stderr_msg = self.strip_escape_codes(stderr_msg.strip())
            if stderr_msg:
                log.debug('(%s):    %s', rel_script_path, stderr_msg)
                if stderr_msg.startswith(self.casper_done_str):
                    break
        (stdout_output, stderr_output) = process.communicate()
        log.debug('process.returncode:    %d', process.returncode)
        stdout_output = '\n'.join(stdout_output.split('\n')[1:])
        if (process.returncode == 1):
            raise self.browser_error_to_exception(rel_script_path, stdout_output)
    except OSError as os_err:
        if (os_err.errno == errno.ENOENT):
            log.error(('No    path    to    headless    browser    executable:    %s\n' + 'These    tests    were    designed    to    use    the    following    headless    browser:\n%s'), self.exec_path, self.casper_info)
        raise
    return self.handle_js_results(stdout_output)
