Modified: trunk/Source/WebKit/ChangeLog (229963 => 229964)
--- trunk/Source/WebKit/ChangeLog 2018-03-25 20:22:18 UTC (rev 229963)
+++ trunk/Source/WebKit/ChangeLog 2018-03-25 20:22:36 UTC (rev 229964)
@@ -1,3 +1,37 @@
+2018-03-23 Brian Burg <bb...@apple.com>
+
+ Web Automation: remove unnecessary member variable WebAutomationSession
+ https://bugs.webkit.org/show_bug.cgi?id=183971
+
+ Reviewed by Timothy Hatcher.
+
+ The concept of the "active" browsing context is something in the WebDriver
+ specification, but we were a bit too literal when first implementing this.
+ There's no actual need for this on the browser side since most commands
+ require implicitly switching to the target window passed in with the
+ Automation command. The driver, however, still needs to track the current
+ browsing context and current top-level browsing context.
+
+ For returning whether a browsing context is active, we can just look at
+ the page's activity state to know whether the page is active or not. For
+ a normal browser, only one page is going to be visible and focused at a time.
+
+ * UIProcess/Automation/WebAutomationSession.h:
+ * UIProcess/Automation/WebAutomationSession.cpp:
+ (WebKit::WebAutomationSession::buildBrowsingContextForPage):
+ Consult the page's activity state to determine whether it's active.
+
+ (WebKit::WebAutomationSession::createBrowsingContext):
+ (WebKit::WebAutomationSession::closeBrowsingContext):
+ (WebKit::WebAutomationSession::switchToBrowsingContext):
+ (WebKit::WebAutomationSession::handleRunOpenPanel):
+ Stop reading and writing the current browsing context handle.
+
+ * UIProcess/WebPageProxy.h:
+ (WebKit::WebPageProxy::isViewFocused const):
+ (WebKit::WebPageProxy::isViewWindowActive const):
+ Add new accessor.
+
2018-03-25 Tim Horton <timothy_hor...@apple.com>
Add and adopt ENABLE(AIRPLAY_PICKER)
Modified: trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp (229963 => 229964)
--- trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp 2018-03-25 20:22:18 UTC (rev 229963)
+++ trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp 2018-03-25 20:22:36 UTC (rev 229964)
@@ -218,11 +218,12 @@
.setHeight(windowFrame.height())
.release();
+ bool isActive = page.isViewVisible() && page.isViewFocused() && page.isViewWindowActive();
String handle = handleForWebPageProxy(page);
return Inspector::Protocol::Automation::BrowsingContext::create()
.setHandle(handle)
- .setActive(m_activeBrowsingContextHandle == handle)
+ .setActive(isActive)
.setUrl(page.pageLoadState().activeURL())
.setWindowOrigin(WTFMove(originObject))
.setWindowSize(WTFMove(sizeObject))
@@ -280,8 +281,6 @@
WebPageProxy* page = m_client->didRequestNewWindow(*this);
if (!page)
SYNC_FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InternalError, "The remote session failed to create a new browsing context.");
-
- m_activeBrowsingContextHandle = *handle = handleForWebPageProxy(*page);
}
void WebAutomationSession::closeBrowsingContext(Inspector::ErrorString& errorString, const String& handle)
@@ -290,9 +289,6 @@
if (!page)
SYNC_FAIL_WITH_PREDEFINED_ERROR(WindowNotFound);
- if (handle == m_activeBrowsingContextHandle)
- m_activeBrowsingContextHandle = emptyString();
-
page->closePage(false);
}
@@ -306,9 +302,6 @@
if (!frameID)
SYNC_FAIL_WITH_PREDEFINED_ERROR(FrameNotFound);
- // FIXME: We don't need to track this in WK2. Remove in a follow up.
- m_activeBrowsingContextHandle = browsingContextHandle;
-
page->setFocus(true);
page->process().send(Messages::WebAutomationSessionProxy::FocusFrame(page->pageID(), frameID.value()), 0);
}
@@ -692,15 +685,16 @@
void WebAutomationSession::handleRunOpenPanel(const WebPageProxy& page, const WebFrameProxy&, const API::OpenPanelParameters& parameters, WebOpenPanelResultListenerProxy& resultListener)
{
+ String browsingContextHandle = handleForWebPageProxy(page);
if (!m_filesToSelectForFileUpload.size()) {
resultListener.cancel();
- m_domainNotifier->fileChooserDismissed(m_activeBrowsingContextHandle, true);
+ m_domainNotifier->fileChooserDismissed(browsingContextHandle, true);
return;
}
if (m_filesToSelectForFileUpload.size() > 1 && !parameters.allowMultipleFiles()) {
resultListener.cancel();
- m_domainNotifier->fileChooserDismissed(m_activeBrowsingContextHandle, true);
+ m_domainNotifier->fileChooserDismissed(browsingContextHandle, true);
return;
}
@@ -723,13 +717,13 @@
for (const String& filename : m_filesToSelectForFileUpload) {
if (!fileCanBeAcceptedForUpload(filename, allowedMIMETypes, allowedFileExtensions)) {
resultListener.cancel();
- m_domainNotifier->fileChooserDismissed(m_activeBrowsingContextHandle, true);
+ m_domainNotifier->fileChooserDismissed(browsingContextHandle, true);
return;
}
}
resultListener.chooseFiles(m_filesToSelectForFileUpload);
- m_domainNotifier->fileChooserDismissed(m_activeBrowsingContextHandle, false);
+ m_domainNotifier->fileChooserDismissed(browsingContextHandle, false);
}
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)
Modified: trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.h (229963 => 229964)
--- trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.h 2018-03-25 20:22:18 UTC (rev 229963)
+++ trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.h 2018-03-25 20:22:36 UTC (rev 229964)
@@ -218,7 +218,6 @@
HashMap<uint64_t, String> m_webPageHandleMap;
HashMap<String, uint64_t> m_handleWebPageMap;
- String m_activeBrowsingContextHandle;
HashMap<uint64_t, String> m_webFrameHandleMap;
HashMap<String, uint64_t> m_handleWebFrameMap;
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (229963 => 229964)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2018-03-25 20:22:18 UTC (rev 229963)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2018-03-25 20:22:36 UTC (rev 229964)
@@ -496,7 +496,8 @@
WebCore::IntSize viewSize() const;
bool isViewVisible() const { return m_activityState & WebCore::ActivityState::IsVisible; }
- bool isViewWindowActive() const;
+ bool isViewFocused() const { return m_activityState & WebCore::ActivityState::IsFocused; }
+ bool isViewWindowActive() const { return m_activityState & WebCore::ActivityState::WindowIsActive; }
void addMIMETypeWithCustomContentProvider(const String& mimeType);