Skip to content
This repository was archived by the owner on Dec 17, 2024. It is now read-only.

Commit d9b0000

Browse files
authored
Merge pull request #344 from vania-pooh/master
Explicitly setting browserVersion in top-level capabilites only
2 parents 79cc283 + 3a0db10 commit d9b0000

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

proxy.go

+10-7
Original file line numberDiff line numberDiff line change
@@ -87,27 +87,27 @@ type Routes map[string]*Host
8787

8888
type caps map[string]interface{}
8989

90-
func (c caps) capabilities(fn func(m map[string]interface{}, w3c bool)) {
90+
func (c caps) capabilities(fn func(m map[string]interface{}, w3c bool, extension bool)) {
9191
if desiredCapabilities, ok := c[keys.desiredCapabilities]; ok {
9292
if m, ok := desiredCapabilities.(map[string]interface{}); ok {
93-
fn(m, false)
93+
fn(m, false, false)
9494
}
9595
}
9696
if w3cCapabilities, ok := c[keys.w3cCapabilities]; ok {
9797
if m, ok := w3cCapabilities.(map[string]interface{}); ok {
9898
if alwaysMatch, ok := m[keys.alwaysMatch]; ok {
9999
if m, ok := alwaysMatch.(map[string]interface{}); ok {
100-
fn(m, true)
100+
fn(m, true, false)
101101
for k, v := range m { // Extension capabilities have ":" in key
102102
if ec, ok := v.(map[string]interface{}); ok && strings.Contains(k, ":") {
103-
fn(ec, true)
103+
fn(ec, true, true)
104104
}
105105
}
106106
}
107107
}
108108
}
109109
} else {
110-
fn(make(map[string]interface{}), false)
110+
fn(make(map[string]interface{}), false, false)
111111
}
112112
}
113113

@@ -117,7 +117,7 @@ func (c caps) capability(k string) string {
117117

118118
func (c caps) capabilityJsonWireW3C(jsonWire, W3C string) string {
119119
result := ""
120-
c.capabilities(func(m map[string]interface{}, w3c bool) {
120+
c.capabilities(func(m map[string]interface{}, w3c bool, _ bool) {
121121
k := jsonWire
122122
if w3c {
123123
k = W3C
@@ -162,7 +162,10 @@ func (c caps) labels() string {
162162
}
163163

164164
func (c caps) setVersion(version string) {
165-
c.capabilities(func(m map[string]interface{}, w3c bool) {
165+
c.capabilities(func(m map[string]interface{}, w3c bool, extension bool) {
166+
if extension {
167+
return
168+
}
166169
if w3c {
167170
m["browserVersion"] = version
168171
} else {

proxy_test.go

+6
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,12 @@ func TestStartSessionWithDefaultVersionW3C(t *testing.T) {
886886
AssertThat(t, err, Is{nil})
887887
AssertThat(t, sess["capabilities"]["alwaysMatch"]["browserVersion"], EqualTo{"2.0"})
888888

889+
so, ok := sess["capabilities"]["alwaysMatch"]["selenoid:options"]
890+
AssertThat(t, ok, Is{true})
891+
selenoidOptions, ok := so.(map[string]interface{})
892+
AssertThat(t, ok, Is{true})
893+
_, ok = selenoidOptions["browserVersion"]
894+
AssertThat(t, ok, Is{false})
889895
}))
890896
selenium := httptest.NewServer(mux)
891897
defer selenium.Close()

0 commit comments

Comments
 (0)