Skip to content

Commit c17a348

Browse files
committed
Fix failing Firefox tests
The mind boggles that we used to pass in something thinking it was JSON that wasn't actually JSON. *sigh*
1 parent 8943c61 commit c17a348

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

java/client/src/org/openqa/selenium/firefox/FirefoxProfile.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,9 +366,15 @@ public String toJson() throws IOException {
366366
}
367367

368368
public static FirefoxProfile fromJson(String json) throws IOException {
369-
String zippedProfile = new Json().toType(json, String.class);
369+
// We used to just pass in the entire string without quotes. If we see that, we're good.
370+
// Otherwise, parse the json.
371+
372+
if (json.trim().startsWith("\"")) {
373+
json = new Json().toType(json, String.class);
374+
}
375+
370376
return new FirefoxProfile(Zip.unzipToTempDir(
371-
zippedProfile,
377+
json,
372378
"webdriver",
373379
"duplicated"));
374380
}

java/client/test/org/openqa/selenium/firefox/FirefoxProfileTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public void shouldQuoteStringsWhenSettingStringProperties() throws Exception {
6767
}
6868

6969
@Test
70-
public void getStringPreferenceShouldReturnUserSuppliedValueWhenSet() throws Exception {
70+
public void getStringPreferenceShouldReturnUserSuppliedValueWhenSet() {
7171
String key = "cheese";
7272
String value = "brie";
7373
profile.setPreference(key, value);
@@ -77,7 +77,7 @@ public void getStringPreferenceShouldReturnUserSuppliedValueWhenSet() throws Exc
7777
}
7878

7979
@Test
80-
public void getStringPreferenceShouldReturnDefaultValueWhenSet() throws Exception {
80+
public void getStringPreferenceShouldReturnDefaultValueWhenSet() {
8181
String key = "cheese";
8282

8383
String defaultValue = "brie";
@@ -92,7 +92,7 @@ public void shouldSetIntegerPreferences() throws Exception {
9292
}
9393

9494
@Test
95-
public void getIntegerPreferenceShouldReturnUserSuppliedValueWhenSet() throws Exception {
95+
public void getIntegerPreferenceShouldReturnUserSuppliedValueWhenSet() {
9696
String key = "cheese";
9797
int value = 1234;
9898
profile.setPreference(key, value);
@@ -102,7 +102,7 @@ public void getIntegerPreferenceShouldReturnUserSuppliedValueWhenSet() throws Ex
102102
}
103103

104104
@Test
105-
public void getIntegerPreferenceShouldReturnDefaultValueWhenSet() throws Exception {
105+
public void getIntegerPreferenceShouldReturnDefaultValueWhenSet() {
106106
String key = "cheese";
107107

108108
int defaultValue = 42;
@@ -117,7 +117,7 @@ public void shouldSetBooleanPreferences() throws Exception {
117117
}
118118

119119
@Test
120-
public void getBooleanPreferenceShouldReturnUserSuppliedValueWhenSet() throws Exception {
120+
public void getBooleanPreferenceShouldReturnUserSuppliedValueWhenSet() {
121121
String key = "cheese";
122122
boolean value = true;
123123
profile.setPreference(key, value);
@@ -127,7 +127,7 @@ public void getBooleanPreferenceShouldReturnUserSuppliedValueWhenSet() throws Ex
127127
}
128128

129129
@Test
130-
public void getBooleanPreferenceShouldReturnDefaultValueWhenSet() throws Exception {
130+
public void getBooleanPreferenceShouldReturnDefaultValueWhenSet() {
131131
String key = "cheese";
132132

133133
boolean defaultValue = true;
@@ -153,15 +153,15 @@ public void shouldNotResetFrozenPreferences() throws Exception {
153153
}
154154

155155
@Test
156-
public void shouldInstallExtensionFromZip() throws IOException {
156+
public void shouldInstallExtensionFromZip() {
157157
profile.addExtension(InProject.locate(FIREBUG_PATH).toFile());
158158
File profileDir = profile.layoutOnDisk();
159159
File extensionDir = new File(profileDir, "extensions/[email protected]");
160160
assertTrue(extensionDir.exists());
161161
}
162162

163163
@Test
164-
public void shouldInstallWebExtensionFromZip() throws IOException {
164+
public void shouldInstallWebExtensionFromZip() {
165165
profile.addExtension(InProject.locate(MOOLTIPASS_PATH).toFile());
166166
File profileDir = profile.layoutOnDisk();
167167
File extensionDir = new File(profileDir, "extensions/[email protected]");
@@ -189,7 +189,7 @@ public void shouldInstallWebExtensionFromDirectory() throws IOException {
189189
}
190190

191191
@Test
192-
public void shouldInstallExtensionUsingClasspath() throws IOException {
192+
public void shouldInstallExtensionUsingClasspath() {
193193
profile.addExtension(SynthesizedFirefoxDriver.class, FIREBUG_RESOURCE_PATH);
194194
File profileDir = profile.layoutOnDisk();
195195
File extensionDir = new File(profileDir, "extensions/[email protected]");

0 commit comments

Comments
 (0)