Skip to content

Commit

Permalink
Update FF Marionette commands
Browse files Browse the repository at this point in the history
In Firefox 63 an old syntax for Marionette commands was deprecated.
Updating mostly just meant prepending `WebDriver` to existing commands.

This should fix most problems in #232
  • Loading branch information
xv-tom-bh committed Nov 6, 2018
1 parent c7bb0b1 commit 5f4c819
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go:

addons:
# Use the full version number with ".0" if needed. This value is scraped by setup scripts.
firefox: "60.0"
firefox: "63.0"
apt:
packages:
- rpm
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ is running somewhere else on mains electricity.
## Installation

Download a binary from the [releases](https://github.com/browsh-org/browsh/releases) (~7MB).
You will need to have [Firefox 57](https://www.mozilla.org/en-US/firefox/new/) (or higher) aleady installed.
You will need to have [Firefox 63](https://www.mozilla.org/en-US/firefox/new/) (or higher) aleady installed.

Or download and run the Docker image (~230MB) with:
`docker run --rm -it browsh/browsh`
Expand Down
12 changes: 6 additions & 6 deletions interfacer/src/browsh/firefox.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func firefoxMarionette() {
}
marionette = conn
readMarionette()
sendFirefoxCommand("newSession", map[string]interface{}{})
sendFirefoxCommand("WebDriver:NewSession", map[string]interface{}{})
}

// Install the Browsh extension that was bundled with `go-bindata` under
Expand All @@ -228,20 +228,20 @@ func installWebextension() {
defer os.Remove(file.Name())
ioutil.WriteFile(file.Name(), []byte(data), 0644)
args := map[string]interface{}{"path": file.Name()}
sendFirefoxCommand("addon:install", args)
sendFirefoxCommand("Addon:Install", args)
}

// Set a Firefox preference as you would in `about:config`
// `value` needs to be supplied with quotes if it's to be used as a JS string
func setFFPreference(key string, value string) {
sendFirefoxCommand("setContext", map[string]interface{}{"value": "chrome"})
sendFirefoxCommand("Marionette:SetContext", map[string]interface{}{"value": "chrome"})
script := fmt.Sprintf(`
Components.utils.import("resource://gre/modules/Preferences.jsm");
prefs = new Preferences({defaultBranch: false});
prefs.set("%s", %s);`, key, value)
args := map[string]interface{}{"script": script}
sendFirefoxCommand("executeScript", args)
sendFirefoxCommand("setContext", map[string]interface{}{"value": "content"})
sendFirefoxCommand("WebDriver:ExecuteScript", args)
sendFirefoxCommand("Marionette:SetContext", map[string]interface{}{"value": "content"})
}

// Consume output from Marionette, we don't do anything with it. It"s just
Expand Down Expand Up @@ -309,5 +309,5 @@ func startFirefox() {
}

func quitFirefox() {
sendFirefoxCommand("quitApplication", map[string]interface{}{})
sendFirefoxCommand("Marionette:Quit", map[string]interface{}{})
}

0 comments on commit 5f4c819

Please sign in to comment.