Changeset 253883 in webkit


Ignore:
Timestamp:
Dec 23, 2019 2:42:26 AM (4 years ago)
Author:
Carlos Garcia Campos
Message:

WebDriver: fix handling of session timeouts for values higher than MAX_INT
https://bugs.webkit.org/show_bug.cgi?id=204114

Reviewed by Brian Burg.

Source/JavaScriptCore:

Fix generation of code with optional number in stack variable.

  • inspector/scripts/codegen/cpp_generator.py:

(CppGenerator.cpp_type_for_stack_in_parameter): Do not use Optional for numbers either.

  • inspector/scripts/tests/generic/expected/commands-with-optional-call-return-parameters.json-result:

Source/WebDriver:

Use double instead of Seconds for handling timeouts.

  • Capabilities.h:
  • Session.cpp:

(WebDriver::Session::getTimeouts): Handle the case of script timeout being null.
(WebDriver::Session::go):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::findElements):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::executeScript): Do not pass a timeout when it's null.

  • Session.h:

(WebDriver::Session::scriptTimeout const):
(WebDriver::Session::pageLoadTimeout const):
(WebDriver::Session::implicitWaitTimeout const):

  • WebDriverService.cpp:

(WebDriver::deserializeTimeouts): Add IgnoreUnknownTimeout, since we should only fail when processing
capabilities, but not when setting new timeouts. Also handle the case of script timeout being null.
(WebDriver::WebDriverService::parseCapabilities const): Pass IgnoreUnknownTimeout::No to deserializeTimeouts.
(WebDriver::WebDriverService::validatedCapabilities const): Ditto.
(WebDriver::WebDriverService::createSession): Handle the case of script timeout being null.
(WebDriver::WebDriverService::setTimeouts): Pass IgnoreUnknownTimeout::Yes to deserializeTimeouts.

Source/WebKit:

Use number instead of integer for all optional timeout parameters. In the case of script timeout, not passing a
value means a timeout should not be used, so use Optional<double> also for the IPC message and handle the
optional value in the web process to not set any timeout in that case.

  • UIProcess/Automation/Automation.json:
  • UIProcess/Automation/WebAutomationSession.cpp:

(WebKit::WebAutomationSession::waitForNavigationToComplete):
(WebKit::WebAutomationSession::navigateBrowsingContext):
(WebKit::WebAutomationSession::goBackInBrowsingContext):
(WebKit::WebAutomationSession::goForwardInBrowsingContext):
(WebKit::WebAutomationSession::reloadBrowsingContext):
(WebKit::WebAutomationSession::evaluateJavaScriptFunction):

  • UIProcess/Automation/WebAutomationSession.h:
  • WebProcess/Automation/WebAutomationSessionProxy.cpp:

(WebKit::WebAutomationSessionProxy::evaluateJavaScriptFunction):

  • WebProcess/Automation/WebAutomationSessionProxy.h:
  • WebProcess/Automation/WebAutomationSessionProxy.js:

(let.AutomationSessionProxy.prototype.evaluateJavaScriptFunction):

  • WebProcess/Automation/WebAutomationSessionProxy.messages.in:
