Skip to content

Commit 5fc8b53

Browse files
committed
[java] Removing setLegacy from Firefox
This has been deprecated for a while.
1 parent 12c8c27 commit 5fc8b53

File tree

4 files changed

+103
-160
lines changed

4 files changed

+103
-160
lines changed

‎java/src/org/openqa/selenium/firefox/FirefoxDriver.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,6 @@ public class FirefoxDriver extends RemoteWebDriver
8686
*/
8787
@Deprecated
8888
public static final String PROFILE = Capability.PROFILE;
89-
/**
90-
* @deprecated Use {@link Capability#MARIONETTE}
91-
*/
92-
@Deprecated
93-
public static final String MARIONETTE = Capability.MARIONETTE;
9489
private final Capabilities capabilities;
9590
private final RemoteWebStorage webStorage;
9691
private final HasExtensions extensions;
@@ -300,29 +295,12 @@ public static final class SystemProperty {
300295
*/
301296
public static final String BROWSER_LOGFILE = "webdriver.firefox.logfile";
302297

303-
/**
304-
* System property that defines the additional library path (Linux only).
305-
*/
306-
public static final String BROWSER_LIBRARY_PATH = "webdriver.firefox.library.path";
307-
308298
/**
309299
* System property that defines the profile that should be used as a template.
310300
* When the driver starts, it will make a copy of the profile it is using,
311301
* rather than using that profile directly.
312302
*/
313303
public static final String BROWSER_PROFILE = "webdriver.firefox.profile";
314-
315-
/**
316-
* System property that defines the location of the webdriver.xpi browser extension to install
317-
* in the browser. If not set, the prebuilt extension bundled with this class will be used.
318-
*/
319-
public static final String DRIVER_XPI_PROPERTY = "webdriver.firefox.driver";
320-
321-
/**
322-
* Boolean system property that instructs FirefoxDriver to use Marionette backend,
323-
* overrides any capabilities specified by the user
324-
*/
325-
public static final String DRIVER_USE_MARIONETTE = "webdriver.firefox.marionette";
326304
}
327305

328306
public static final class Capability {

‎java/src/org/openqa/selenium/firefox/FirefoxOptions.java

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
import static java.util.stream.Collectors.toMap;
2121
import static org.openqa.selenium.firefox.FirefoxDriver.Capability.BINARY;
22-
import static org.openqa.selenium.firefox.FirefoxDriver.Capability.MARIONETTE;
2322
import static org.openqa.selenium.firefox.FirefoxDriver.Capability.PROFILE;
2423
import static org.openqa.selenium.remote.Browser.FIREFOX;
2524

@@ -61,7 +60,6 @@ public class FirefoxOptions extends AbstractDriverOptions<FirefoxOptions> {
6160
public static final String FIREFOX_OPTIONS = "moz:firefoxOptions";
6261

6362
private Map<String, Object> firefoxOptions = Collections.unmodifiableMap(new TreeMap<>());
64-
private boolean legacy;
6563

6664
public FirefoxOptions() {
6765
setCapability(CapabilityType.BROWSER_NAME, FIREFOX.browserName());
@@ -99,10 +97,6 @@ public FirefoxOptions(Capabilities source) {
9997

10098
this.firefoxOptions = Collections.unmodifiableMap(options);
10199
}
102-
103-
if (source.getCapability(MARIONETTE) == Boolean.FALSE) {
104-
this.legacy = true;
105-
}
106100
}
107101
}
108102

@@ -117,7 +111,6 @@ private void mirror(FirefoxOptions that) {
117111
}
118112

119113
this.firefoxOptions = Collections.unmodifiableMap(newOptions);
120-
this.legacy = that.legacy;
121114
}
122115

123116
/**
@@ -150,20 +143,6 @@ public FirefoxOptions configureFromEnv() {
150143
setProfile(profile);
151144
}
152145

153-
String forceMarionette = System.getProperty(FirefoxDriver.SystemProperty.DRIVER_USE_MARIONETTE);
154-
if (forceMarionette != null && !Boolean.getBoolean(FirefoxDriver.SystemProperty.DRIVER_USE_MARIONETTE)) {
155-
setLegacy(true);
156-
}
157-
158-
return this;
159-
}
160-
161-
/**
162-
* @deprecated This method will be deleted and will not be replaced.
163-
*/
164-
@Deprecated
165-
public FirefoxOptions setLegacy(boolean legacy) {
166-
setCapability(MARIONETTE, !legacy);
167146
return this;
168147
}
169148

@@ -334,12 +313,6 @@ public void setCapability(String key, Object value) {
334313
}
335314
break;
336315

