Changeset 220317 in webkit


Ignore:
Timestamp:
Aug 5, 2017 4:14:34 AM (7 years ago)
Author:
Carlos Garcia Campos
Message:

WebDriver: Implement page load strategy
https://bugs.webkit.org/show_bug.cgi?id=175183

Reviewed by Brian Burg.

Source/WebDriver:

Validate and parse page load strategy when processing capabilities.

  • Capabilities.h:
  • Session.cpp:

(WebDriver::Session::pageLoadStrategyString const): Helper to get the page load strategy as a String to be
passed to Automation.
(WebDriver::Session::go): Pass page load strategy if present.
(WebDriver::Session::back): Ditto.
(WebDriver::Session::forward): Ditto.
(WebDriver::Session::refresh): Ditto.
(WebDriver::Session::waitForNavigationToComplete): Ditto.

  • Session.h:
  • WebDriverService.cpp:

(WebDriver::deserializePageLoadStrategy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::newSession):

Source/WebKit:

Split pending navigation maps into normal and eager, and use one or the other depending on the received page
load strategy. We need to keep different maps for every page load strategy because every command could use a
different strategy.

  • UIProcess/Automation/WebAutomationSession.cpp:

(WebKit::WebAutomationSession::waitForNavigationToComplete): Extract page load strategy from parameter and pass
it to waitForNavigationToCompleteOnPage() and waitForNavigationToCompleteOnFrame().
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnPage): Return early if page load strategy is
none. Otherwise at the pening callback to the normal or eager map depeding on the page load straegy.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnFrame): Ditto.
(WebKit::respondToPendingNavigationCallbacksWithTimeout): Helper to send pening navigation callback in case of
timeout failure.
(WebKit::WebAutomationSession::loadTimerFired): Call finishPendingNavigationsWithTimeoutFailure() with all the maps.
(WebKit::WebAutomationSession::navigateBrowsingContext): Extract page load strategy from parameter and pass it
to waitForNavigationToCompleteOnPage().
(WebKit::WebAutomationSession::goBackInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::goForwardInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::reloadBrowsingContext): Ditto.
(WebKit::WebAutomationSession::navigationOccurredForFrame): Use the normal maps.
(WebKit::WebAutomationSession::documentLoadedForFrame): Stop timeout timer and dispatch eager pending navigations.

  • UIProcess/Automation/WebAutomationSession.h:
  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::didFinishDocumentLoadForFrame): Notify the automation session.

