@@ -104,6 +104,12 @@ public FirefoxOptions(Capabilities source) {
104
104
}
105
105
});
106
106
107
+ // If `source` is an instance of FirefoxOptions, we need to mirror those into this instance.
108
+ if (source instanceof FirefoxOptions ) {
109
+ mirror ((FirefoxOptions ) source );
110
+ return ;
111
+ }
112
+
107
113
// If `source` has options, we need to mirror those into this instance. This may be either a
108
114
// Map (if we're constructing from a serialized instance) or another FirefoxOptions. *sigh*
109
115
Object raw = source .getCapability (FIREFOX_OPTIONS );
@@ -167,6 +173,17 @@ public FirefoxOptions(Capabilities source) {
167
173
}
168
174
}
169
175
176
+ private void mirror (FirefoxOptions that ) {
177
+ addArguments (that .args );
178
+ that .preferences .forEach (this ::addPreference );
179
+ setLegacy (that .legacy );
180
+
181
+ if (that .logLevel != null ) { setLogLevel (that .logLevel ); }
182
+ if (that .binary != null ) { setCapability (BINARY , that .binary .asCapability ()); }
183
+
184
+ if (that .profile != null ) { setProfile (that .profile ); }
185
+ }
186
+
170
187
public FirefoxOptions setLegacy (boolean legacy ) {
171
188
setCapability (MARIONETTE , !legacy );
172
189
return this ;
@@ -309,6 +326,9 @@ public Map<String, Object> asMap() {
309
326
@ Override
310
327
public FirefoxOptions merge (Capabilities capabilities ) {
311
328
super .merge (capabilities );
329
+ if (capabilities instanceof FirefoxOptions ) {
330
+ mirror ((FirefoxOptions ) capabilities );
331
+ }
312
332
return this ;
313
333
}
314
334
0 commit comments