func GetDefaultPrefs() map[string]interface{} {
	prefs := map[string]interface{}{
		"browser.cache.disk.enable":   false,
		"browser.cache.disk.capacity": 0,
		"browser.cache.memory.enable": true,
		"extensions.autoDisableScopes": 10,
		"signon.rememberSignons": false,
		"browser.EULA.3.accepted": true,
		"browser.EULA.override":   true,
		"browser.startup.homepage":                 "about:blank",
		"browser.startup.page":                     0,
		"browser.startup.homepage_override.mstone": "ignore",
		"browser.offline": false,
		"browser.shell.checkDefaultBrowser": false,
		"dom.disable_open_during_load": false,
		"network.http.phishy-userpass-length": 255,
		"security.warn_entering_secure":           false,
		"security.warn_entering_secure.show_once": false,
		"security.warn_entering_weak":             false,
		"security.warn_entering_weak.show_once":   false,
		"security.warn_leaving_secure":            false,
		"security.warn_leaving_secure.show_once":  false,
		"security.warn_submit_insecure":           false,
		"security.warn_submit_insecure.show_once": false,
		"security.warn_viewing_mixed":             false,
		"security.warn_viewing_mixed.show_once":   false,
		"toolkit.networkmanager.disable": true,
		"app.update.auto":                           false,
		"app.update.enabled":                        false,
		"extensions.update.enabled":                 false,
		"browser.search.update":                     false,
		"extensions.blocklist.enabled":              false,
		"browser.safebrowsing.enabled":              false,
		"browser.safebrowsing.malware.enabled":      false,
		"browser.download.manager.showWhenStarting": false,
		"browser.sessionstore.resume_from_crash":    false,
		"browser.tabs.warnOnClose":                  false,
		"browser.tabs.warnOnOpen":                   false,
		"devtools.errorconsole.enabled":             true,
		"extensions.logging.enabled":                true,
		"extensions.update.notifyUser":              false,
		"network.manage-offline-status":             false,
		"offline-apps.allow_by_default":             true,
		"prompts.tab_modal.enabled":                 false,
		"security.fileuri.origin_policy":            3,
		"security.fileuri.strict_origin_policy":     false,
		"toolkit.telemetry.prompted":                2,
		"toolkit.telemetry.enabled":                 false,
		"toolkit.telemetry.rejected":                true,
		"browser.dom.window.dump.enabled":           true,
		"dom.report_all_js_exceptions":              true,
		"javascript.options.showInConsole":          true,
		"network.http.max-connections-per-server":   10,
		"webdriver_accept_untrusted_certs":     true,
		"webdriver_assume_untrusted_issuer":    true,
		"webdriver_enable_native_events":       false,
		"webdriver_unexpected_alert_behaviour": "dismiss",
	}
	return prefs
}
Populate a map with default firefox preferences
package webdriver
import (
	"archive/zip"
	"encoding/xml"
	"errors"
	"fmt"
	"io"
	"io/ioutil"
	"net"
	"os"
	"os/exec"
	"path/filepath"
	"strconv"
	"time"
)
type FirefoxDriver struct {
	WebDriverCore
	Port int
	LockPortTimeout time.Duration
	StartTimeout time.Duration
	LogFile string
	Prefs map[string]interface{}
	DeleteProfileOnClose bool
	firefoxPath string
	xpiPath     string
	profilePath string
	cmd         *exec.Cmd
	logFile     *os.File
}
func NewFirefoxDriver(firefoxPath string, xpiPath string) *FirefoxDriver {
	d := &FirefoxDriver{}
	d.firefoxPath = firefoxPath
	d.xpiPath = xpiPath
	d.Port = 0
	d.LockPortTimeout = 60 * time.Second
	d.StartTimeout = 20 * time.Second
	d.LogFile = ""
	d.Prefs = GetDefaultPrefs()
	d.DeleteProfileOnClose = true
	return d
}
func (d *FirefoxDriver) SetLogPath(path string) {
	d.Prefs["webdriver.log.file"] = filepath.Join(path, "jsconsole.log")
	d.Prefs["webdriver.log.driver.file"] = filepath.Join(path, "driver.log")
	d.Prefs["webdriver.log.profiler.file"] = filepath.Join(path, "profiler.log")
	d.Prefs["webdriver.log.browser.file"] = filepath.Join(path, "browser.log")
}
func (d *FirefoxDriver) Start() error {
	if d.Port == 0 {  
		d.Port = 7055
		lockPortAddress := fmt.Sprintf("127.0.0.1:%d", d.Port-1)
		now := time.Now()
		for {
			if ln, err := net.Listen("tcp", lockPortAddress); err == nil {
				defer ln.Close()
				break
			}
			if time.Since(now) > d.LockPortTimeout {
				return errors.New("timeout expired trying to lock mutex port")
			}
			time.Sleep(1 * time.Second)
		}
		for i := d.Port; i < 65535; i++ {
			address := fmt.Sprintf("127.0.0.1:%d", i)
			if ln, err := net.Listen("tcp", address); err == nil {
				if err = ln.Close(); err != nil {
					return err
				}
				d.Port = i
				break
			}
		}
	}
	d.Prefs["webdriver_firefox_port"] = d.Port
	var err error
	d.profilePath, err = createTempProfile(d.xpiPath, d.Prefs)
	if err != nil {
		return err
	}
	debugprint(d.profilePath)
	d.cmd = exec.Command(d.firefoxPath, "-no-remote", "-profile", d.profilePath)
	stdout, err := d.cmd.StdoutPipe()
	if err != nil {
		fmt.Println(err)
	}
	stderr, err := d.cmd.StderrPipe()
	if err != nil {
		fmt.Println(err)
	}
	if err := d.cmd.Start(); err != nil {
		return errors.New("unable to start firefox: " + err.Error())
	}
	if d.LogFile != "" {
		flags := os.O_WRONLY | os.O_CREATE | os.O_TRUNC
		d.logFile, err = os.OpenFile(d.LogFile, flags, 0640)
		if err != nil {
			return err
		}
		go io.Copy(d.logFile, stdout)
		go io.Copy(d.logFile, stderr)
	} else {
		go io.Copy(os.Stdout, stdout)
		go io.Copy(os.Stderr, stderr)
	}
	if err = probePort(d.Port, d.StartTimeout); err != nil {
		return err
	}
	d.url = fmt.Sprintf("http://127.0.0.1:%d/hub", d.Port)
	return nil
}