Location:
trunk/Source
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r253870 r253883  
     12019-12-23  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        WebDriver: fix handling of session timeouts for values higher than MAX_INT
     4        https://bugs.webkit.org/show_bug.cgi?id=204114
     5
     6        Reviewed by Brian Burg.
     7
     8        Fix generation of code with optional number in stack variable.
     9
     10        * inspector/scripts/codegen/cpp_generator.py:
     11        (CppGenerator.cpp_type_for_stack_in_parameter): Do not use Optional for numbers either.
     12        * inspector/scripts/tests/generic/expected/commands-with-optional-call-return-parameters.json-result:
     13
    1142019-12-22  Yusuke Suzuki  <ysuzuki@apple.com>
    215
  • trunk/Source/JavaScriptCore/inspector/scripts/codegen/cpp_generator.py

    r239846 r253883  
    276276            if _type.qualified_name() in ['any', 'object']:
    277277                return "RefPtr<%s>" % CppGenerator.cpp_name_for_primitive_type(_type)
    278             elif parameter.is_optional and _type.qualified_name() not in ['boolean', 'string', 'integer']:
     278            elif parameter.is_optional and _type.qualified_name() not in ['boolean', 'string', 'integer', 'number']:
    279279                return "Optional<%s>" % cpp_name
    280280            else:
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/generic/expected/commands-with-optional-call-return-parameters.json-result

    r251395 r253883  
    262262    String opt_in_notes = m_backendDispatcher->getString(parameters.get(), "notes"_s, &opt_in_notes_valueFound);
    263263    bool opt_in_timestamp_valueFound = false;
    264     Optional<double> opt_in_timestamp = m_backendDispatcher->getDouble(parameters.get(), "timestamp"_s, &opt_in_timestamp_valueFound);
     264    double opt_in_timestamp = m_backendDispatcher->getDouble(parameters.get(), "timestamp"_s, &opt_in_timestamp_valueFound);
    265265    bool opt_in_values_valueFound = false;
    266266    RefPtr<JSON::Object> opt_in_values = m_backendDispatcher->getObject(parameters.get(), "values"_s, &opt_in_values_valueFound);
  • trunk/Source/WebDriver/Capabilities.h

    r253030 r253883  
    2828#include <utility>
    2929#include <wtf/Forward.h>
    30 #include <wtf/Seconds.h>
    3130#include <wtf/URL.h>
    3231#include <wtf/Vector.h>
     
    3635
    3736struct Timeouts {
    38     Optional<Seconds> script;
    39     Optional<Seconds> pageLoad;
    40     Optional<Seconds> implicit;
     37    Optional<double> script;
     38    Optional<double> pageLoad;
     39    Optional<double> implicit;
    4140};
    4241
  • trunk/Source/WebDriver/ChangeLog

    r253475 r253883  
     12019-12-23  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        WebDriver: fix handling of session timeouts for values higher than MAX_INT
     4        https://bugs.webkit.org/show_bug.cgi?id=204114
     5
     6        Reviewed by Brian Burg.
     7
     8        Use double instead of Seconds for handling timeouts.
     9
     10        * Capabilities.h:
     11        * Session.cpp:
     12        (WebDriver::Session::getTimeouts): Handle the case of script timeout being null.
     13        (WebDriver::Session::go):
     14        (WebDriver::Session::back):
     15        (WebDriver::Session::forward):
     16        (WebDriver::Session::refresh):
     17        (WebDriver::Session::findElements):
     18        (WebDriver::Session::waitForNavigationToComplete):
     19        (WebDriver::Session::executeScript): Do not pass a timeout when it's null.
     20        * Session.h:
     21        (WebDriver::Session::scriptTimeout const):
     22        (WebDriver::Session::pageLoadTimeout const):
     23        (WebDriver::Session::implicitWaitTimeout const):
     24        * WebDriverService.cpp:
     25        (WebDriver::deserializeTimeouts): Add IgnoreUnknownTimeout, since we should only fail when processing
     26        capabilities, but not when setting new timeouts. Also handle the case of script timeout being null.
     27        (WebDriver::WebDriverService::parseCapabilities const): Pass IgnoreUnknownTimeout::No to deserializeTimeouts.
     28        (WebDriver::WebDriverService::validatedCapabilities const): Ditto.
     29        (WebDriver::WebDriverService::createSession): Handle the case of script timeout being null.
     30        (WebDriver::WebDriverService::setTimeouts): Pass IgnoreUnknownTimeout::Yes to deserializeTimeouts.
     31
    1322019-12-13  Jim Mason  <jmason@ibinx.com>
    233
  • trunk/Source/WebDriver/Session.cpp

    r253425 r253883  
    3939
    4040// https://w3c.github.io/webdriver/webdriver-spec.html#dfn-session-script-timeout
    41 static const Seconds defaultScriptTimeout = 30_s;
     41static const double defaultScriptTimeout = 30000;
    4242// https://w3c.github.io/webdriver/webdriver-spec.html#dfn-session-page-load-timeout
    43 static const Seconds defaultPageLoadTimeout = 300_s;
     43static const double defaultPageLoadTimeout = 300000;
    4444// https://w3c.github.io/webdriver/webdriver-spec.html#dfn-session-implicit-wait-timeout
    45 static const Seconds defaultImplicitWaitTimeout = 0_s;
     45static const double defaultImplicitWaitTimeout = 0;
    4646
    4747const String& Session::webElementIdentifier()
     
    128128{
    129129    RefPtr<JSON::Object> parameters = JSON::Object::create();
    130     parameters->setInteger("script"_s, m_scriptTimeout.millisecondsAs<int>());
    131     parameters->setInteger("pageLoad"_s, m_pageLoadTimeout.millisecondsAs<int>());
    132     parameters->setInteger("implicit"_s, m_implicitWaitTimeout.millisecondsAs<int>());
     130    if (m_scriptTimeout == std::numeric_limits<double>::infinity())
     131        parameters->setValue("script"_s, JSON::Value::null());
     132    else
     133        parameters->setDouble("script"_s, m_scriptTimeout);
     134    parameters->setDouble("pageLoad"_s, m_pageLoadTimeout);
     135    parameters->setDouble("implicit"_s, m_implicitWaitTimeout);
    133136    completionHandler(CommandResult::success(WTFMove(parameters)));
    134137}
     
    301304        parameters->setString("handle"_s, m_toplevelBrowsingContext.value());
    302305        parameters->setString("url"_s, url);
    303         parameters->setInteger("pageLoadTimeout"_s, m_pageLoadTimeout.millisecondsAs<int>());
     306        parameters->setDouble("pageLoadTimeout"_s, m_pageLoadTimeout);
    304307        if (auto pageLoadStrategy = pageLoadStrategyString())
    305308            parameters->setString("pageLoadStrategy"_s, pageLoadStrategy.value());
     
    364367        RefPtr<JSON::Object> parameters = JSON::Object::create();
    365368        parameters->setString("handle"_s, m_toplevelBrowsingContext.value());
    366         parameters->setInteger("pageLoadTimeout"_s, m_pageLoadTimeout.millisecondsAs<int>());
     369        parameters->setDouble("pageLoadTimeout"_s, m_pageLoadTimeout);
    367370        if (auto pageLoadStrategy = pageLoadStrategyString())
    368371            parameters->setString("pageLoadStrategy"_s, pageLoadStrategy.value());
     
    392395        RefPtr<JSON::Object> parameters = JSON::Object::create();
    393396        parameters->setString("handle"_s, m_toplevelBrowsingContext.value());
    394         parameters->setInteger("pageLoadTimeout"_s, m_pageLoadTimeout.millisecondsAs<int>());
     397        parameters->setDouble("pageLoadTimeout"_s, m_pageLoadTimeout);
    395398        if (auto pageLoadStrategy = pageLoadStrategyString())
    396399            parameters->setString("pageLoadStrategy"_s, pageLoadStrategy.value());
     
    420423        RefPtr<JSON::Object> parameters = JSON::Object::create();
    421424        parameters->setString("handle"_s, m_toplevelBrowsingContext.value());
    422         parameters->setInteger("pageLoadTimeout"_s, m_pageLoadTimeout.millisecondsAs<int>());
     425        parameters->setDouble("pageLoadTimeout"_s, m_pageLoadTimeout);
    423426        if (auto pageLoadStrategy = pageLoadStrategyString())
    424427            parameters->setString("pageLoadStrategy"_s, pageLoadStrategy.value());
     
    10281031        arguments->pushString(JSON::Value::create(selector)->toJSONString());
    10291032        arguments->pushString(JSON::Value::create(mode == FindElementsMode::Single)->toJSONString());
    1030         arguments->pushString(JSON::Value::create(m_implicitWaitTimeout.milliseconds())->toJSONString());
     1033        arguments->pushString(JSON::Value::create(m_implicitWaitTimeout)->toJSONString());
    10311034
    10321035        RefPtr<JSON::Object> parameters = JSON::Object::create();
     
    10391042        // If there's an implicit wait, use one second more as callback timeout.
    10401043        if (m_implicitWaitTimeout)
    1041             parameters->setInteger("callbackTimeout"_s, Seconds(m_implicitWaitTimeout + 1_s).millisecondsAs<int>());
     1044            parameters->setDouble("callbackTimeout"_s, m_implicitWaitTimeout + 1000);
    10421045
    10431046        m_host->sendCommandToBackend("evaluateJavaScriptFunction"_s, WTFMove(parameters), [this, protectedThis = protectedThis.copyRef(), mode, completionHandler = WTFMove(completionHandler)](SessionHost::CommandResponse&& response) {
     
    15061509    if (m_currentBrowsingContext)
    15071510        parameters->setString("frameHandle"_s, m_currentBrowsingContext.value());
    1508     parameters->setInteger("pageLoadTimeout"_s, m_pageLoadTimeout.millisecondsAs<int>());
     1511    parameters->setDouble("pageLoadTimeout"_s, m_pageLoadTimeout);
    15091512    if (auto pageLoadStrategy = pageLoadStrategyString())
    15101513        parameters->setString("pageLoadStrategy"_s, pageLoadStrategy.value());
     
    21352138        if (mode == ExecuteScriptMode::Async) {
    21362139            parameters->setBoolean("expectsImplicitCallbackArgument"_s, true);
    2137             if (m_scriptTimeout)
    2138                 parameters->setInteger("callbackTimeout"_s, m_scriptTimeout.millisecondsAs<int>());
     2140            if (m_scriptTimeout != std::numeric_limits<double>::infinity())
     2141                parameters->setDouble("callbackTimeout"_s, m_scriptTimeout);
    21392142        }
    21402143        m_host->sendCommandToBackend("evaluateJavaScriptFunction"_s, WTFMove(parameters), [this, protectedThis = protectedThis.copyRef(), completionHandler = WTFMove(completionHandler)](SessionHost::CommandResponse&& response) mutable {
  • trunk/Source/WebDriver/Session.h

    r253030 r253883  
    5151    const Capabilities& capabilities() const;
    5252    bool isConnected() const;
    53     Seconds scriptTimeout() const  { return m_scriptTimeout; }
    54     Seconds pageLoadTimeout() const { return m_pageLoadTimeout; }
    55     Seconds implicitWaitTimeout() const { return m_implicitWaitTimeout; }
     53    double scriptTimeout() const  { return m_scriptTimeout; }
     54    double pageLoadTimeout() const { return m_pageLoadTimeout; }
     55    double implicitWaitTimeout() const { return m_implicitWaitTimeout; }
    5656    static const String& webElementIdentifier();
    5757
     
    208208
    209209    std::unique_ptr<SessionHost> m_host;
    210     Seconds m_scriptTimeout;
    211     Seconds m_pageLoadTimeout;
    212     Seconds m_implicitWaitTimeout;
     210    double m_scriptTimeout;
     211    double m_pageLoadTimeout;
     212    double m_implicitWaitTimeout;
    213213    Optional<String> m_toplevelBrowsingContext;
    214214    Optional<String> m_currentBrowsingContext;
  • trunk/Source/WebDriver/WebDriverService.cpp

    r253030 r253883  
    321321}
    322322
    323 static Optional<Timeouts> deserializeTimeouts(JSON::Object& timeoutsObject)
     323enum class IgnoreUnknownTimeout { No, Yes };
     324
     325static Optional<Timeouts> deserializeTimeouts(JSON::Object& timeoutsObject, IgnoreUnknownTimeout ignoreUnknownTimeout)
    324326{
    325327    // §8.5 Set Timeouts.
     
    331333            continue;
    332334
     335        if (it->key == "script" && it->value->isNull()) {
     336            timeouts.script = std::numeric_limits<double>::infinity();
     337            continue;
     338        }
     339
    333340        // If value is not an integer, or it is less than 0 or greater than the maximum safe integer, return error with error code invalid argument.
    334341        auto timeoutMS = unsignedValue(*it->value);
     
    337344
    338345        if (it->key == "script")
    339             timeouts.script = Seconds::fromMilliseconds(timeoutMS.value());
     346            timeouts.script = timeoutMS.value();
    340347        else if (it->key == "pageLoad")
    341             timeouts.pageLoad = Seconds::fromMilliseconds(timeoutMS.value());
     348            timeouts.pageLoad = timeoutMS.value();
    342349        else if (it->key == "implicit")
    343             timeouts.implicit = Seconds::fromMilliseconds(timeoutMS.value());
    344         else
     350            timeouts.implicit = timeoutMS.value();
     351        else if (ignoreUnknownTimeout == IgnoreUnknownTimeout::No)
    345352            return WTF::nullopt;
    346353    }
     
    488495    RefPtr<JSON::Object> timeouts;
    489496    if (matchedCapabilities.getObject("timeouts"_s, timeouts))
    490         capabilities.timeouts = deserializeTimeouts(*timeouts);
     497        capabilities.timeouts = deserializeTimeouts(*timeouts, IgnoreUnknownTimeout::No);
    491498    String pageLoadStrategy;
    492499    if (matchedCapabilities.getString("pageLoadStrategy"_s, pageLoadStrategy))
     
    550557        } else if (it->key == "timeouts") {
    551558            RefPtr<JSON::Object> timeouts;
    552             if (!it->value->asObject(timeouts) || !deserializeTimeouts(*timeouts))
     559            if (!it->value->asObject(timeouts) || !deserializeTimeouts(*timeouts, IgnoreUnknownTimeout::No))
    553560                return nullptr;
    554561            result->setValue(it->key, RefPtr<JSON::Value>(it->value));
     
    844851                capabilitiesObject->setObject("proxy"_s, JSON::Object::create());
    845852            RefPtr<JSON::Object> timeoutsObject = JSON::Object::create();
    846             timeoutsObject->setInteger("script"_s, m_session->scriptTimeout().millisecondsAs<int>());
    847             timeoutsObject->setInteger("pageLoad"_s, m_session->pageLoadTimeout().millisecondsAs<int>());
    848             timeoutsObject->setInteger("implicit"_s, m_session->implicitWaitTimeout().millisecondsAs<int>());
     853            if (m_session->scriptTimeout() == std::numeric_limits<double>::infinity())
     854                timeoutsObject->setValue("script"_s, JSON::Value::null());
     855            else
     856                timeoutsObject->setDouble("script"_s, m_session->scriptTimeout());
     857            timeoutsObject->setDouble("pageLoad"_s, m_session->pageLoadTimeout());
     858            timeoutsObject->setDouble("implicit"_s, m_session->implicitWaitTimeout());
    849859            capabilitiesObject->setObject("timeouts"_s, WTFMove(timeoutsObject));
    850860
     
    907917        return;
    908918
    909     auto timeouts = deserializeTimeouts(*parameters);
     919    auto timeouts = deserializeTimeouts(*parameters, IgnoreUnknownTimeout::Yes);
    910920    if (!timeouts) {
    911921        completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
  • trunk/Source/WebKit/ChangeLog

    r253882 r253883  
     12019-12-23  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        WebDriver: fix handling of session timeouts for values higher than MAX_INT
     4        https://bugs.webkit.org/show_bug.cgi?id=204114
     5
     6        Reviewed by Brian Burg.
     7
     8        Use number instead of integer for all optional timeout parameters. In the case of script timeout, not passing a
     9        value means a timeout should not be used, so use Optional<double> also for the IPC message and handle the
     10        optional value in the web process to not set any timeout in that case.
     11
     12        * UIProcess/Automation/Automation.json:
     13        * UIProcess/Automation/WebAutomationSession.cpp:
     14        (WebKit::WebAutomationSession::waitForNavigationToComplete):
     15        (WebKit::WebAutomationSession::navigateBrowsingContext):
     16        (WebKit::WebAutomationSession::goBackInBrowsingContext):
     17        (WebKit::WebAutomationSession::goForwardInBrowsingContext):
     18        (WebKit::WebAutomationSession::reloadBrowsingContext):
     19        (WebKit::WebAutomationSession::evaluateJavaScriptFunction):
     20        * UIProcess/Automation/WebAutomationSession.h:
     21        * WebProcess/Automation/WebAutomationSessionProxy.cpp:
     22        (WebKit::WebAutomationSessionProxy::evaluateJavaScriptFunction):
     23        * WebProcess/Automation/WebAutomationSessionProxy.h:
     24        * WebProcess/Automation/WebAutomationSessionProxy.js:
     25        (let.AutomationSessionProxy.prototype.evaluateJavaScriptFunction):
     26        * WebProcess/Automation/WebAutomationSessionProxy.messages.in:
     27
    1282019-12-23  Carlos Garcia Campos  <cgarcia@igalia.com>
    229
  • trunk/Source/WebKit/UIProcess/Automation/Automation.json

    r253030 r253883  
    389389                { "name": "url", "type": "string", "description": "The URL to load in the browsing context." },
    390390                { "name": "pageLoadStrategy", "$ref": "PageLoadStrategy", "optional": true, "description": "The page load strategy to use when determining when navigation is complete." },
    391                 { "name": "pageLoadTimeout", "type": "integer", "optional": true, "description": "The timeout in milliseconds that the navigation is expected to be completed in, otherwise a <code>Timeout</code> error is returned." }
     391                { "name": "pageLoadTimeout", "type": "number", "optional": true, "description": "The timeout in milliseconds that the navigation is expected to be completed in, otherwise a <code>Timeout</code> error is returned." }
    392392            ],
    393393            "async": true
     
    399399                { "name": "handle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context that should be navigated." },
    400400                { "name": "pageLoadStrategy", "$ref": "PageLoadStrategy", "optional": true, "description": "The page load strategy to use when determining when navigation is complete." },
    401                 { "name": "pageLoadTimeout", "type": "integer", "optional": true, "description": "The timeout in milliseconds that the navigation is expected to be completed in, otherwise a <code>Timeout</code> error is returned." }
     401                { "name": "pageLoadTimeout", "type": "number", "optional": true, "description": "The timeout in milliseconds that the navigation is expected to be completed in, otherwise a <code>Timeout</code> error is returned." }
    402402            ],
    403403            "async": true
     
    409409                { "name": "handle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context that should be navigated." },
    410410                { "name": "pageLoadStrategy", "$ref": "PageLoadStrategy", "optional": true, "description": "The page load strategy to use when determining when navigation is complete." },
    411                 { "name": "pageLoadTimeout", "type": "integer", "optional": true, "description": "The timeout in milliseconds that the navigation is expected to be completed in, otherwise a <code>Timeout</code> error is returned." }
     411                { "name": "pageLoadTimeout", "type": "number", "optional": true, "description": "The timeout in milliseconds that the navigation is expected to be completed in, otherwise a <code>Timeout</code> error is returned." }
    412412            ],
    413413            "async": true
     
    419419                { "name": "handle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context that should be reloaded." },
    420420                { "name": "pageLoadStrategy", "$ref": "PageLoadStrategy", "optional": true, "description": "The page load strategy to use when determining when navigation is complete." },
    421                 { "name": "pageLoadTimeout", "type": "integer", "optional": true, "description": "The timeout in milliseconds that the navigation is expected to be completed in, otherwise a <code>Timeout</code> error is returned." }
     421                { "name": "pageLoadTimeout", "type": "number", "optional": true, "description": "The timeout in milliseconds that the navigation is expected to be completed in, otherwise a <code>Timeout</code> error is returned." }
    422422            ],
    423423            "async": true
     
    430430                { "name": "frameHandle", "$ref": "FrameHandle", "optional": true, "description": "The handle for the frame in which wait for pending navigation to complete. The main frame is used if this parameter empty string or excluded." },
    431431                { "name": "pageLoadStrategy", "$ref": "PageLoadStrategy", "optional": true, "description": "The page load strategy to use when determining when navigation is complete." },
    432                 { "name": "pageLoadTimeout", "type": "integer", "optional": true, "description": "The timeout in milliseconds that the navigation is expected to be completed in, otherwise a <code>Timeout</code> error is returned." }
     432                { "name": "pageLoadTimeout", "type": "number", "optional": true, "description": "The timeout in milliseconds that the navigation is expected to be completed in, otherwise a <code>Timeout</code> error is returned." }
    433433            ],
    434434            "async": true
     
    453453                { "name": "arguments", "type": "array", "items": { "type": "string" }, "description": "The arguments to pass to the function when called. They will be parsed as JSON before calling the function." },
    454454                { "name": "expectsImplicitCallbackArgument", "type": "boolean", "optional": true, "description": "The function expects a callback function as the last argument. It is expected to call this callback with a result." },
    455                 { "name": "callbackTimeout", "type": "integer", "optional": true, "description": "The timeout in milliseconds that the implicit callback is expected to be called in, otherwise a <code>JavaScriptTimeout</code> error is returned." }
     455                { "name": "callbackTimeout", "type": "number", "optional": true, "description": "The timeout in milliseconds that the implicit callback is expected to be called in, otherwise a <code>JavaScriptTimeout</code> error is returned." }
    456456            ],
    457457            "returns": [
  • trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp

    r253346 r253883  
    443443}
    444444
    445 void WebAutomationSession::waitForNavigationToComplete(const String& browsingContextHandle, const String* optionalFrameHandle, const String* optionalPageLoadStrategyString, const int* optionalPageLoadTimeout, Ref<WaitForNavigationToCompleteCallback>&& callback)
     445void WebAutomationSession::waitForNavigationToComplete(const String& browsingContextHandle, const String* optionalFrameHandle, const String* optionalPageLoadStrategyString, const double* optionalPageLoadTimeout, Ref<WaitForNavigationToCompleteCallback>&& callback)
    446446{
    447447    WebPageProxy* page = webPageProxyForHandle(browsingContextHandle);
     
    697697}
    698698
    699 void WebAutomationSession::navigateBrowsingContext(const String& handle, const String& url, const String* optionalPageLoadStrategyString, const int* optionalPageLoadTimeout, Ref<NavigateBrowsingContextCallback>&& callback)
     699void WebAutomationSession::navigateBrowsingContext(const String& handle, const String& url, const String* optionalPageLoadStrategyString, const double* optionalPageLoadTimeout, Ref<NavigateBrowsingContextCallback>&& callback)
    700700{
    701701    WebPageProxy* page = webPageProxyForHandle(handle);
     
    712712}
    713713
    714 void WebAutomationSession::goBackInBrowsingContext(const String& handle, const String* optionalPageLoadStrategyString, const int* optionalPageLoadTimeout, Ref<GoBackInBrowsingContextCallback>&& callback)
     714void WebAutomationSession::goBackInBrowsingContext(const String& handle, const String* optionalPageLoadStrategyString, const double* optionalPageLoadTimeout, Ref<GoBackInBrowsingContextCallback>&& callback)
    715715{
    716716    WebPageProxy* page = webPageProxyForHandle(handle);
     
    727727}
    728728
    729 void WebAutomationSession::goForwardInBrowsingContext(const String& handle, const String* optionalPageLoadStrategyString, const int* optionalPageLoadTimeout, Ref<GoForwardInBrowsingContextCallback>&& callback)
     729void WebAutomationSession::goForwardInBrowsingContext(const String& handle, const String* optionalPageLoadStrategyString, const double* optionalPageLoadTimeout, Ref<GoForwardInBrowsingContextCallback>&& callback)
    730730{
    731731    WebPageProxy* page = webPageProxyForHandle(handle);
     
    742742}
    743743
    744 void WebAutomationSession::reloadBrowsingContext(const String& handle, const String* optionalPageLoadStrategyString, const int* optionalPageLoadTimeout, Ref<ReloadBrowsingContextCallback>&& callback)
     744void WebAutomationSession::reloadBrowsingContext(const String& handle, const String* optionalPageLoadStrategyString, const double* optionalPageLoadTimeout, Ref<ReloadBrowsingContextCallback>&& callback)
    745745{
    746746    WebPageProxy* page = webPageProxyForHandle(handle);
     
    923923}
    924924
    925 void WebAutomationSession::evaluateJavaScriptFunction(const String& browsingContextHandle, const String* optionalFrameHandle, const String& function, const JSON::Array& arguments, const bool* optionalExpectsImplicitCallbackArgument, const int* optionalCallbackTimeout, Ref<EvaluateJavaScriptFunctionCallback>&& callback)
     925void WebAutomationSession::evaluateJavaScriptFunction(const String& browsingContextHandle, const String* optionalFrameHandle, const String& function, const JSON::Array& arguments, const bool* optionalExpectsImplicitCallbackArgument, const double* optionalCallbackTimeout, Ref<EvaluateJavaScriptFunctionCallback>&& callback)
    926926{
    927927    WebPageProxy* page = webPageProxyForHandle(browsingContextHandle);
     
    944944
    945945    bool expectsImplicitCallbackArgument = optionalExpectsImplicitCallbackArgument ? *optionalExpectsImplicitCallbackArgument : false;
    946     int callbackTimeout = optionalCallbackTimeout ? *optionalCallbackTimeout : 0;
     946    Optional<double> callbackTimeout;
     947    if (optionalCallbackTimeout)
     948        callbackTimeout = *optionalCallbackTimeout;
    947949
    948950    uint64_t callbackID = m_nextEvaluateJavaScriptCallbackID++;
  • trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.h

    r253030 r253883  
    171171    void maximizeWindowOfBrowsingContext(const String& handle, Ref<MaximizeWindowOfBrowsingContextCallback>&&) final;
    172172    void hideWindowOfBrowsingContext(const String& handle, Ref<HideWindowOfBrowsingContextCallback>&&) final;
    173     void navigateBrowsingContext(const String& handle, const String& url, const String* optionalPageLoadStrategyString, const int* optionalPageLoadTimeout, Ref<NavigateBrowsingContextCallback>&&) override;
    174     void goBackInBrowsingContext(const String&, const String* optionalPageLoadStrategyString, const int* optionalPageLoadTimeout, Ref<GoBackInBrowsingContextCallback>&&) override;
    175     void goForwardInBrowsingContext(const String&, const String* optionalPageLoadStrategyString, const int* optionalPageLoadTimeout, Ref<GoForwardInBrowsingContextCallback>&&) override;
    176     void reloadBrowsingContext(const String&, const String* optionalPageLoadStrategyString, const int* optionalPageLoadTimeout, Ref<ReloadBrowsingContextCallback>&&) override;
    177     void waitForNavigationToComplete(const String& browsingContextHandle, const String* optionalFrameHandle, const String* optionalPageLoadStrategyString, const int* optionalPageLoadTimeout, Ref<WaitForNavigationToCompleteCallback>&&) override;
    178     void evaluateJavaScriptFunction(const String& browsingContextHandle, const String* optionalFrameHandle, const String& function, const JSON::Array& arguments, const bool* optionalExpectsImplicitCallbackArgument, const int* optionalCallbackTimeout, Ref<Inspector::AutomationBackendDispatcherHandler::EvaluateJavaScriptFunctionCallback>&&) override;
     173    void navigateBrowsingContext(const String& handle, const String& url, const String* optionalPageLoadStrategyString, const double* optionalPageLoadTimeout, Ref<NavigateBrowsingContextCallback>&&) override;
     174    void goBackInBrowsingContext(const String&, const String* optionalPageLoadStrategyString, const double* optionalPageLoadTimeout, Ref<GoBackInBrowsingContextCallback>&&) override;
     175    void goForwardInBrowsingContext(const String&, const String* optionalPageLoadStrategyString, const double* optionalPageLoadTimeout, Ref<GoForwardInBrowsingContextCallback>&&) override;
     176    void reloadBrowsingContext(const String&, const String* optionalPageLoadStrategyString, const double* optionalPageLoadTimeout, Ref<ReloadBrowsingContextCallback>&&) override;
     177    void waitForNavigationToComplete(const String& browsingContextHandle, const String* optionalFrameHandle, const String* optionalPageLoadStrategyString, const double* optionalPageLoadTimeout, Ref<WaitForNavigationToCompleteCallback>&&) override;
     178    void evaluateJavaScriptFunction(const String& browsingContextHandle, const String* optionalFrameHandle, const String& function, const JSON::Array& arguments, const bool* optionalExpectsImplicitCallbackArgument, const double* optionalCallbackTimeout, Ref<Inspector::AutomationBackendDispatcherHandler::EvaluateJavaScriptFunctionCallback>&&) override;
    179179    void performMouseInteraction(const String& handle, const JSON::Object& requestedPosition, const String& mouseButton, const String& mouseInteraction, const JSON::Array& keyModifiers, Ref<PerformMouseInteractionCallback>&&) final;
    180180    void performKeyboardInteractions(const String& handle, const JSON::Array& interactions, Ref<PerformKeyboardInteractionsCallback>&&) override;
  • trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp

    r253538 r253883  
    236236}
    237237
    238 void WebAutomationSessionProxy::evaluateJavaScriptFunction(WebCore::PageIdentifier pageID, Optional<WebCore::FrameIdentifier> optionalFrameID, const String& function, Vector<String> arguments, bool expectsImplicitCallbackArgument, int callbackTimeout, uint64_t callbackID)
     238void WebAutomationSessionProxy::evaluateJavaScriptFunction(WebCore::PageIdentifier pageID, Optional<WebCore::FrameIdentifier> optionalFrameID, const String& function, Vector<String> arguments, bool expectsImplicitCallbackArgument, Optional<double> callbackTimeout, uint64_t callbackID)
    239239{
    240240    WebPage* page = WebProcess::singleton().webPage(pageID);
     
    270270        JSValueMakeNumber(context, callbackID),
    271271        JSObjectMakeFunctionWithCallback(context, nullptr, evaluateJavaScriptCallback),
    272         JSValueMakeNumber(context, callbackTimeout)
     272        JSValueMakeNumber(context, callbackTimeout.valueOr(-1))
    273273    };
    274274
  • trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.h

    r253030 r253883  
    6464
    6565    // Called by WebAutomationSessionProxy messages
    66     void evaluateJavaScriptFunction(WebCore::PageIdentifier, Optional<WebCore::FrameIdentifier>, const String& function, Vector<String> arguments, bool expectsImplicitCallbackArgument, int callbackTimeout, uint64_t callbackID);
     66    void evaluateJavaScriptFunction(WebCore::PageIdentifier, Optional<WebCore::FrameIdentifier>, const String& function, Vector<String> arguments, bool expectsImplicitCallbackArgument, Optional<double> callbackTimeout, uint64_t callbackID);
    6767    void resolveChildFrameWithOrdinal(WebCore::PageIdentifier, Optional<WebCore::FrameIdentifier>, uint32_t ordinal, CompletionHandler<void(Optional<String>, Optional<WebCore::FrameIdentifier>)>&&);
    6868    void resolveChildFrameWithNodeHandle(WebCore::PageIdentifier, Optional<WebCore::FrameIdentifier>, const String& nodeHandle, CompletionHandler<void(Optional<String>, Optional<WebCore::FrameIdentifier>)>&&);
  • trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.js

    r229210 r253883  
    6565            argumentValues.push(reportResult);
    6666            functionValue.apply(null, argumentValues);
    67             if (!resultReported)
     67            if (!resultReported && callbackTimeout >= 0)
    6868                timeoutIdentifier = setTimeout(reportTimeoutError, callbackTimeout);
    6969        } else
  • trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.messages.in

    r253030 r253883  
    2222
    2323messages -> WebAutomationSessionProxy NotRefCounted {
    24     EvaluateJavaScriptFunction(WebCore::PageIdentifier pageID, Optional<WebCore::FrameIdentifier> frameID, String function, Vector<String> arguments, bool expectsImplicitCallbackArgument, int callbackTimeout, uint64_t callbackID)
     24    EvaluateJavaScriptFunction(WebCore::PageIdentifier pageID, Optional<WebCore::FrameIdentifier> frameID, String function, Vector<String> arguments, bool expectsImplicitCallbackArgument, Optional<double> callbackTimeout, uint64_t callbackID)
    2525
    2626    ResolveChildFrameWithOrdinal(WebCore::PageIdentifier pageID, Optional<WebCore::FrameIdentifier> frameID, uint32_t ordinal) -> (Optional<String> errorType, Optional<WebCore::FrameIdentifier> frameID) Async
Note: See TracChangeset for help on using the changeset viewer.