Skip to content

Commit 932cbf9

Browse files
committed
[java] support installing temporary addon in Firefox
1 parent 44f1fd9 commit 932cbf9

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,13 @@ public HasExtensions getImplementation(Capabilities capabilities, ExecuteMethod
6767
return new HasExtensions() {
6868
@Override
6969
public String installExtension(Path path) {
70+
return installExtension(path, false);
71+
}
72+
73+
@Override
74+
public String installExtension(Path path, Boolean temporary) {
7075
Require.nonNull("Extension Path", path);
76+
Require.nonNull("Temporary", temporary);
7177

7278
String encoded;
7379
try {
@@ -78,7 +84,7 @@ public String installExtension(Path path) {
7884

7985
return (String) executeMethod.execute(
8086
INSTALL_EXTENSION,
81-
ImmutableMap.of("addon", encoded, "temporary", false));
87+
ImmutableMap.of("addon", encoded, "temporary", temporary));
8288
}
8389

8490
@Override

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,13 @@ public String installExtension(Path path) {
269269
return extensions.installExtension(path);
270270
}
271271

272+
@Override
273+
public String installExtension(Path path, Boolean temporary) {
274+
Require.nonNull("Path", path);
275+
Require.nonNull("Temporary", temporary);
276+
return extensions.installExtension(path, temporary);
277+
}
278+
272279
@Override
273280
public void uninstallExtension(String extensionId) {
274281
Require.nonNull("Extension ID", extensionId);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ public interface HasExtensions {
3535
*/
3636
String installExtension(Path path);
3737

38+
String installExtension(Path path, Boolean temporary);
39+
3840
/**
3941
* Uninstall the extension by the given identifier.
4042
* This value can be found in the extension's manifest, and typically ends with "@mozilla.org".

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,20 @@ public void canAddRemoveExtensions() {
512512
}
513513
}
514514

515+
@Test
516+
public void canAddRemoveTempExtensions() {
517+
Path extension = InProject.locate("third_party/firebug/favourite_colour-1.1-an+fx.xpi");
518+
519+
String id = ((HasExtensions) driver).installExtension(extension, true);
520+
assertThat(id).isEqualTo("favourite-colour-examples@mozilla.org");
521+
522+
try {
523+
((HasExtensions) driver).uninstallExtension(id);
524+
} catch (WebDriverException ex) {
525+
fail(ex.getMessage());
526+
}
527+
}
528+
515529
@Test
516530
public void canTakeFullPageScreenshot() {
517531
File tempFile = ((HasFullPageScreenshot) driver).getFullPageScreenshotAs(OutputType.FILE);

0 commit comments

Comments
 (0)