Location:
trunk/Source
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebDriver/Capabilities.h

    r220315 r220317  
    3939};
    4040
     41enum class PageLoadStrategy {
     42    None,
     43    Normal,
     44    Eager
     45};
     46
    4147struct Capabilities {
    4248    std::optional<String> browserName;
     
    4551    std::optional<bool> acceptInsecureCerts;
    4652    std::optional<Timeouts> timeouts;
     53    std::optional<PageLoadStrategy> pageLoadStrategy;
    4754#if PLATFORM(GTK)
    4855    std::optional<String> browserBinary;
  • trunk/Source/WebDriver/ChangeLog

    r220316 r220317  
     12017-08-05  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        WebDriver: Implement page load strategy
     4        https://bugs.webkit.org/show_bug.cgi?id=175183
     5
     6        Reviewed by Brian Burg.
     7
     8        Validate and parse page load strategy when processing capabilities.
     9
     10        * Capabilities.h:
     11        * Session.cpp:
     12        (WebDriver::Session::pageLoadStrategyString const): Helper to get the page load strategy as a String to be
     13        passed to Automation.
     14        (WebDriver::Session::go): Pass page load strategy if present.
     15        (WebDriver::Session::back): Ditto.
     16        (WebDriver::Session::forward): Ditto.
     17        (WebDriver::Session::refresh): Ditto.
     18        (WebDriver::Session::waitForNavigationToComplete): Ditto.
     19        * Session.h:
     20        * WebDriverService.cpp:
     21        (WebDriver::deserializePageLoadStrategy):
     22        (WebDriver::WebDriverService::parseCapabilities const):
     23        (WebDriver::WebDriverService::validatedCapabilities const):
     24        (WebDriver::WebDriverService::newSession):
     25
    1262017-08-05  Carlos Garcia Campos  <cgarcia@igalia.com>
    227
  • trunk/Source/WebDriver/Session.cpp

    r220314 r220317  
    103103}
    104104
     105std::optional<String> Session::pageLoadStrategyString() const
     106{
     107    if (!capabilities().pageLoadStrategy)
     108        return std::nullopt;
     109
     110    switch (capabilities().pageLoadStrategy.value()) {
     111    case PageLoadStrategy::None:
     112        return String("None");
     113    case PageLoadStrategy::Normal:
     114        return String("Normal");
     115    case PageLoadStrategy::Eager:
     116        return String("Eager");
     117    }
     118
     119    return std::nullopt;
     120}
     121
    105122void Session::createTopLevelBrowsingContext(Function<void (CommandResult&&)>&& completionHandler)
    106123{
     
    135152    if (m_timeouts.pageLoad)
    136153        parameters->setInteger(ASCIILiteral("pageLoadTimeout"), m_timeouts.pageLoad.value().millisecondsAs<int>());
     154    if (auto pageLoadStrategy = pageLoadStrategyString())
     155        parameters->setString(ASCIILiteral("pageLoadStrategy"), pageLoadStrategy.value());
    137156    m_host->sendCommandToBackend(ASCIILiteral("navigateBrowsingContext"), WTFMove(parameters), [this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)](SessionHost::CommandResponse&& response) {
    138157        if (response.isError) {
     
    184203    if (m_timeouts.pageLoad)
    185204        parameters->setInteger(ASCIILiteral("pageLoadTimeout"), m_timeouts.pageLoad.value().millisecondsAs<int>());
     205    if (auto pageLoadStrategy = pageLoadStrategyString())
     206        parameters->setString(ASCIILiteral("pageLoadStrategy"), pageLoadStrategy.value());
    186207    m_host->sendCommandToBackend(ASCIILiteral("goBackInBrowsingContext"), WTFMove(parameters), [this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)](SessionHost::CommandResponse&& response) {
    187208        if (response.isError) {
     
    205226    if (m_timeouts.pageLoad)
    206227        parameters->setInteger(ASCIILiteral("pageLoadTimeout"), m_timeouts.pageLoad.value().millisecondsAs<int>());
     228    if (auto pageLoadStrategy = pageLoadStrategyString())
     229        parameters->setString(ASCIILiteral("pageLoadStrategy"), pageLoadStrategy.value());
    207230    m_host->sendCommandToBackend(ASCIILiteral("goForwardInBrowsingContext"), WTFMove(parameters), [this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)](SessionHost::CommandResponse&& response) {
    208231        if (response.isError) {
     
    226249    if (m_timeouts.pageLoad)
    227250        parameters->setInteger(ASCIILiteral("pageLoadTimeout"), m_timeouts.pageLoad.value().millisecondsAs<int>());
     251    if (auto pageLoadStrategy = pageLoadStrategyString())
     252        parameters->setString(ASCIILiteral("pageLoadStrategy"), pageLoadStrategy.value());
    228253    m_host->sendCommandToBackend(ASCIILiteral("reloadBrowsingContext"), WTFMove(parameters), [this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)](SessionHost::CommandResponse&& response) {
    229254        if (response.isError) {
     
    9821007    if (m_timeouts.pageLoad)
    9831008        parameters->setInteger(ASCIILiteral("pageLoadTimeout"), m_timeouts.pageLoad.value().millisecondsAs<int>());
     1009    if (auto pageLoadStrategy = pageLoadStrategyString())
     1010        parameters->setString(ASCIILiteral("pageLoadStrategy"), pageLoadStrategy.value());
    9841011    m_host->sendCommandToBackend(ASCIILiteral("waitForNavigationToComplete"), WTFMove(parameters), [this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)](SessionHost::CommandResponse&& response) {
    9851012        if (response.isError) {
  • trunk/Source/WebDriver/Session.h

    r220315 r220317  
    102102    void switchToBrowsingContext(std::optional<String>);
    103103
     104    std::optional<String> pageLoadStrategyString() const;
     105
    104106    RefPtr<Inspector::InspectorObject> createElement(RefPtr<Inspector::InspectorValue>&&);
    105107    RefPtr<Inspector::InspectorObject> createElement(const String& elementID);
  • trunk/Source/WebDriver/WebDriverService.cpp

    r220316 r220317  
    278278}
    279279
     280static std::optional<PageLoadStrategy> deserializePageLoadStrategy(const String& pageLoadStrategy)
     281{
     282    if (pageLoadStrategy == "none")
     283        return PageLoadStrategy::None;
     284    if (pageLoadStrategy == "normal")
     285        return PageLoadStrategy::Normal;
     286    if (pageLoadStrategy == "eager")
     287        return PageLoadStrategy::Eager;
     288    return std::nullopt;
     289}
     290
    280291void WebDriverService::parseCapabilities(const InspectorObject& matchedCapabilities, Capabilities& capabilities) const
    281292{
     
    296307    if (matchedCapabilities.getObject(ASCIILiteral("timeouts"), timeouts))
    297308        capabilities.timeouts = deserializeTimeouts(*timeouts);
     309    String pageLoadStrategy;
     310    if (matchedCapabilities.getString(ASCIILiteral("pageLoadStrategy"), pageLoadStrategy))
     311        capabilities.pageLoadStrategy = deserializePageLoadStrategy(pageLoadStrategy);
    298312    platformParseCapabilities(matchedCapabilities, capabilities);
    299313}
     
    337351        } else if (it->key == "pageLoadStrategy") {
    338352            String pageLoadStrategy;
    339             if (!it->value->asString(pageLoadStrategy))
     353            if (!it->value->asString(pageLoadStrategy) || !deserializePageLoadStrategy(pageLoadStrategy))
    340354                return nullptr;
    341             // FIXME: implement pageLoadStrategy.
    342355            result->setString(it->key, pageLoadStrategy);
    343356        } else if (it->key == "proxy") {
     
    561574                capabilitiesObject->setObject(ASCIILiteral("timeouts"), WTFMove(timeoutsObject));
    562575            }
     576            if (capabilities.pageLoadStrategy) {
     577                switch (capabilities.pageLoadStrategy.value()) {
     578                case PageLoadStrategy::None:
     579                    capabilitiesObject->setString(ASCIILiteral("pageLoadStrategy"), "none");
     580                    break;
     581                case PageLoadStrategy::Normal:
     582                    capabilitiesObject->setString(ASCIILiteral("pageLoadStrategy"), "normal");
     583                    break;
     584                case PageLoadStrategy::Eager:
     585                    capabilitiesObject->setString(ASCIILiteral("pageLoadStrategy"), "eager");
     586                    break;
     587                }
     588            }
    563589            resultObject->setObject(ASCIILiteral("value"), WTFMove(capabilitiesObject));
    564590            completionHandler(CommandResult::success(WTFMove(resultObject)));
  • trunk/Source/WebKit/ChangeLog

    r220314 r220317  
     12017-08-05  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        WebDriver: Implement page load strategy
     4        https://bugs.webkit.org/show_bug.cgi?id=175183
     5
     6        Reviewed by Brian Burg.
     7
     8        Split pending navigation maps into normal and eager, and use one or the other depending on the received page
     9        load strategy. We need to keep different maps for every page load strategy because every command could use a
     10        different strategy.
     11
     12        * UIProcess/Automation/WebAutomationSession.cpp:
     13        (WebKit::WebAutomationSession::waitForNavigationToComplete): Extract page load strategy from parameter and pass
     14        it to waitForNavigationToCompleteOnPage() and waitForNavigationToCompleteOnFrame().
     15        (WebKit::WebAutomationSession::waitForNavigationToCompleteOnPage): Return early if page load strategy is
     16        none. Otherwise at the pening callback to the normal or eager map depeding on the page load straegy.
     17        (WebKit::WebAutomationSession::waitForNavigationToCompleteOnFrame): Ditto.
     18        (WebKit::respondToPendingNavigationCallbacksWithTimeout): Helper to send pening navigation callback in case of
     19        timeout failure.
     20        (WebKit::WebAutomationSession::loadTimerFired): Call finishPendingNavigationsWithTimeoutFailure() with all the maps.
     21        (WebKit::WebAutomationSession::navigateBrowsingContext): Extract page load strategy from parameter and pass it
     22        to waitForNavigationToCompleteOnPage().
     23        (WebKit::WebAutomationSession::goBackInBrowsingContext): Ditto.
     24        (WebKit::WebAutomationSession::goForwardInBrowsingContext): Ditto.
     25        (WebKit::WebAutomationSession::reloadBrowsingContext): Ditto.
     26        (WebKit::WebAutomationSession::navigationOccurredForFrame): Use the normal maps.
     27        (WebKit::WebAutomationSession::documentLoadedForFrame): Stop timeout timer and dispatch eager pending navigations.
     28        * UIProcess/Automation/WebAutomationSession.h:
     29        * UIProcess/WebPageProxy.cpp:
     30        (WebKit::WebPageProxy::didFinishDocumentLoadForFrame): Notify the automation session.
     31
    1322017-08-05  Carlos Garcia Campos  <cgarcia@igalia.com>
    233
  • trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp

    r220314 r220317  
    5555// https://www.w3.org/TR/webdriver/#dfn-session-page-load-timeout
    5656static const Seconds defaultPageLoadTimeout = 300_s;
     57// https://www.w3.org/TR/webdriver/#dfn-page-loading-strategy
     58static const Inspector::Protocol::Automation::PageLoadStrategy defaultPageLoadStrategy = Inspector::Protocol::Automation::PageLoadStrategy::Normal;
    5759
    5860WebAutomationSession::WebAutomationSession()
     
    386388}
    387389
     390static std::optional<Inspector::Protocol::Automation::PageLoadStrategy> pageLoadStrategyFromStringParameter(const String* optionalPageLoadStrategyString)
     391{
     392    if (!optionalPageLoadStrategyString)
     393        return defaultPageLoadStrategy;
     394
     395    auto parsedPageLoadStrategy = Inspector::Protocol::AutomationHelpers::parseEnumValueFromString<Inspector::Protocol::Automation::PageLoadStrategy>(*optionalPageLoadStrategyString);
     396    if (!parsedPageLoadStrategy)
     397        return std::nullopt;
     398    return parsedPageLoadStrategy;
     399}
     400
    388401void WebAutomationSession::waitForNavigationToComplete(Inspector::ErrorString& errorString, const String& browsingContextHandle, const String* optionalFrameHandle, const String* optionalPageLoadStrategyString, const int* optionalPageLoadTimeout, Ref<WaitForNavigationToCompleteCallback>&& callback)
    389402{
     
    392405        FAIL_WITH_PREDEFINED_ERROR(WindowNotFound);
    393406
    394     // FIXME: Implement page load strategy.
    395 
    396     Seconds pageLoadTimeout = optionalPageLoadTimeout ? Seconds::fromMilliseconds(*optionalPageLoadTimeout) : defaultPageLoadTimeout;
     407    auto pageLoadStrategy = pageLoadStrategyFromStringParameter(optionalPageLoadStrategyString);
     408    if (!pageLoadStrategy)
     409        FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InvalidParameter, "The parameter 'pageLoadStrategy' is invalid.");
     410    auto pageLoadTimeout = optionalPageLoadTimeout ? Seconds::fromMilliseconds(*optionalPageLoadTimeout) : defaultPageLoadTimeout;
    397411
    398412    if (optionalFrameHandle && !optionalFrameHandle->isEmpty()) {
     
    403417        if (!frame)
    404418            FAIL_WITH_PREDEFINED_ERROR(FrameNotFound);
    405         waitForNavigationToCompleteOnFrame(*frame, pageLoadTimeout, WTFMove(callback));
     419        waitForNavigationToCompleteOnFrame(*frame, pageLoadStrategy.value(), pageLoadTimeout, WTFMove(callback));
    406420    } else
    407         waitForNavigationToCompleteOnPage(*page, pageLoadTimeout, WTFMove(callback));
    408 }
    409 
    410 void WebAutomationSession::waitForNavigationToCompleteOnPage(WebPageProxy& page, Seconds timeout, Ref<Inspector::BackendDispatcher::CallbackBase>&& callback)
     421        waitForNavigationToCompleteOnPage(*page, pageLoadStrategy.value(), pageLoadTimeout, WTFMove(callback));
     422}
     423
     424void WebAutomationSession::waitForNavigationToCompleteOnPage(WebPageProxy& page, Inspector::Protocol::Automation::PageLoadStrategy loadStrategy, Seconds timeout, Ref<Inspector::BackendDispatcher::CallbackBase>&& callback)
    411425{
    412426    ASSERT(!m_loadTimer.isActive());
    413     if (!page.pageLoadState().isLoading()) {
     427    if (loadStrategy == Inspector::Protocol::Automation::PageLoadStrategy::None || !page.pageLoadState().isLoading()) {
    414428        callback->sendSuccess(InspectorObject::create());
    415429        return;
     
    417431
    418432    m_loadTimer.startOneShot(timeout);
    419     m_pendingNavigationInBrowsingContextCallbacksPerPage.set(page.pageID(), WTFMove(callback));
    420 }
    421 
    422 void WebAutomationSession::waitForNavigationToCompleteOnFrame(WebFrameProxy& frame, Seconds timeout, Ref<Inspector::BackendDispatcher::CallbackBase>&& callback)
     433    switch (loadStrategy) {
     434    case Inspector::Protocol::Automation::PageLoadStrategy::Normal:
     435        m_pendingNormalNavigationInBrowsingContextCallbacksPerPage.set(page.pageID(), WTFMove(callback));
     436        break;
     437    case Inspector::Protocol::Automation::PageLoadStrategy::Eager:
     438        m_pendingEagerNavigationInBrowsingContextCallbacksPerPage.set(page.pageID(), WTFMove(callback));
     439        break;
     440    case Inspector::Protocol::Automation::PageLoadStrategy::None:
     441        ASSERT_NOT_REACHED();
     442    }
     443}
     444
     445void WebAutomationSession::waitForNavigationToCompleteOnFrame(WebFrameProxy& frame, Inspector::Protocol::Automation::PageLoadStrategy loadStrategy, Seconds timeout, Ref<Inspector::BackendDispatcher::CallbackBase>&& callback)
    423446{
    424447    ASSERT(!m_loadTimer.isActive());
    425     if (frame.frameLoadState().state() == FrameLoadState::State::Finished) {
     448    if (loadStrategy == Inspector::Protocol::Automation::PageLoadStrategy::None || frame.frameLoadState().state() == FrameLoadState::State::Finished) {
    426449        callback->sendSuccess(InspectorObject::create());
    427450        return;
     
    429452
    430453    m_loadTimer.startOneShot(timeout);
    431     m_pendingNavigationInBrowsingContextCallbacksPerFrame.set(frame.frameID(), WTFMove(callback));
     454    switch (loadStrategy) {
     455    case Inspector::Protocol::Automation::PageLoadStrategy::Normal:
     456        m_pendingNormalNavigationInBrowsingContextCallbacksPerFrame.set(frame.frameID(), WTFMove(callback));
     457        break;
     458    case Inspector::Protocol::Automation::PageLoadStrategy::Eager:
     459        m_pendingEagerNavigationInBrowsingContextCallbacksPerFrame.set(frame.frameID(), WTFMove(callback));
     460        break;
     461    case Inspector::Protocol::Automation::PageLoadStrategy::None:
     462        ASSERT_NOT_REACHED();
     463    }
     464}
     465
     466static void respondToPendingNavigationCallbacksWithTimeout(HashMap<uint64_t, RefPtr<Inspector::BackendDispatcher::CallbackBase>>& map)
     467{
     468    for (auto id : map.keys()) {
     469        auto callback = map.take(id);
     470        callback->sendFailure(STRING_FOR_PREDEFINED_ERROR_NAME(Timeout));
     471    }
    432472}
    433473
    434474void WebAutomationSession::loadTimerFired()
    435475{
    436     for (auto frameID : m_pendingNavigationInBrowsingContextCallbacksPerFrame.keys()) {
    437         auto callback = m_pendingNavigationInBrowsingContextCallbacksPerFrame.take(frameID);
    438         callback->sendFailure(STRING_FOR_PREDEFINED_ERROR_NAME(Timeout));
    439     }
    440     for (auto pageID : m_pendingNavigationInBrowsingContextCallbacksPerPage.keys()) {
    441         auto callback = m_pendingNavigationInBrowsingContextCallbacksPerPage.take(pageID);
    442         callback->sendFailure(STRING_FOR_PREDEFINED_ERROR_NAME(Timeout));
    443     }
     476    respondToPendingNavigationCallbacksWithTimeout(m_pendingNormalNavigationInBrowsingContextCallbacksPerFrame);
     477    respondToPendingNavigationCallbacksWithTimeout(m_pendingEagerNavigationInBrowsingContextCallbacksPerFrame);
     478    respondToPendingNavigationCallbacksWithTimeout(m_pendingNormalNavigationInBrowsingContextCallbacksPerPage);
     479    respondToPendingNavigationCallbacksWithTimeout(m_pendingEagerNavigationInBrowsingContextCallbacksPerPage);
    444480}
    445481
     
    450486        FAIL_WITH_PREDEFINED_ERROR(WindowNotFound);
    451487
    452     // FIXME: Implement page load strategy.
     488    auto pageLoadStrategy = pageLoadStrategyFromStringParameter(optionalPageLoadStrategyString);
     489    if (!pageLoadStrategy)
     490        FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InvalidParameter, "The parameter 'pageLoadStrategy' is invalid.");
     491    auto pageLoadTimeout = optionalPageLoadTimeout ? Seconds::fromMilliseconds(*optionalPageLoadTimeout) : defaultPageLoadTimeout;
    453492
    454493    page->loadRequest(WebCore::URL(WebCore::URL(), url));
    455     waitForNavigationToCompleteOnPage(*page, optionalPageLoadTimeout ? Seconds::fromMilliseconds(*optionalPageLoadTimeout) : defaultPageLoadTimeout, WTFMove(callback));
     494    waitForNavigationToCompleteOnPage(*page, pageLoadStrategy.value(), pageLoadTimeout, WTFMove(callback));
    456495}
    457496
     
    462501        FAIL_WITH_PREDEFINED_ERROR(WindowNotFound);
    463502
    464     // FIXME: Implement page load strategy.
     503    auto pageLoadStrategy = pageLoadStrategyFromStringParameter(optionalPageLoadStrategyString);
     504    if (!pageLoadStrategy)
     505        FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InvalidParameter, "The parameter 'pageLoadStrategy' is invalid.");
     506    auto pageLoadTimeout = optionalPageLoadTimeout ? Seconds::fromMilliseconds(*optionalPageLoadTimeout) : defaultPageLoadTimeout;
    465507
    466508    page->goBack();
    467     waitForNavigationToCompleteOnPage(*page, optionalPageLoadTimeout ? Seconds::fromMilliseconds(*optionalPageLoadTimeout) : defaultPageLoadTimeout, WTFMove(callback));
     509    waitForNavigationToCompleteOnPage(*page, pageLoadStrategy.value(), pageLoadTimeout, WTFMove(callback));
    468510}
    469511
     
    474516        FAIL_WITH_PREDEFINED_ERROR(WindowNotFound);
    475517
    476     // FIXME: Implement page load strategy.
     518    auto pageLoadStrategy = pageLoadStrategyFromStringParameter(optionalPageLoadStrategyString);
     519    if (!pageLoadStrategy)
     520        FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InvalidParameter, "The parameter 'pageLoadStrategy' is invalid.");
     521    auto pageLoadTimeout = optionalPageLoadTimeout ? Seconds::fromMilliseconds(*optionalPageLoadTimeout) : defaultPageLoadTimeout;
    477522
    478523    page->goForward();
    479     waitForNavigationToCompleteOnPage(*page, optionalPageLoadTimeout ? Seconds::fromMilliseconds(*optionalPageLoadTimeout) : defaultPageLoadTimeout, WTFMove(callback));
     524    waitForNavigationToCompleteOnPage(*page, pageLoadStrategy.value(), pageLoadTimeout, WTFMove(callback));
    480525}
    481526
     
    486531        FAIL_WITH_PREDEFINED_ERROR(WindowNotFound);
    487532
    488     // FIXME: Implement page load strategy.
     533    auto pageLoadStrategy = pageLoadStrategyFromStringParameter(optionalPageLoadStrategyString);
     534    if (!pageLoadStrategy)
     535        FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InvalidParameter, "The parameter 'pageLoadStrategy' is invalid.");
     536    auto pageLoadTimeout = optionalPageLoadTimeout ? Seconds::fromMilliseconds(*optionalPageLoadTimeout) : defaultPageLoadTimeout;
    489537
    490538    page->reload({ });
    491     waitForNavigationToCompleteOnPage(*page, optionalPageLoadTimeout ? Seconds::fromMilliseconds(*optionalPageLoadTimeout) : defaultPageLoadTimeout, WTFMove(callback));
     539    waitForNavigationToCompleteOnPage(*page, pageLoadStrategy.value(), pageLoadTimeout, WTFMove(callback));
    492540}
    493541
     
    498546        m_handleWebFrameMap.clear();
    499547        m_webFrameHandleMap.clear();
    500         if (auto callback = m_pendingNavigationInBrowsingContextCallbacksPerPage.take(frame.page()->pageID())) {
     548        if (auto callback = m_pendingNormalNavigationInBrowsingContextCallbacksPerPage.take(frame.page()->pageID())) {
    501549            m_loadTimer.stop();
    502550            callback->sendSuccess(InspectorObject::create());
     
    504552        m_domainNotifier->browsingContextCleared(handleForWebPageProxy(*frame.page()));
    505553    } else {
    506         if (auto callback = m_pendingNavigationInBrowsingContextCallbacksPerFrame.take(frame.frameID())) {
     554        if (auto callback = m_pendingNormalNavigationInBrowsingContextCallbacksPerFrame.take(frame.frameID())) {
     555            m_loadTimer.stop();
     556            callback->sendSuccess(InspectorObject::create());
     557        }
     558    }
     559}
     560
     561void WebAutomationSession::documentLoadedForFrame(const WebFrameProxy& frame)
     562{
     563    if (frame.isMainFrame()) {
     564        if (auto callback = m_pendingEagerNavigationInBrowsingContextCallbacksPerPage.take(frame.page()->pageID())) {
     565            m_loadTimer.stop();
     566            callback->sendSuccess(InspectorObject::create());
     567        }
     568    } else {
     569        if (auto callback = m_pendingEagerNavigationInBrowsingContextCallbacksPerFrame.take(frame.frameID())) {
    507570            m_loadTimer.stop();
    508571            callback->sendSuccess(InspectorObject::create());
  • trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.h

    r220314 r220317  
    9595
    9696    void navigationOccurredForFrame(const WebFrameProxy&);
     97    void documentLoadedForFrame(const WebFrameProxy&);
    9798    void inspectorFrontendLoaded(const WebPageProxy&);
    9899    void keyboardEventsFlushedForPage(const WebPageProxy&);
     
    164165    String handleForWebFrameProxy(const WebFrameProxy&);
    165166
    166     void waitForNavigationToCompleteOnPage(WebPageProxy&, Seconds, Ref<Inspector::BackendDispatcher::CallbackBase>&&);
    167     void waitForNavigationToCompleteOnFrame(WebFrameProxy&, Seconds, Ref<Inspector::BackendDispatcher::CallbackBase>&&);
     167    void waitForNavigationToCompleteOnPage(WebPageProxy&, Inspector::Protocol::Automation::PageLoadStrategy, Seconds, Ref<Inspector::BackendDispatcher::CallbackBase>&&);
     168    void waitForNavigationToCompleteOnFrame(WebFrameProxy&, Inspector::Protocol::Automation::PageLoadStrategy, Seconds, Ref<Inspector::BackendDispatcher::CallbackBase>&&);
    168169    void loadTimerFired();
    169170
     
    213214    HashMap<String, uint64_t> m_handleWebFrameMap;
    214215
    215     HashMap<uint64_t, RefPtr<Inspector::BackendDispatcher::CallbackBase>> m_pendingNavigationInBrowsingContextCallbacksPerPage;
    216     HashMap<uint64_t, RefPtr<Inspector::BackendDispatcher::CallbackBase>> m_pendingNavigationInBrowsingContextCallbacksPerFrame;
     216    HashMap<uint64_t, RefPtr<Inspector::BackendDispatcher::CallbackBase>> m_pendingNormalNavigationInBrowsingContextCallbacksPerPage;
     217    HashMap<uint64_t, RefPtr<Inspector::BackendDispatcher::CallbackBase>> m_pendingEagerNavigationInBrowsingContextCallbacksPerPage;
     218    HashMap<uint64_t, RefPtr<Inspector::BackendDispatcher::CallbackBase>> m_pendingNormalNavigationInBrowsingContextCallbacksPerFrame;
     219    HashMap<uint64_t, RefPtr<Inspector::BackendDispatcher::CallbackBase>> m_pendingEagerNavigationInBrowsingContextCallbacksPerFrame;
    217220    HashMap<uint64_t, RefPtr<Inspector::BackendDispatcher::CallbackBase>> m_pendingInspectorCallbacksPerPage;
    218221    HashMap<uint64_t, RefPtr<Inspector::BackendDispatcher::CallbackBase>> m_pendingKeyboardEventsFlushedCallbacksPerPage;
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r220286 r220317  
    33703370    MESSAGE_CHECK(frame);
    33713371
     3372    if (m_controlledByAutomation) {
     3373        if (auto* automationSession = process().processPool().automationSession())
     3374            automationSession->documentLoadedForFrame(*frame);
     3375    }
     3376
    33723377    // FIXME: We should message check that navigationID is not zero here, but it's currently zero for some navigations through the page cache.
    33733378    RefPtr<API::Navigation> navigation;
Note: See TracChangeset for help on using the changeset viewer.