WebDriver: crash in Session::computeElementLayout when called without a current brows...
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Nov 2017 16:55:39 +0000 (16:55 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Nov 2017 16:55:39 +0000 (16:55 +0000)
https://bugs.webkit.org/show_bug.cgi?id=179917

Reviewed by Darin Adler.

In the case of computeElementLayout message, the frameHandle parameter is not optional, but we still need to
provide a valid value (empty string means the default frame) when m_currentBrowsingContext is std::nullopt. The
same applies to selectOptionElement.

* Session.cpp:
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::selectOptionElement):

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

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

index 6ab34ee..1eaff68 100644 (file)
@@ -1,3 +1,18 @@
+2017-11-21  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        WebDriver: crash in Session::computeElementLayout when called without a current browsing context
+        https://bugs.webkit.org/show_bug.cgi?id=179917
+
+        Reviewed by Darin Adler.
+
+        In the case of computeElementLayout message, the frameHandle parameter is not optional, but we still need to
+        provide a valid value (empty string means the default frame) when m_currentBrowsingContext is std::nullopt. The
+        same applies to selectOptionElement.
+
+        * Session.cpp:
+        (WebDriver::Session::computeElementLayout):
+        (WebDriver::Session::selectOptionElement):
+
 2017-11-15  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [WPE] Add initial support for WebDriver
index 4413f7f..8378858 100644 (file)
@@ -822,7 +822,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_currentBrowsingContext.value());
+    parameters->setString(ASCIILiteral("frameHandle"), m_currentBrowsingContext.value_or(emptyString()));
     parameters->setString(ASCIILiteral("nodeHandle"), elementID);
     parameters->setBoolean(ASCIILiteral("scrollIntoViewIfNeeded"), options.contains(ElementLayoutOption::ScrollIntoViewIfNeeded));
     parameters->setString(ASCIILiteral("coordinateSystem"), options.contains(ElementLayoutOption::UseViewportCoordinates) ? ASCIILiteral("LayoutViewport") : ASCIILiteral("Page"));
@@ -1280,7 +1280,7 @@ void Session::selectOptionElement(const String& elementID, Function<void (Comman
 {
     RefPtr<InspectorObject> parameters = InspectorObject::create();
     parameters->setString(ASCIILiteral("browsingContextHandle"), m_toplevelBrowsingContext.value());
-    parameters->setString(ASCIILiteral("frameHandle"), m_currentBrowsingContext.value());
+    parameters->setString(ASCIILiteral("frameHandle"), m_currentBrowsingContext.value_or(emptyString()));
     parameters->setString(ASCIILiteral("nodeHandle"), elementID);
     m_host->sendCommandToBackend(ASCIILiteral("selectOptionElement"), WTFMove(parameters), [this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)](SessionHost::CommandResponse&& response) {
         if (response.isError) {