Skip to content

Commit a009c52

Browse files
committed
Bringing MarionetteConnection in line with the current marionette state (FF33)
1 parent d0c863a commit a009c52

16 files changed

+62
-103
lines changed

Diff for: java/client/src/org/openqa/selenium/firefox/internal/MarionetteConnection.java

+30-65
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import org.openqa.selenium.firefox.ExtensionConnection;
2727
import org.openqa.selenium.firefox.FirefoxBinary;
2828
import org.openqa.selenium.firefox.FirefoxProfile;
29-
import org.openqa.selenium.firefox.NotConnectedException;
3029
import org.openqa.selenium.internal.Lock;
3130
import org.openqa.selenium.logging.LocalLogs;
3231
import org.openqa.selenium.logging.NeedsLocalLogs;
@@ -47,8 +46,6 @@
4746
import java.io.Reader;
4847
import java.net.ConnectException;
4948
import java.net.Socket;
50-
import java.net.URL;
51-
import java.util.Arrays;
5249
import java.util.List;
5350
import java.util.Map;
5451

@@ -64,7 +61,7 @@ public class MarionetteConnection implements ExtensionConnection, NeedsLocalLogs
6461
private File profileDir;
6562

6663
private static Map<String, String> seleniumToMarionetteCommandMap = ImmutableMap.<String, String>builder()
67-
.put(DriverCommand.GET, "goUrl")
64+
.put(DriverCommand.GET, "get")
6865
.put(DriverCommand.GET_CURRENT_WINDOW_HANDLE, "getWindow")
6966
.put(DriverCommand.GET_WINDOW_HANDLES, "getWindows")
7067
.put(DriverCommand.CLOSE, "closeWindow")
@@ -162,6 +159,7 @@ public void start() throws IOException {
162159
// This initializes the "actor" for future communication with this instance.
163160
sendCommand(serializeCommand(new Command(null, "getMarionetteID")));
164161
String getMarionetteIdRawResponse = receiveResponse();
162+
System.out.println(getMarionetteIdRawResponse);
165163
Map<String, Object> map = new JsonToBeanConverter().convert(Map.class,
166164
getMarionetteIdRawResponse);
167165
marionetteId = map.get("id").toString();
@@ -191,14 +189,8 @@ public Response execute(Command command) throws IOException {
191189
Map<String, Object> map = new JsonToBeanConverter().convert(Map.class, rawResponse);
192190
Response response;
193191
if (DriverCommand.NEW_SESSION.equals(command.getName())) {
194-
// If we're starting a new session, we need to return the response
195-
// with that session.
196-
// ***************************************************************
197-
// Marionette Compliance Issue: The response should return the
198-
// newly created session ID in the "sessionId" member of the
199-
// returned JSON object.
200-
// ***************************************************************
201-
response = new Response(new SessionId(map.get("value").toString()));
192+
// See https://bugzilla.mozilla.org/show_bug.cgi?id=1073732
193+
response = new Response(new SessionId(new BeanToJsonConverter().convert(map.get("value"))));
202194
response.setValue(Maps.newHashMap());
203195

204196
} else {
@@ -217,17 +209,27 @@ public Response execute(Command command) throws IOException {
217209
// }
218210
// ***************************************************************
219211
response = new Response();
220-
Map<String, Object> errorMap = (Map<String, Object>) map.get("error");
221-
if (errorMap != null) {
222-
response.setStatus(Integer.parseInt(errorMap.get("status").toString()));
223-
errorMap.remove("status");
224-
response.setValue(errorMap);
212+
Object value = map.get("error");
213+
if (value != null) {
214+
if (value instanceof Map) {
215+
Map<String, Object> errorMap = (Map<String, Object>) value;
216+
if (errorMap != null) {
217+
response.setStatus(Integer.parseInt(errorMap.get("status").toString()));
218+
errorMap.remove("status");
219+
response.setValue(errorMap);
220+
}
221+
} else {
222+
response.setStatus(ErrorCodes.UNHANDLED_ERROR);
223+
response.setValue(value + ": " + map.get("message"));
224+
}
225225
}
226226

227227
} else {
228+
response = new JsonToBeanConverter().convert(Response.class, rawResponse);
229+
228230
// ***************************************************************
229-
// Marionette Compliance Issue: Responses from findElement and
230-
// findElements are returned with raw element IDs as the value.
231+
// Marionette Compliance Issue: Responses from findElements
232+
// are returned with raw element IDs as the value.
231233
// This should be a JSON object with the following structure:
232234
//
233235
// { "ELEMENT": "<element ID goes here>" }
@@ -236,11 +238,7 @@ public Response execute(Command command) throws IOException {
236238
// a raw string and an element reference returned from the
237239
// executeScript command.
238240
// ***************************************************************
239-
response = new JsonToBeanConverter().convert(Response.class, rawResponse);
240-
241-
if (DriverCommand.FIND_ELEMENT.equals(command.getName())
242-
|| DriverCommand.FIND_CHILD_ELEMENT.equals(command.getName())
243-
|| DriverCommand.GET_ACTIVE_ELEMENT.equals(command.getName()))
241+
if (DriverCommand.GET_ACTIVE_ELEMENT.equals(command.getName()))
244242
{
245243
if (response.getStatus() == ErrorCodes.SUCCESS) {
246244
Map<String, Object> wrappedElement = Maps.newHashMap();
@@ -278,51 +276,17 @@ private String serializeCommand(Command command) {
278276
if (DriverCommand.NEW_SESSION.equals(commandName)) {
279277
params.remove("desiredCapabilities");
280278

281-
} else if (DriverCommand.GET.equals(commandName)) {
282-
renameParameter(params, "url", "value");
283-
284279
} else if (DriverCommand.SET_TIMEOUT.equals(commandName)) {
285280
String timeoutType = (String) params.get("type");
286-
// System.out.println("timeout type = " + timeoutType);
287281
if ("implicit".equals(timeoutType)) {
288282
commandName = "setSearchTimeout";
289283
} else if ("script".equals(timeoutType)) {
290284
commandName = "setScriptTimeout";
291285
}
292286
params.remove("type");
293-
renameParameter(params, "ms", "value");
294-
295-
} else if (DriverCommand.EXECUTE_SCRIPT.equals(commandName)
296-
|| DriverCommand.EXECUTE_ASYNC_SCRIPT.equals(commandName)) {
297-
renameParameter(params, "script", "value");
298-
299-
} else if (DriverCommand.SWITCH_TO_WINDOW.equals(commandName)) {
300-
renameParameter(params, "name", "value");
301-
302-
} else if (DriverCommand.SWITCH_TO_FRAME.equals(commandName)) {
303-
Object target = params.get("id");
304-
if (target instanceof Map) {
305-
String elementId = (String) ((Map<String,Object>) target).get("ELEMENT");
306-
params.put("element", elementId);
307-
params.remove("id");
308-
309-
} else {
310-
renameParameter(params, "id", "value");
311-
}
312287

313288
} else if (DriverCommand.FIND_CHILD_ELEMENT.equals(commandName)
314-
|| DriverCommand.FIND_CHILD_ELEMENTS.equals(commandName)
315-
|| DriverCommand.CLICK_ELEMENT.equals(commandName)
316-
|| DriverCommand.CLEAR_ELEMENT.equals(commandName)
317-
|| DriverCommand.GET_ELEMENT_ATTRIBUTE.equals(commandName)
318-
|| DriverCommand.GET_ELEMENT_TEXT.equals(commandName)
319-
|| DriverCommand.SEND_KEYS_TO_ELEMENT.equals(commandName)
320-
|| DriverCommand.IS_ELEMENT_SELECTED.equals(commandName)
321-
|| DriverCommand.IS_ELEMENT_ENABLED.equals(commandName)
322-
|| DriverCommand.IS_ELEMENT_DISPLAYED.equals(commandName)
323-
|| DriverCommand.GET_ELEMENT_SIZE.equals(commandName)
324-
|| DriverCommand.GET_ELEMENT_LOCATION.equals(commandName)
325-
|| DriverCommand.GET_ELEMENT_TAG_NAME.equals(commandName)) {
289+
|| DriverCommand.FIND_CHILD_ELEMENTS.equals(commandName)) {
326290
renameParameter(params, "id", "element");
327291

328292
} else if (DriverCommand.CLICK.equals(commandName)
@@ -349,11 +313,12 @@ private String serializeCommand(Command command) {
349313

350314
Map<String, Object> map = Maps.newHashMap();
351315
map.put("to", marionetteId != null ? marionetteId : "root");
352-
map.put("type", commandName);
316+
map.put("name", commandName);
353317
if (command.getSessionId() != null) {
354-
map.put("session", command.getSessionId().toString());
318+
// See https://bugzilla.mozilla.org/show_bug.cgi?id=1073732
319+
map.put("sessionId", new JsonToBeanConverter().convert(Map.class, command.getSessionId().toString()));
355320
}
356-
map.putAll(params);
321+
map.put("parameters", params);
357322

358323
return new BeanToJsonConverter().convert(map);
359324
}
@@ -365,8 +330,8 @@ private void renameParameter(Map<String, Object> params, String origParName, Str
365330
}
366331

367332
private void sendCommand(String commandAsString) {
368-
String line = "" + commandAsString.length() + ":" + commandAsString + " ";
369-
// System.out.println(line);
333+
String line = "" + commandAsString.length() + ":" + commandAsString;
334+
System.out.println(line);
370335
writer.write(line);
371336
writer.flush();
372337
}
@@ -383,7 +348,7 @@ private String receiveResponse() throws IOException {
383348
response.append(buf, 0, len);
384349
}
385350

386-
// System.out.println("<- |" + response.toString() + "|");
351+
System.out.println("<- |" + response.toString() + "|");
387352

388353
String[] parts = response.toString().split(":", 2);
389354
int length = Integer.parseInt(parts[0]);

Diff for: java/client/test/org/openqa/selenium/AtomsInjectionTest.java

+3
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,19 @@
1717
package org.openqa.selenium;
1818

1919
import org.junit.Test;
20+
import org.openqa.selenium.testing.Ignore;
2021
import org.openqa.selenium.testing.JUnit4TestBase;
2122
import org.openqa.selenium.testing.JavascriptEnabled;
2223

2324
import static org.junit.Assert.assertEquals;
25+
import static org.openqa.selenium.testing.Ignore.Driver.MARIONETTE;
2426

2527
public class AtomsInjectionTest extends JUnit4TestBase {
2628

2729
/** http://code.google.com/p/selenium/issues/detail?id=1333 */
2830
@JavascriptEnabled
2931
@Test
32+
@Ignore({MARIONETTE})
3033
public void testInjectingAtomShouldNotTrampleOnUnderscoreGlobal() {
3134
driver.get(pages.underscorePage);
3235
driver.findElement(By.tagName("body"));

Diff for: java/client/test/org/openqa/selenium/ClickScrollingTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public void testShouldBeAbleToClickOnAnElementHiddenByDoubleOverflow() {
104104
}
105105

106106
@JavascriptEnabled
107-
@Ignore(value = {IPHONE, SAFARI, MARIONETTE}, reason = "Safari: failed, iPhone: untested")
107+
@Ignore(value = {IPHONE, SAFARI}, reason = "Safari: failed, iPhone: untested")
108108
@Test
109109
public void testShouldBeAbleToClickOnAnElementHiddenByYOverflow() {
110110
driver.get(appServer.whereIs("scrolling_tests/page_with_y_overflow_auto.html"));

Diff for: java/client/test/org/openqa/selenium/ClickTest.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ public void testCanClickOnALinkThatContainsTextWrappedInASpan() {
234234
}
235235

236236
@Test
237+
@Ignore(MARIONETTE)
237238
public void testCanClickOnALinkThatContainsEmbeddedBlockElements() {
238239
driver.findElement(By.id("embeddedBlock")).click();
239240
wait.until(titleIs("XHTML Test Page"));
@@ -330,8 +331,7 @@ public void testShouldBeAbleToClickOnRTLLanguageLink() {
330331
}
331332

332333
@Test
333-
@Ignore(value = {OPERA, OPERA_MOBILE, ANDROID, IPHONE, MARIONETTE}, reason
334-
= "not tested")
334+
@Ignore(value = {OPERA, OPERA_MOBILE, ANDROID, IPHONE}, reason = "not tested")
335335
public void testShouldBeAbleToClickOnLinkInAbsolutelyPositionedFooter() {
336336
String url = appServer.whereIs("fixedFooterNoScroll.html");
337337
driver.get(url);
@@ -343,8 +343,7 @@ public void testShouldBeAbleToClickOnLinkInAbsolutelyPositionedFooter() {
343343
}
344344

345345
@Test
346-
@Ignore(value = {OPERA, OPERA_MOBILE, ANDROID, IPHONE, MARIONETTE}, reason
347-
= "not tested")
346+
@Ignore(value = {OPERA, OPERA_MOBILE, ANDROID, IPHONE}, reason = "not tested")
348347
public void testShouldBeAbleToClickOnLinkInAbsolutelyPositionedFooterInQuirksMode() {
349348
String url = appServer.whereIs("fixedFooterNoScrollQuirksMode.html");
350349
driver.get(url);

Diff for: java/client/test/org/openqa/selenium/CorrectEventFiringTest.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ public void testShouldFireMouseMoveEventWhenClicking() {
121121

122122
@JavascriptEnabled
123123
@Test
124-
@Ignore(MARIONETTE)
125124
public void testShouldNotThrowIfEventHandlerThrows() {
126125
driver.get(pages.javascriptPage);
127126

@@ -290,7 +289,7 @@ public void testClearingAnElementShouldCauseTheOnChangeHandlerToFire() {
290289
}
291290

292291
@JavascriptEnabled
293-
@Ignore(value = {IPHONE, ANDROID, MARIONETTE}, reason = "iPhone: sendKeys implementation is incorrect")
292+
@Ignore(value = {IPHONE, ANDROID}, reason = "iPhone: sendKeys implementation is incorrect")
294293
@Test
295294
public void testSendingKeysToAnotherElementShouldCauseTheBlurEventToFire() {
296295
assumeFalse(browserNeedsFocusOnThisOs(driver));
@@ -304,7 +303,7 @@ public void testSendingKeysToAnotherElementShouldCauseTheBlurEventToFire() {
304303
}
305304

306305
@JavascriptEnabled
307-
@Ignore(value = {IPHONE, ANDROID, MARIONETTE}, reason = "iPhone: sendKeys implementation is incorrect")
306+
@Ignore(value = {IPHONE, ANDROID}, reason = "iPhone: sendKeys implementation is incorrect")
308307
@Test
309308
public void testSendingKeysToAnElementShouldCauseTheFocusEventToFire() {
310309
assumeFalse(browserNeedsFocusOnThisOs(driver));

Diff for: java/client/test/org/openqa/selenium/CssValueTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void testGetCssValueShouldReturnStandardizedColour() {
6666
}
6767

6868
@JavascriptEnabled
69-
@Ignore({ANDROID, IPHONE, OPERA, HTMLUNIT, MARIONETTE})
69+
@Ignore({ANDROID, IPHONE, OPERA, HTMLUNIT})
7070
@Test
7171
public void testShouldAllowInheritedStylesToBeUsed() {
7272
driver.get(pages.javascriptPage);

Diff for: java/client/test/org/openqa/selenium/ElementEqualityTest.java

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public void testSameElementLookedUpDifferentWaysShouldBeEqual() {
4949
}
5050

5151
@Test
52+
@Ignore(value = MARIONETTE, reason = "Marionette does not recognize the packet type elementEquals")
5253
public void testDifferentElementsShouldNotBeEqual() {
5354
driver.get(pages.simpleTestPage);
5455

Diff for: java/client/test/org/openqa/selenium/ExecutingJavascriptTest.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,6 @@ public void testShouldBeAbleToGrabTheBodyOfFrameOnceSwitchedTo() {
443443
@SuppressWarnings("unchecked")
444444
@JavascriptEnabled
445445
@Test
446-
@Ignore(MARIONETTE)
447446
public void testShouldBeAbleToReturnAnArrayOfWebElements() {
448447
driver.get(pages.formPage);
449448

@@ -484,7 +483,6 @@ public void testShouldBeAbleToExecuteABigChunkOfJavascriptCode() throws IOExcept
484483
@SuppressWarnings("unchecked")
485484
@JavascriptEnabled
486485
@Test
487-
@Ignore(MARIONETTE)
488486
public void testShouldBeAbleToExecuteScriptAndReturnElementsList() {
489487
driver.get(pages.formPage);
490488
String scriptToExec = "return document.getElementsByName('snack');";
@@ -539,7 +537,7 @@ public void testCanHandleAnArrayOfElementsAsAnObjectArray() {
539537
}
540538

541539
@JavascriptEnabled
542-
@Ignore(value = {ANDROID, OPERA, OPERA_MOBILE, MARIONETTE},
540+
@Ignore(value = {ANDROID, OPERA, OPERA_MOBILE},
543541
reason = "Opera obeys the method contract. Android not tested")
544542
@Test
545543
public void testCanPassAMapAsAParameter() {

Diff for: java/client/test/org/openqa/selenium/FormHandlingTest.java

+2-5
Original file line numberDiff line numberDiff line change
@@ -77,31 +77,28 @@ public void testShouldBeAbleToClickImageButtons() {
7777
}
7878

7979
@Test
80-
@Ignore(MARIONETTE)
8180
public void testShouldBeAbleToSubmitForms() {
8281
driver.get(pages.formPage);
8382
driver.findElement(By.name("login")).submit();
8483
wait.until(titleIs("We Arrive Here"));
8584
}
8685

8786
@Test
88-
@Ignore(MARIONETTE)
8987
public void testShouldSubmitAFormWhenAnyInputElementWithinThatFormIsSubmitted() {
9088
driver.get(pages.formPage);
9189
driver.findElement(By.id("checky")).submit();
9290
wait.until(titleIs("We Arrive Here"));
9391
}
9492

9593
@Test
96-
@Ignore(MARIONETTE)
9794
public void testShouldSubmitAFormWhenAnyElementWithinThatFormIsSubmitted() {
9895
driver.get(pages.formPage);
9996
driver.findElement(By.xpath("//form/p")).submit();
10097
wait.until(titleIs("We Arrive Here"));
10198
}
10299

103100
@Test(expected = NoSuchElementException.class)
104-
@Ignore(value = {ANDROID, IPHONE, OPERA, PHANTOMJS, SAFARI, OPERA_MOBILE, MARIONETTE})
101+
@Ignore(value = {ANDROID, IPHONE, OPERA, PHANTOMJS, SAFARI, OPERA_MOBILE})
105102
public void testShouldNotBeAbleToSubmitAFormThatDoesNotExist() {
106103
driver.get(pages.formPage);
107104
driver.findElement(By.name("SearchableText")).submit();
@@ -206,7 +203,7 @@ public void testShouldBeAbleToSendKeysToAFileUploadInputElementInAnXhtmlDocument
206203
assertTrue(uploadPath.endsWith(file.getName()));
207204
}
208205

209-
@Ignore(value = {IPHONE, ANDROID, OPERA, SAFARI, MARIONETTE},
206+
@Ignore(value = {IPHONE, ANDROID, OPERA, SAFARI},
210207
reason = "Does not yet support file uploads", issues = {4220})
211208
@Test
212209
public void testShouldBeAbleToUploadTheSameFileTwice() throws IOException {

Diff for: java/client/test/org/openqa/selenium/FrameSwitchingTest.java

-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ public void tearDown() throws Exception {
6464
//
6565
// ----------------------------------------------------------------------------------------------
6666
@Test
67-
@Ignore(MARIONETTE)
6867
public void testShouldAlwaysFocusOnTheTopMostFrameAfterANavigationEvent() {
6968
driver.get(pages.framesetPage);
7069
driver.findElement(By.tagName("frameset")); // Test passes if this does not throw.
@@ -101,7 +100,6 @@ public void testShouldOpenPageWithBrokenFrameset() {
101100
//
102101
// ----------------------------------------------------------------------------------------------
103102
@Test
104-
@Ignore(MARIONETTE)
105103
public void testShouldBeAbleToSwitchToAFrameByItsIndex() {
106104
driver.get(pages.framesetPage);
107105
driver.switchTo().frame(1);

Diff for: java/client/test/org/openqa/selenium/MiscTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public void testShouldReturnTheSourceOfAPage() {
7878
}
7979

8080
@JavascriptEnabled
81-
@Ignore(value = {ANDROID, CHROME, IE, SAFARI, OPERA, OPERA_MOBILE, MARIONETTE},
81+
@Ignore(value = {ANDROID, CHROME, IE, SAFARI, OPERA, OPERA_MOBILE},
8282
reason = "Chrome, Safari: returns XML content formatted for display as HTML document"
8383
+ "Opera: includes XML doctype"
8484
+ "Others: untested")

Diff for: java/client/test/org/openqa/selenium/PageLoadingTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ public void testShouldDoNothingIfThereIsNothingToGoBackTo() {
274274
assertThat(driver.getTitle(), equalTo(originalTitle));
275275
}
276276

277-
@Ignore(value = {ANDROID, SAFARI, MARIONETTE}, issues = {3771})
277+
@Ignore(value = {ANDROID, SAFARI}, issues = {3771})
278278
@Test
279279
public void testShouldBeAbleToNavigateBackInTheBrowserHistory() {
280280
driver.get(pages.formPage);
@@ -298,7 +298,7 @@ public void testShouldBeAbleToNavigateBackInTheBrowserHistoryInPresenceOfIframes
298298
wait.until(titleIs("XHTML Test Page"));
299299
}
300300

301-
@Ignore(value = {ANDROID, SAFARI, MARIONETTE}, issues = {3771})
301+
@Ignore(value = {ANDROID, SAFARI}, issues = {3771})
302302
@Test
303303
public void testShouldBeAbleToNavigateForwardsInTheBrowserHistory() {
304304
driver.get(pages.formPage);

0 commit comments

Comments
 (0)