File tree 2 files changed +25
-1
lines changed
src/org/openqa/selenium/chrome
test/org/openqa/selenium/chrome
2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -202,7 +202,12 @@ public Object getExperimentalOption(String name) {
202
202
* JSON.
203
203
*/
204
204
public JSONObject toJson () throws IOException , JSONException {
205
- JSONObject options = new JSONObject (experimentalOptions );
205
+ JSONObject options = new JSONObject ();
206
+ // copy experimental options, instead of passing to the JSONObject constructor
207
+ // because the JSON library will mutate the map passed in.
208
+ for (String key : experimentalOptions .keySet ()) {
209
+ options .put (key , experimentalOptions .get (key ));
210
+ }
206
211
207
212
if (binary != null ) {
208
213
options .put ("binary" , binary );
Original file line number Diff line number Diff line change 18
18
package org .openqa .selenium .chrome ;
19
19
20
20
import static org .junit .Assert .assertEquals ;
21
+ import static org .junit .Assert .assertTrue ;
21
22
22
23
import org .junit .After ;
24
+ import org .junit .Before ;
23
25
import org .junit .Test ;
24
26
import org .openqa .selenium .testing .JUnit4TestBase ;
25
27
import org .openqa .selenium .testing .NeedsLocalEnvironment ;
@@ -37,6 +39,12 @@ public void tearDown() throws Exception {
37
39
}
38
40
}
39
41
42
+ @ Before
43
+ @ Override
44
+ public void createDriver () throws Exception {
45
+ // do nothing, don't want to have it create a driver for these tests
46
+ }
47
+
40
48
@ NeedsLocalEnvironment
41
49
@ Test
42
50
public void canStartChromeWithCustomOptions () {
@@ -48,4 +56,15 @@ public void canStartChromeWithCustomOptions() {
48
56
Object userAgent = driver .executeScript ("return window.navigator.userAgent" );
49
57
assertEquals ("foo;bar" , userAgent );
50
58
}
59
+
60
+ @ NeedsLocalEnvironment
61
+ @ Test
62
+ public void optionsStayEqualAfterSerialization () throws Exception {
63
+ ChromeOptions options1 = new ChromeOptions ();
64
+ ChromeOptions options2 = new ChromeOptions ();
65
+ assertTrue ("empty chrome options should be equal" , options1 .equals (options2 ));
66
+ options1 .toJson ();
67
+ assertTrue ("empty chrome options after one is .toJson() should be equal" ,
68
+ options1 .equals (options2 ));
69
+ }
51
70
}
You can’t perform that action at this time.
1 commit comments
lukeis commentedon May 25, 2014
@rsalvador fyi