From 55c366fde3134786bfae703387a41ea900180484 Mon Sep 17 00:00:00 2001 From: Andreas Tolfsen Date: Fri, 24 Feb 2017 17:44:11 +0000 Subject: [PATCH] geckodriver: marionette: add Get Timeouts command Source-Repo: https://github.com/mozilla/geckodriver Source-Revision: 140ab5a897d16d01418fc8aff94ae580eef49f2d --HG-- extra : rebase_source : ca327ed76cfc819270598648c0b85e949c3bbd57 --- testing/geckodriver/CHANGES.md | 6 +++++ testing/geckodriver/src/marionette.rs | 37 ++++++++++++++++++++++----- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/testing/geckodriver/CHANGES.md b/testing/geckodriver/CHANGES.md index 81fd4f202d55..37812b6cb0e2 100644 --- a/testing/geckodriver/CHANGES.md +++ b/testing/geckodriver/CHANGES.md @@ -4,9 +4,15 @@ All notable changes to this program is documented in this file. ## Unreleased +### Added +- Added routing and parsing for the [Get Timeouts](https://w3c.github.io/webdriver/webdriver-spec.html#dfn-get-timeouts) command + ### Changed - Now uses about:blank as the new tab document; this was previously disabled due to [bug 1333736](https://bugzilla.mozilla.org/show_bug.cgi?id=1333736) in Marionette +### Fixed +- Aligned the data structure accepted by the [Set Timeouts](https://w3c.github.io/webdriver/webdriver-spec.html#set-timeouts) command with the WebDriver specification + ## 0.14.0 (2017-01-31) ### Changed diff --git a/testing/geckodriver/src/marionette.rs b/testing/geckodriver/src/marionette.rs index 0fd6a68a781e..e5155866ba85 100644 --- a/testing/geckodriver/src/marionette.rs +++ b/testing/geckodriver/src/marionette.rs @@ -40,9 +40,9 @@ use webdriver::command::{ SwitchToFrameParameters, LocatorParameters, JavascriptCommandParameters, GetNamedCookieParameters, AddCookieParameters, TimeoutsParameters, ActionsParameters, TakeScreenshotParameters, WindowPositionParameters}; -use webdriver::response::{ - WebDriverResponse, NewSessionResponse, ValueResponse, WindowSizeResponse, - WindowPositionResponse, ElementRectResponse, CookieResponse, Cookie}; +use webdriver::response::{Cookie, CookieResponse, ElementRectResponse, NewSessionResponse, + TimeoutsResponse, ValueResponse, WebDriverResponse, + WindowPositionResponse, WindowSizeResponse}; use webdriver::common::{ Date, Nullable, WebElement, FrameId, ELEMENT_KEY}; use webdriver::error::{ErrorStatus, WebDriverError, WebDriverResult}; @@ -532,8 +532,33 @@ impl MarionetteSession { WebDriverResponse::Generic(ValueResponse::new(value.clone())) }, GetTimeouts => { - return Err(WebDriverError::new(ErrorStatus::UnsupportedOperation, - "Getting timeouts not yet supported")); + let script = try_opt!(try_opt!(resp.result + .find("script"), + ErrorStatus::UnknownError, + "Missing field: script") + .as_u64(), + ErrorStatus::UnknownError, + "Failed to interpret script timeout duration as u64"); + let page_load = try_opt!(try_opt!(resp.result + .find("pageLoad"), + ErrorStatus::UnknownError, + "Missing field: pageLoad") + .as_u64(), + ErrorStatus::UnknownError, + "Failed to interpret page load duration as u64"); + let implicit = try_opt!(try_opt!(resp.result + .find("implicit"), + ErrorStatus::UnknownError, + "Missing field: implicit") + .as_u64(), + ErrorStatus::UnknownError, + "Failed to interpret implicit search duration as u64"); + + WebDriverResponse::Timeouts(TimeoutsResponse { + script: script, + pageLoad: page_load, + implicit: implicit, + }) }, Status => panic!("Got status command that should already have been handled"), GetWindowHandles => { @@ -810,7 +835,7 @@ impl MarionetteCommand { GetWindowHandle => (Some("getWindowHandle"), None), GetWindowHandles => (Some("getWindowHandles"), None), CloseWindow => (Some("close"), None), - GetTimeouts => (None, None), + GetTimeouts => (Some("getTimeouts"), None), SetTimeouts(ref x) => (Some("timeouts"), Some(x.to_marionette())), SetWindowSize(ref x) => (Some("setWindowSize"), Some(x.to_marionette())), GetWindowSize => (Some("getWindowSize"), None),