WebDriver: rename m_browsingContext as m_currentBrowsingContext in Session
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 24 Jul 2017 19:16:55 +0000 (19:16 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 24 Jul 2017 19:16:55 +0000 (19:16 +0000)
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:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219833 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebDriver/ChangeLog
Source/WebDriver/Session.cpp
Source/WebDriver/Session.h

index 138a4c3d3eeb1c4959bd7a75ce5b17c3c3e06ad6..7114d173a563e128b0132d1a4fd3ed38b4edc50c 100644 (file)
@@ -1,3 +1,34 @@
+2017-07-24  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        WebDriver: rename m_browsingContext as m_currentBrowsingContext in Session
+        https://bugs.webkit.org/show_bug.cgi?id=174783
+
+        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:
+
 2017-07-20  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         WebDriver: implement page load timeout
index 68e2fd7e6f6451abd6abb650469ae323a4950e14..b335c1d0f4a16208fe88caa49e31cd2c6f7de0e9 100644 (file)
@@ -90,16 +90,16 @@ void Session::setTimeouts(const Timeouts& timeouts, Function<void (CommandResult
 void Session::switchToTopLevelBrowsingContext(std::optional<String> toplevelBrowsingContext)
 {
     m_toplevelBrowsingContext = toplevelBrowsingContext;
-    m_browsingContext = std::nullopt;
+    m_currentBrowsingContext = std::nullopt;
 }
 
 void Session::switchToBrowsingContext(std::optional<String> browsingContext)
 {
     // Automation sends empty strings for main frame.
     if (!browsingContext || browsingContext.value().isEmpty())
-        m_browsingContext = std::nullopt;
+        m_currentBrowsingContext = std::nullopt;
     else
-        m_browsingContext = browsingContext;
+        m_currentBrowsingContext = browsingContext;
 }
 
 void Session::createTopLevelBrowsingContext(Function<void (CommandResult&&)>&& completionHandler)
@@ -370,8 +370,8 @@ void Session::switchToFrame(RefPtr<InspectorValue>&& frameID, Function<void (Com
 
     RefPtr<InspectorObject> parameters = InspectorObject::create();
     parameters->setString(ASCIILiteral("browsingContextHandle"), m_toplevelBrowsingContext.value());
-    if (m_browsingContext)
-        parameters->setString(ASCIILiteral("frameHandle"), m_browsingContext.value());
+    if (m_currentBrowsingContext)
+        parameters->setString(ASCIILiteral("frameHandle"), m_currentBrowsingContext.value());
 
     int frameIndex;
     if (frameID->asInteger(frameIndex)) {
@@ -416,14 +416,14 @@ void Session::switchToParentFrame(Function<void (CommandResult&&)>&& completionH
         return;
     }
 
-    if (!m_browsingContext) {
+    if (!m_currentBrowsingContext) {
         completionHandler(CommandResult::success());
         return;
     }
 
     RefPtr<InspectorObject> parameters = InspectorObject::create();
     parameters->setString(ASCIILiteral("browsingContextHandle"), m_toplevelBrowsingContext.value());
-    parameters->setString(ASCIILiteral("frameHandle"), m_browsingContext.value());
+    parameters->setString(ASCIILiteral("frameHandle"), m_currentBrowsingContext.value());
     m_host->sendCommandToBackend(ASCIILiteral("resolveParentFrameHandle"), WTFMove(parameters), [this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)](SessionHost::CommandResponse&& response) {
         if (response.isError || !response.responseObject) {
             completionHandler(CommandResult::fail(WTFMove(response.responseObject)));
@@ -586,7 +586,7 @@ void Session::computeElementLayout(const String& elementID, OptionSet<ElementLay
 
     RefPtr<InspectorObject> parameters = InspectorObject::create();
     parameters->setString(ASCIILiteral("browsingContextHandle"), m_toplevelBrowsingContext.value());
-    parameters->setString(ASCIILiteral("frameHandle"), m_browsingContext.value());
+    parameters->setString(ASCIILiteral("frameHandle"), m_currentBrowsingContext.value());
     parameters->setString(ASCIILiteral("nodeHandle"), elementID);
     parameters->setBoolean(ASCIILiteral("scrollIntoViewIfNeeded"), options.contains(ElementLayoutOption::ScrollIntoViewIfNeeded));
     parameters->setBoolean(ASCIILiteral("useViewportCoordinates"), options.contains(ElementLayoutOption::UseViewportCoordinates));
@@ -653,8 +653,8 @@ void Session::findElements(const String& strategy, const String& selector, FindE
 
     RefPtr<InspectorObject> parameters = InspectorObject::create();
     parameters->setString(ASCIILiteral("browsingContextHandle"), m_toplevelBrowsingContext.value());
-    if (m_browsingContext)
-        parameters->setString(ASCIILiteral("frameHandle"), m_browsingContext.value());
+    if (m_currentBrowsingContext)
+        parameters->setString(ASCIILiteral("frameHandle"), m_currentBrowsingContext.value());
     parameters->setString(ASCIILiteral("function"), FindNodesJavaScript);
     parameters->setArray(ASCIILiteral("arguments"), WTFMove(arguments));
     parameters->setBoolean(ASCIILiteral("expectsImplicitCallbackArgument"), true);
@@ -720,8 +720,8 @@ void Session::isElementSelected(const String& elementID, Function<void (CommandR
 
     RefPtr<InspectorObject> parameters = InspectorObject::create();
     parameters->setString(ASCIILiteral("browsingContextHandle"), m_toplevelBrowsingContext.value());
-    if (m_browsingContext)
-        parameters->setString(ASCIILiteral("frameHandle"), m_browsingContext.value());
+    if (m_currentBrowsingContext)
+        parameters->setString(ASCIILiteral("frameHandle"), m_currentBrowsingContext.value());
     parameters->setString(ASCIILiteral("function"), ElementAttributeJavaScript);
     parameters->setArray(ASCIILiteral("arguments"), WTFMove(arguments));
     m_host->sendCommandToBackend(ASCIILiteral("evaluateJavaScriptFunction"), WTFMove(parameters), [this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)](SessionHost::CommandResponse&& response) {
@@ -764,8 +764,8 @@ void Session::getElementText(const String& elementID, Function<void (CommandResu
 
     RefPtr<InspectorObject> parameters = InspectorObject::create();
     parameters->setString(ASCIILiteral("browsingContextHandle"), m_toplevelBrowsingContext.value());
-    if (m_browsingContext)
-        parameters->setString(ASCIILiteral("frameHandle"), m_browsingContext.value());
+    if (m_currentBrowsingContext)
+        parameters->setString(ASCIILiteral("frameHandle"), m_currentBrowsingContext.value());
     // FIXME: Add an atom to properly implement this instead of just using innerText.
     parameters->setString(ASCIILiteral("function"), ASCIILiteral("function(element) { return element.innerText.replace(/^[^\\S\\xa0]+|[^\\S\\xa0]+$/g, '') }"));
     parameters->setArray(ASCIILiteral("arguments"), WTFMove(arguments));
@@ -800,8 +800,8 @@ void Session::getElementTagName(const String& elementID, Function<void (CommandR
 
     RefPtr<InspectorObject> parameters = InspectorObject::create();
     parameters->setString(ASCIILiteral("browsingContextHandle"), m_toplevelBrowsingContext.value());
-    if (m_browsingContext)
-        parameters->setString(ASCIILiteral("frameHandle"), m_browsingContext.value());
+    if (m_currentBrowsingContext)
+        parameters->setString(ASCIILiteral("frameHandle"), m_currentBrowsingContext.value());
     parameters->setString(ASCIILiteral("function"), ASCIILiteral("function(element) { return element.tagName.toLowerCase() }"));
     parameters->setArray(ASCIILiteral("arguments"), WTFMove(arguments));
     m_host->sendCommandToBackend(ASCIILiteral("evaluateJavaScriptFunction"), WTFMove(parameters), [this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)](SessionHost::CommandResponse&& response) {
@@ -856,8 +856,8 @@ void Session::isElementEnabled(const String& elementID, Function<void (CommandRe
 
     RefPtr<InspectorObject> parameters = InspectorObject::create();
     parameters->setString(ASCIILiteral("browsingContextHandle"), m_toplevelBrowsingContext.value());
-    if (m_browsingContext)
-        parameters->setString(ASCIILiteral("frameHandle"), m_browsingContext.value());
+    if (m_currentBrowsingContext)
+        parameters->setString(ASCIILiteral("frameHandle"), m_currentBrowsingContext.value());
     parameters->setString(ASCIILiteral("function"), ASCIILiteral("function(element) { return element.disabled === undefined ? true : !element.disabled }"));
     parameters->setArray(ASCIILiteral("arguments"), WTFMove(arguments));
     m_host->sendCommandToBackend(ASCIILiteral("evaluateJavaScriptFunction"), WTFMove(parameters), [this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)](SessionHost::CommandResponse&& response) {
@@ -891,8 +891,8 @@ void Session::isElementDisplayed(const String& elementID, Function<void (Command
 
     RefPtr<InspectorObject> parameters = InspectorObject::create();
     parameters->setString(ASCIILiteral("browsingContextHandle"), m_toplevelBrowsingContext.value());
-    if (m_browsingContext)
-        parameters->setString(ASCIILiteral("frameHandle"), m_browsingContext.value());
+    if (m_currentBrowsingContext)
+        parameters->setString(ASCIILiteral("frameHandle"), m_currentBrowsingContext.value());
     parameters->setString(ASCIILiteral("function"), ElementDisplayedJavaScript);
     parameters->setArray(ASCIILiteral("arguments"), WTFMove(arguments));
     m_host->sendCommandToBackend(ASCIILiteral("evaluateJavaScriptFunction"), WTFMove(parameters), [this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)](SessionHost::CommandResponse&& response) {
@@ -927,8 +927,8 @@ void Session::getElementAttribute(const String& elementID, const String& attribu
 
     RefPtr<InspectorObject> parameters = InspectorObject::create();
     parameters->setString(ASCIILiteral("browsingContextHandle"), m_toplevelBrowsingContext.value());
-    if (m_browsingContext)
-        parameters->setString(ASCIILiteral("frameHandle"), m_browsingContext.value());
+    if (m_currentBrowsingContext)
+        parameters->setString(ASCIILiteral("frameHandle"), m_currentBrowsingContext.value());
     parameters->setString(ASCIILiteral("function"), ElementAttributeJavaScript);
     parameters->setArray(ASCIILiteral("arguments"), WTFMove(arguments));
     m_host->sendCommandToBackend(ASCIILiteral("evaluateJavaScriptFunction"), WTFMove(parameters), [this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)](SessionHost::CommandResponse&& response) {
@@ -959,8 +959,8 @@ void Session::waitForNavigationToComplete(Function<void (CommandResult&&)>&& com
 
     RefPtr<InspectorObject> parameters = InspectorObject::create();
     parameters->setString(ASCIILiteral("browsingContextHandle"), m_toplevelBrowsingContext.value());
-    if (m_browsingContext)
-        parameters->setString(ASCIILiteral("frameHandle"), m_browsingContext.value());
+    if (m_currentBrowsingContext)
+        parameters->setString(ASCIILiteral("frameHandle"), m_currentBrowsingContext.value());
     if (m_timeouts.pageLoad)
         parameters->setInteger(ASCIILiteral("pageLoadTimeout"), m_timeouts.pageLoad.value().millisecondsAs<int>());
     m_host->sendCommandToBackend(ASCIILiteral("waitForNavigationToComplete"), WTFMove(parameters), [this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)](SessionHost::CommandResponse&& response) {
@@ -1013,8 +1013,8 @@ void Session::elementClear(const String& elementID, Function<void (CommandResult
 
     RefPtr<InspectorObject> parameters = InspectorObject::create();
     parameters->setString(ASCIILiteral("browsingContextHandle"), m_toplevelBrowsingContext.value());
-    if (m_browsingContext)
-        parameters->setString(ASCIILiteral("frameHandle"), m_browsingContext.value());
+    if (m_currentBrowsingContext)
+        parameters->setString(ASCIILiteral("frameHandle"), m_currentBrowsingContext.value());
     parameters->setString(ASCIILiteral("function"), FormElementClearJavaScript);
     parameters->setArray(ASCIILiteral("arguments"), WTFMove(arguments));
     m_host->sendCommandToBackend(ASCIILiteral("evaluateJavaScriptFunction"), WTFMove(parameters), [this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)](SessionHost::CommandResponse&& response) {
@@ -1175,8 +1175,8 @@ void Session::elementSendKeys(const String& elementID, Vector<String>&& keys, Fu
     arguments->pushString(createElement(elementID)->toJSONString());
     RefPtr<InspectorObject> parameters = InspectorObject::create();
     parameters->setString(ASCIILiteral("browsingContextHandle"), m_toplevelBrowsingContext.value());
-    if (m_browsingContext)
-        parameters->setString(ASCIILiteral("frameHandle"), m_browsingContext.value());
+    if (m_currentBrowsingContext)
+        parameters->setString(ASCIILiteral("frameHandle"), m_currentBrowsingContext.value());
     parameters->setString(ASCIILiteral("function"), focusScript);
     parameters->setArray(ASCIILiteral("arguments"), WTFMove(arguments));
     m_host->sendCommandToBackend(ASCIILiteral("evaluateJavaScriptFunction"), WTFMove(parameters), [this, protectedThis = makeRef(*this), keys = WTFMove(keys), completionHandler = WTFMove(completionHandler)](SessionHost::CommandResponse&& response) mutable {
@@ -1234,8 +1234,8 @@ void Session::elementSubmit(const String& elementID, Function<void (CommandResul
 
     RefPtr<InspectorObject> parameters = InspectorObject::create();
     parameters->setString(ASCIILiteral("browsingContextHandle"), m_toplevelBrowsingContext.value());
-    if (m_browsingContext)
-        parameters->setString(ASCIILiteral("frameHandle"), m_browsingContext.value());
+    if (m_currentBrowsingContext)
+        parameters->setString(ASCIILiteral("frameHandle"), m_currentBrowsingContext.value());
     parameters->setString(ASCIILiteral("function"), FormSubmitJavaScript);
     parameters->setArray(ASCIILiteral("arguments"), WTFMove(arguments));
     m_host->sendCommandToBackend(ASCIILiteral("evaluateJavaScriptFunction"), WTFMove(parameters), [this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)](SessionHost::CommandResponse&& response) {
@@ -1293,8 +1293,8 @@ void Session::executeScript(const String& script, RefPtr<InspectorArray>&& argum
 
     RefPtr<InspectorObject> parameters = InspectorObject::create();
     parameters->setString(ASCIILiteral("browsingContextHandle"), m_toplevelBrowsingContext.value());
-    if (m_browsingContext)
-        parameters->setString(ASCIILiteral("frameHandle"), m_browsingContext.value());
+    if (m_currentBrowsingContext)
+        parameters->setString(ASCIILiteral("frameHandle"), m_currentBrowsingContext.value());
     parameters->setString(ASCIILiteral("function"), "function(){" + script + '}');
     parameters->setArray(ASCIILiteral("arguments"), WTFMove(arguments));
     if (mode == ExecuteScriptMode::Async) {
index 137b82adfe265727cb306bb6b9ba6c521accdc5f..143e9ea45094b2aebcfcb97bb11e790f7f9ec49b 100644 (file)
@@ -159,7 +159,7 @@ private:
     Timeouts m_timeouts;
     String m_id;
     std::optional<String> m_toplevelBrowsingContext;
-    std::optional<String> m_browsingContext;
+    std::optional<String> m_currentBrowsingContext;
 };
 
 } // WebDriver