Changeset 219833 in webkit


Ignore:
Timestamp:
Jul 24, 2017 12:16:55 PM (7 years ago)
Author:
commit-queue@webkit.org
Message:

WebDriver: rename m_browsingContext as m_currentBrowsingContext in Session
https://bugs.webkit.org/show_bug.cgi?id=174783

Patch by Carlos Garcia Campos <cgarcia@igalia.com> on 2017-07-24
Reviewed by Brian Burg.

We have m_toplevelBrowsingContext and m_browsingContext, which is confusing. m_browsingContext is actually the
current browsing context, and the spec also refers to it as the current browsing context, so better use
m_currentBrowsingContext.

  • Session.cpp:

(WebDriver::Session::switchToTopLevelBrowsingContext):
(WebDriver::Session::switchToBrowsingContext):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementClear):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::elementSubmit):
(WebDriver::Session::executeScript):

  • Session.h:
Location:
trunk/Source/WebDriver
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebDriver/ChangeLog

    r219794 r219833  
     12017-07-24  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        WebDriver: rename m_browsingContext as m_currentBrowsingContext in Session
     4        https://bugs.webkit.org/show_bug.cgi?id=174783
     5
     6        Reviewed by Brian Burg.
     7
     8        We have m_toplevelBrowsingContext and m_browsingContext, which is confusing. m_browsingContext is actually the
     9        current browsing context, and the spec also refers to it as the current browsing context, so better use
     10        m_currentBrowsingContext.
     11
     12        * Session.cpp:
     13        (WebDriver::Session::switchToTopLevelBrowsingContext):
     14        (WebDriver::Session::switchToBrowsingContext):
     15        (WebDriver::Session::switchToFrame):
     16        (WebDriver::Session::switchToParentFrame):
     17        (WebDriver::Session::computeElementLayout):
     18        (WebDriver::Session::findElements):
     19        (WebDriver::Session::isElementSelected):
     20        (WebDriver::Session::getElementText):
     21        (WebDriver::Session::getElementTagName):
     22        (WebDriver::Session::isElementEnabled):
     23        (WebDriver::Session::isElementDisplayed):
     24        (WebDriver::Session::getElementAttribute):
     25        (WebDriver::Session::waitForNavigationToComplete):
     26        (WebDriver::Session::elementClear):
     27        (WebDriver::Session::elementSendKeys):
     28        (WebDriver::Session::elementSubmit):
     29        (WebDriver::Session::executeScript):
     30        * Session.h:
     31
    1322017-07-20  Carlos Garcia Campos  <cgarcia@igalia.com>
    233
  • trunk/Source/WebDriver/Session.cpp

    r219794 r219833  
    9191{
    9292    m_toplevelBrowsingContext = toplevelBrowsingContext;
    93     m_browsingContext = std::nullopt;
     93    m_currentBrowsingContext = std::nullopt;
    9494}
    9595
     
    9898    // Automation sends empty strings for main frame.
    9999    if (!browsingContext || browsingContext.value().isEmpty())
    100         m_browsingContext = std::nullopt;
     100        m_currentBrowsingContext = std::nullopt;
    101101    else
    102         m_browsingContext = browsingContext;
     102        m_currentBrowsingContext = browsingContext;
    103103}
    104104
     
    371371    RefPtr<InspectorObject> parameters = InspectorObject::create();
    372372    parameters->setString(ASCIILiteral("browsingContextHandle"), m_toplevelBrowsingContext.value());
    373     if (m_browsingContext)
    374         parameters->setString(ASCIILiteral("frameHandle"), m_browsingContext.value());
     373    if (m_currentBrowsingContext)
     374        parameters->setString(ASCIILiteral("frameHandle"), m_currentBrowsingContext.value());
    375375
    376376    int frameIndex;
     
    417417    }
    418418
    419     if (!m_browsingContext) {
    420         completionHandler(CommandResult::success());
    421         return;
    422     }
    423 
    424     RefPtr<InspectorObject> parameters = InspectorObject::create();
    425     parameters->setString(ASCIILiteral("browsingContextHandle"), m_toplevelBrowsingContext.value());
    426     parameters->setString(ASCIILiteral("frameHandle"), m_browsingContext.value());
     419    if (!m_currentBrowsingContext) {
     420        completionHandler(CommandResult::success());
     421        return;
     422    }
     423
     424    RefPtr<InspectorObject> parameters = InspectorObject::create();
     425    parameters->setString(ASCIILiteral("browsingContextHandle"), m_toplevelBrowsingContext.value());
     426    parameters->setString(ASCIILiteral("frameHandle"), m_currentBrowsingContext.value());
    427427    m_host->sendCommandToBackend(ASCIILiteral("resolveParentFrameHandle"), WTFMove(parameters), [this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)](SessionHost::CommandResponse&& response) {
    428428        if (response.isError || !response.responseObject) {
     
    587587    RefPtr<InspectorObject> parameters = InspectorObject::create();
    588588    parameters->setString(ASCIILiteral("browsingContextHandle"), m_toplevelBrowsingContext.value());
    589     parameters->setString(ASCIILiteral("frameHandle"), m_browsingContext.value());
     589    parameters->setString(ASCIILiteral("frameHandle"), m_currentBrowsingContext.value());
    590590    parameters->setString(ASCIILiteral("nodeHandle"), elementID);
    591591    parameters->setBoolean(ASCIILiteral("scrollIntoViewIfNeeded"), options.contains(ElementLayoutOption::ScrollIntoViewIfNeeded));
     
    654654    RefPtr<InspectorObject> parameters = InspectorObject::create();
    655655    parameters->setString(ASCIILiteral("browsingContextHandle"), m_toplevelBrowsingContext.value());
    656     if (m_browsingContext)
    657         parameters->setString(ASCIILiteral("frameHandle"), m_browsingContext.value());
     656    if (m_currentBrowsingContext)
     657        parameters->setString(ASCIILiteral("frameHandle"), m_currentBrowsingContext.value());
    658658    parameters->setString(ASCIILiteral("function"), FindNodesJavaScript);
    659659    parameters->setArray(ASCIILiteral("arguments"), WTFMove(arguments));
     
    721721    RefPtr<InspectorObject> parameters = InspectorObject::create();
    722722    parameters->setString(ASCIILiteral("browsingContextHandle"), m_toplevelBrowsingContext.value());
    723     if (m_browsingContext)
    724         parameters->setString(ASCIILiteral("frameHandle"), m_browsingContext.value());
     723    if (m_currentBrowsingContext)
     724        parameters->setString(ASCIILiteral("frameHandle"), m_currentBrowsingContext.value());
    725725    parameters->setString(ASCIILiteral("function"), ElementAttributeJavaScript);
    726726    parameters->setArray(ASCIILiteral("arguments"), WTFMove(arguments));
     
    765765    RefPtr<InspectorObject> parameters = InspectorObject::create();
    766766    parameters->setString(ASCIILiteral("browsingContextHandle"), m_toplevelBrowsingContext.value());
    767     if (m_browsingContext)
    768         parameters->setString(ASCIILiteral("frameHandle"), m_browsingContext.value());
     767    if (m_currentBrowsingContext)
     768        parameters->setString(ASCIILiteral("frameHandle"), m_currentBrowsingContext.value());
    769769    // FIXME: Add an atom to properly implement this instead of just using innerText.
    770770    parameters->setString(ASCIILiteral("function"), ASCIILiteral("function(element) { return element.innerText.replace(/^[^\\S\\xa0]+|[^\\S\\xa0]+$/g, '') }"));
     
    801801    RefPtr<InspectorObject> parameters = InspectorObject::create();
    802802    parameters->setString(ASCIILiteral("browsingContextHandle"), m_toplevelBrowsingContext.value());
    803     if (m_browsingContext)
    804         parameters->setString(ASCIILiteral("frameHandle"), m_browsingContext.value());
     803    if (m_currentBrowsingContext)
     804        parameters->setString(ASCIILiteral("frameHandle"), m_currentBrowsingContext.value());
    805805    parameters->setString(ASCIILiteral("function"), ASCIILiteral("function(element) { return element.tagName.toLowerCase() }"));
    806806    parameters->setArray(ASCIILiteral("arguments"), WTFMove(arguments));
     
    857857    RefPtr<InspectorObject> parameters = InspectorObject::create();
    858858    parameters->setString(ASCIILiteral("browsingContextHandle"), m_toplevelBrowsingContext.value());
    859     if (m_browsingContext)
    860         parameters->setString(ASCIILiteral("frameHandle"), m_browsingContext.value());
     859    if (m_currentBrowsingContext)
     860        parameters->setString(ASCIILiteral("frameHandle"), m_currentBrowsingContext.value());
    861861    parameters->setString(ASCIILiteral("function"), ASCIILiteral("function(element) { return element.disabled === undefined ? true : !element.disabled }"));
    862862    parameters->setArray(ASCIILiteral("arguments"), WTFMove(arguments));
     
    892892    RefPtr<InspectorObject> parameters = InspectorObject::create();
    893893    parameters->setString(ASCIILiteral("browsingContextHandle"), m_toplevelBrowsingContext.value());
    894     if (m_browsingContext)
    895         parameters->setString(ASCIILiteral("frameHandle"), m_browsingContext.value());
     894    if (m_currentBrowsingContext)
     895        parameters->setString(ASCIILiteral("frameHandle"), m_currentBrowsingContext.value());
    896896    parameters->setString(ASCIILiteral("function"), ElementDisplayedJavaScript);
    897897    parameters->setArray(ASCIILiteral("arguments"), WTFMove(arguments));
     
    928928    RefPtr<InspectorObject> parameters = InspectorObject::create();
    929929    parameters->setString(ASCIILiteral("browsingContextHandle"), m_toplevelBrowsingContext.value());
    930     if (m_browsingContext)
    931         parameters->setString(ASCIILiteral("frameHandle"), m_browsingContext.value());
     930    if (m_currentBrowsingContext)
     931        parameters->setString(ASCIILiteral("frameHandle"), m_currentBrowsingContext.value());
    932932    parameters->setString(ASCIILiteral("function"), ElementAttributeJavaScript);
    933933    parameters->setArray(ASCIILiteral("arguments"), WTFMove(arguments));
     
    960960    RefPtr<InspectorObject> parameters = InspectorObject::create();
    961961    parameters->setString(ASCIILiteral("browsingContextHandle"), m_toplevelBrowsingContext.value());
    962     if (m_browsingContext)
    963         parameters->setString(ASCIILiteral("frameHandle"), m_browsingContext.value());
     962    if (m_currentBrowsingContext)
     963        parameters->setString(ASCIILiteral("frameHandle"), m_currentBrowsingContext.value());
    964964    if (m_timeouts.pageLoad)
    965965        parameters->setInteger(ASCIILiteral("pageLoadTimeout"), m_timeouts.pageLoad.value().millisecondsAs<int>());
     
    10141014    RefPtr<InspectorObject> parameters = InspectorObject::create();
    10151015    parameters->setString(ASCIILiteral("browsingContextHandle"), m_toplevelBrowsingContext.value());
    1016     if (m_browsingContext)
    1017         parameters->setString(ASCIILiteral("frameHandle"), m_browsingContext.value());
     1016    if (m_currentBrowsingContext)
     1017        parameters->setString(ASCIILiteral("frameHandle"), m_currentBrowsingContext.value());
    10181018    parameters->setString(ASCIILiteral("function"), FormElementClearJavaScript);
    10191019    parameters->setArray(ASCIILiteral("arguments"), WTFMove(arguments));
     
    11761176    RefPtr<InspectorObject> parameters = InspectorObject::create();
    11771177    parameters->setString(ASCIILiteral("browsingContextHandle"), m_toplevelBrowsingContext.value());
    1178     if (m_browsingContext)
    1179         parameters->setString(ASCIILiteral("frameHandle"), m_browsingContext.value());
     1178    if (m_currentBrowsingContext)
     1179        parameters->setString(ASCIILiteral("frameHandle"), m_currentBrowsingContext.value());
    11801180    parameters->setString(ASCIILiteral("function"), focusScript);
    11811181    parameters->setArray(ASCIILiteral("arguments"), WTFMove(arguments));
     
    12351235    RefPtr<InspectorObject> parameters = InspectorObject::create();
    12361236    parameters->setString(ASCIILiteral("browsingContextHandle"), m_toplevelBrowsingContext.value());
    1237     if (m_browsingContext)
    1238         parameters->setString(ASCIILiteral("frameHandle"), m_browsingContext.value());
     1237    if (m_currentBrowsingContext)
     1238        parameters->setString(ASCIILiteral("frameHandle"), m_currentBrowsingContext.value());
    12391239    parameters->setString(ASCIILiteral("function"), FormSubmitJavaScript);
    12401240    parameters->setArray(ASCIILiteral("arguments"), WTFMove(arguments));
     
    12941294    RefPtr<InspectorObject> parameters = InspectorObject::create();
    12951295    parameters->setString(ASCIILiteral("browsingContextHandle"), m_toplevelBrowsingContext.value());
    1296     if (m_browsingContext)
    1297         parameters->setString(ASCIILiteral("frameHandle"), m_browsingContext.value());
     1296    if (m_currentBrowsingContext)
     1297        parameters->setString(ASCIILiteral("frameHandle"), m_currentBrowsingContext.value());
    12981298    parameters->setString(ASCIILiteral("function"), "function(){" + script + '}');
    12991299    parameters->setArray(ASCIILiteral("arguments"), WTFMove(arguments));
  • trunk/Source/WebDriver/Session.h

    r219722 r219833  
    160160    String m_id;
    161161    std::optional<String> m_toplevelBrowsingContext;
    162     std::optional<String> m_browsingContext;
     162    std::optional<String> m_currentBrowsingContext;
    163163};
    164164
Note: See TracChangeset for help on using the changeset viewer.