337-
case MARIONETTE:
338-
if (value instanceof Boolean) {
339-
legacy = !(Boolean) value;
340-
}
341-
break;
342-
343316
case PROFILE:
344317
if (value instanceof FirefoxProfile) {
345318
setProfile((FirefoxProfile) value);
@@ -380,9 +353,6 @@ protected Set<String> getExtraCapabilityNames() {
380353
Set<String> names = new TreeSet<>();
381354

382355
names.add(FIREFOX_OPTIONS);
383-
if (legacy) {
384-
names.add(MARIONETTE);
385-
}
386356

387357
return Collections.unmodifiableSet(names);
388358
}
@@ -391,16 +361,10 @@ protected Set<String> getExtraCapabilityNames() {
391361
protected Object getExtraCapability(String capabilityName) {
392362
Require.nonNull("Capability name", capabilityName);
393363

394-
switch (capabilityName) {
395-
case FIREFOX_OPTIONS:
396-
return Collections.unmodifiableMap(firefoxOptions);
397-
398-
case MARIONETTE:
399-
return !legacy;
400-
401-
default:
402-
return null;
364+
if (FIREFOX_OPTIONS.equals(capabilityName)) {
365+
return Collections.unmodifiableMap(firefoxOptions);
403366
}
367+
return null;
404368
}
405369

406370
@Override

‎java/src/org/openqa/selenium/server/htmlrunner/HTMLLauncher.java

Lines changed: 100 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,17 @@
1717

1818
package org.openqa.selenium.server.htmlrunner;
1919

20+
import static java.util.concurrent.TimeUnit.SECONDS;
21+
22+
import com.google.common.collect.ImmutableMap;
23+
2024
import com.beust.jcommander.JCommander;
2125
import com.beust.jcommander.Parameter;
2226
import com.beust.jcommander.ParameterException;
2327
import com.beust.jcommander.internal.Console;
24-
import com.google.common.collect.ImmutableMap;
2528
import com.thoughtworks.selenium.Selenium;
2629
import com.thoughtworks.selenium.webdriven.WebDriverBackedSelenium;
30+
2731
import org.openqa.selenium.By;
2832
import org.openqa.selenium.WebDriver;
2933
import org.openqa.selenium.WebElement;
@@ -58,8 +62,6 @@
5862
import java.util.logging.Level;
5963
import java.util.logging.Logger;
6064

61-
import static java.util.concurrent.TimeUnit.SECONDS;
62-
6365
/**
6466
* Runs HTML Selenium test suites.
6567
*/
@@ -72,6 +74,100 @@ public class HTMLLauncher {
7274

7375
private Server<?> server;
7476

77+
private static String printUsage(JCommander commander) {
78+
StringBuilder usage = new StringBuilder();
79+
commander.setConsole(new Console() {
80+
@Override
81+
public void print(String msg) {
82+
usage.append(msg);
83+
}
84+
85+
@Override
86+
public void println(String msg) {
87+
usage.append(msg).append("\n");
88+
}
89+
90+
@Override
91+
public char[] readPassword(boolean echoInput) {
92+
throw new UnsupportedOperationException("readPassword");
93+
}
94+
});
95+
commander.usage();
96+
97+
return usage.toString();
98+
}
99+
100+
public static int mainInt(String... args) throws Exception {
101+
Args processed = new Args();
102+
JCommander jCommander = new JCommander(processed);
103+
jCommander.setCaseSensitiveOptions(false);
104+
try {
105+
jCommander.parse(args);
106+
} catch (ParameterException ex) {
107+
System.err.print(ex.getMessage() + "\n" + printUsage(jCommander));
108+
return 0;
109+
}
110+
111+
if (processed.help) {
112+
System.err.print(printUsage(jCommander));
113+
return 0;
114+
}
115+
116+
warnAboutLegacyOptions(processed);
117+
118+
Path resultsPath = Paths.get(processed.htmlSuite.get(3));
119+
Files.createDirectories(resultsPath);
120+
121+
String suite = processed.htmlSuite.get(2);
122+
String startURL = processed.htmlSuite.get(1);
123+
String[] browsers = new String[] {processed.htmlSuite.get(0)};
124+
125+
HTMLLauncher launcher = new HTMLLauncher();
126+
127+
boolean passed = true;
128+
for (String browser : browsers) {
129+
// Turns out that Windows doesn't like "*" in a path name
130+
String reportFileName = browser.contains(" ") ? browser.substring(0, browser.indexOf(' ')) : browser;
131+
File results = resultsPath.resolve(reportFileName.substring(1) + ".results.html").toFile();
132+
String result = "FAILED";
133+
134+
try {
135+
long timeout;
136+
try {
137+
timeout = Long.parseLong(processed.timeout);
138+
} catch (NumberFormatException e) {
139+
System.err.println("Timeout does not appear to be a number: " + processed.timeout);
140+
return -2;
141+
}
142+
result = launcher.runHTMLSuite(browser, startURL, suite, results, timeout, processed.userExtensions);
143+
passed &= "PASSED".equals(result);
144+
} catch (Throwable e) {
145+
log.log(Level.WARNING, "Test of browser failed: " + browser, e);
146+
passed = false;
147+
}
148+
}
149+
150+
return passed ? 1 : 0;
151+
}
152+
153+
private static void warnAboutLegacyOptions(Args processed) {
154+
if (processed.multiWindow) {
155+
System.err.println("Multi-window mode is no longer used as an option and will be ignored.");
156+
}
157+
158+
if (processed.port != 0) {
159+
System.err.println("Port is no longer used as an option and will be ignored.");
160+
}
161+
162+
if (processed.trustAllSSLCertificates) {
163+
System.err.println("Trusting all ssl certificates is no longer a user-settable option.");
164+
}
165+
}
166+
167+
public static void main(String[] args) throws Exception {
168+
System.exit(mainInt(args));
169+
}
170+
75171
/**
76172
* Launches a single HTML Selenium test suite.
77173
*
@@ -193,100 +289,6 @@ private URL verifySuiteUrl(URL url) throws IOException {
193289
return url;
194290
}
195291

196-
private static String printUsage(JCommander commander) {
197-
StringBuilder usage = new StringBuilder();
198-
commander.setConsole(new Console() {
199-
@Override
200-
public void print(String msg) {
201-
usage.append(msg);
202-
}
203-
204-
@Override
205-
public void println(String msg) {
206-
usage.append(msg).append("\n");
207-
}
208-
209-
@Override
210-
public char[] readPassword(boolean echoInput) {
211-
throw new UnsupportedOperationException("readPassword");
212-
}
213-
});
214-
commander.usage();
215-
216-
return usage.toString();
217-
}
218-
219-
public static int mainInt(String... args) throws Exception {
220-
Args processed = new Args();
221-
JCommander jCommander = new JCommander(processed);
222-
jCommander.setCaseSensitiveOptions(false);
223-
try {
224-
jCommander.parse(args);
225-
} catch (ParameterException ex) {
226-
System.err.print(ex.getMessage() + "\n" + printUsage(jCommander));
227-
return 0;
228-
}
229-
230-
if (processed.help) {
231-
System.err.print(printUsage(jCommander));
232-
return 0;
233-
}
234-
235-
warnAboutLegacyOptions(processed);
236-
237-
Path resultsPath = Paths.get(processed.htmlSuite.get(3));
238-
Files.createDirectories(resultsPath);
239-
240-
String suite = processed.htmlSuite.get(2);
241-
String startURL = processed.htmlSuite.get(1);
242-
String[] browsers = new String[] {processed.htmlSuite.get(0)};
243-
244-
HTMLLauncher launcher = new HTMLLauncher();
245-
246-
boolean passed = true;
247-
for (String browser : browsers) {
248-
// Turns out that Windows doesn't like "*" in a path name
249-
String reportFileName = browser.contains(" ") ? browser.substring(0, browser.indexOf(' ')) : browser;
250-
File results = resultsPath.resolve(reportFileName.substring(1) + ".results.html").toFile();
251-
String result = "FAILED";
252-
253-
try {
254-
long timeout;
255-
try {
256-
timeout = Long.parseLong(processed.timeout);
257-
} catch (NumberFormatException e) {
258-
System.err.println("Timeout does not appear to be a number: " + processed.timeout);
259-
return -2;
260-
}
261-
result = launcher.runHTMLSuite(browser, startURL, suite, results, timeout, processed.userExtensions);
262-
passed &= "PASSED".equals(result);
263-
} catch (Throwable e) {
264-
log.log(Level.WARNING, "Test of browser failed: " + browser, e);
265-
passed = false;
266-
}
267-
}
268-
269-
return passed ? 1 : 0;
270-
}
271-
272-
private static void warnAboutLegacyOptions(Args processed) {
273-
if (processed.multiWindow) {
274-
System.err.println("Multi-window mode is no longer used as an option and will be ignored.");
275-
}
276-
277-
if (processed.port != 0) {
278-
System.err.println("Port is no longer used as an option and will be ignored.");
279-
}
280-
281-
if (processed.trustAllSSLCertificates) {
282-
System.err.println("Trusting all ssl certificates is no longer a user-settable option.");
283-
}
284-
}
285-
286-
public static void main(String[] args) throws Exception {
287-
System.exit(mainInt(args));
288-
}
289-
290292
private WebDriver createDriver(String browser) {
291293
String[] parts = browser.split(" ", 2);
292294
browser = parts[0];
@@ -296,7 +298,7 @@ private WebDriver createDriver(String browser) {
296298
case "*firefoxproxy":
297299
case "*firefoxchrome":
298300
case "*pifirefox":
299-
FirefoxOptions options = new FirefoxOptions().setLegacy(false);
301+
FirefoxOptions options = new FirefoxOptions();
300302
if (parts.length > 1) {
301303
options.setBinary(parts[1]);
302304
}

‎java/test/org/openqa/selenium/firefox/FirefoxOptionsTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,6 @@ public void canConvertOptionsWithBinaryToCapabilitiesAndRestoreBack() throws IOE
264264
@Test
265265
public void roundTrippingToCapabilitiesAndBackWorks() {
266266
FirefoxOptions expected = new FirefoxOptions()
267-
.setLegacy(true)
268267
.addPreference("cake", "walk");
269268

270269
// Convert to a Map so we can create a standalone capabilities instance, which we then use to

0 commit comments

Comments
 (0)