Modified: trunk/Source/WebKit2/UIProcess/Automation/Automation.json (197772 => 197773)
--- trunk/Source/WebKit2/UIProcess/Automation/Automation.json 2016-03-08 17:41:59 UTC (rev 197772)
+++ trunk/Source/WebKit2/UIProcess/Automation/Automation.json 2016-03-08 17:55:01 UTC (rev 197773)
@@ -23,7 +23,8 @@
"description": "A handle representing an open window or tab in the automation session.",
"properties": [
{ "name": "handle", "$ref": "BrowsingContextHandle", "description": "Opaque handle for a browsing context (window or tab). Used as a key for window-related commands." },
- { "name": "active", "type": "boolean", "description": "Whether the browsing context has focus at the time the command is handled." }
+ { "name": "active", "type": "boolean", "description": "Whether the browsing context has focus at the time the command is handled." },
+ { "name": "url", "type": "string", "description": "The URL loaded by the browsing context at the time the command is handled." }
]
}
],
@@ -36,6 +37,16 @@
]
},
{
+ "name": "getBrowsingContext",
+ "description": "Fetches information about the specified browsing context.",
+ "parameters": [
+ { "name": "handle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context." }
+ ],
+ "returns": [
+ { "name": "context", "$ref": "BrowsingContext", "description": "The browsing context available to the session." }
+ ]
+ },
+ {
"name": "createBrowsingContext",
"description": "Opens a new browsing context in the automation session and makes it the active browsing context for user interaction. This command creates a browsing context in a new window rather than adding a tab to an existing window.",
"returns": [
@@ -55,6 +66,35 @@
"parameters": [
{ "name": "handle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context that should be made active." }
]
+ },
+ {
+ "name": "navigateBrowsingContext",
+ "description": "Navigates a browsing context to a specified URL.",
+ "parameters": [
+ { "name": "handle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context that should be navigated." },
+ { "name": "url", "type": "string", "description": "The URL to load in the browsing context." }
+ ]
+ },
+ {
+ "name": "goBackInBrowsingContext",
+ "description": "Navigates a browsing context to go back one page in history.",
+ "parameters": [
+ { "name": "handle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context that should be navigated." }
+ ]
+ },
+ {
+ "name": "goForwardInBrowsingContext",
+ "description": "Navigates a browsing context to got forward one page in history.",
+ "parameters": [
+ { "name": "handle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context that should be navigated." }
+ ]
+ },
+ {
+ "name": "reloadBrowsingContext",
+ "description": "Reloads the current page in a browsing context.",
+ "parameters": [
+ { "name": "handle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context that should be reloaded." }
+ ]
}
]
}
Modified: trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp (197772 => 197773)
--- trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp 2016-03-08 17:41:59 UTC (rev 197772)
+++ trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp 2016-03-08 17:55:01 UTC (rev 197773)
@@ -31,6 +31,7 @@
#include "WebProcessPool.h"
#include <_javascript_Core/InspectorBackendDispatcher.h>
#include <_javascript_Core/InspectorFrontendRouter.h>
+#include <WebCore/URL.h>
#include <WebCore/UUID.h>
#include <wtf/HashMap.h>
@@ -141,6 +142,7 @@
auto browsingContext = Inspector::Protocol::Automation::BrowsingContext::create()
.setHandle(handleForWebPageProxy(page))
.setActive(m_activeBrowsingContextHandle == handle)
+ .setUrl(page->pageLoadState().activeURL())
.release();
contexts->addItem(browsingContext.copyRef());
@@ -148,6 +150,19 @@
}
}
+void WebAutomationSession::getBrowsingContext(Inspector::ErrorString& errorString, const String& handle, RefPtr<Inspector::Protocol::Automation::BrowsingContext>& context)
+{
+ WebPageProxy* page = webPageProxyForHandle(handle);
+ if (!page)
+ FAIL_WITH_PREDEFINED_ERROR_MESSAGE(WindowNotFound);
+
+ context = Inspector::Protocol::Automation::BrowsingContext::create()
+ .setHandle(handleForWebPageProxy(page))
+ .setActive(m_activeBrowsingContextHandle == handle)
+ .setUrl(page->pageLoadState().activeURL())
+ .release();
+}
+
void WebAutomationSession::createBrowsingContext(Inspector::ErrorString& errorString, String* handle)
{
ASSERT(m_client);
@@ -186,4 +201,42 @@
page->setFocus(true);
}
+void WebAutomationSession::navigateBrowsingContext(Inspector::ErrorString& errorString, const String& handle, const String& url)
+{
+ WebPageProxy* page = webPageProxyForHandle(handle);
+ if (!page)
+ FAIL_WITH_PREDEFINED_ERROR_MESSAGE(WindowNotFound);
+
+ page->loadRequest(WebCore::URL(WebCore::URL(), url));
+}
+
+void WebAutomationSession::goBackInBrowsingContext(Inspector::ErrorString& errorString, const String& handle)
+{
+ WebPageProxy* page = webPageProxyForHandle(handle);
+ if (!page)
+ FAIL_WITH_PREDEFINED_ERROR_MESSAGE(WindowNotFound);
+
+ page->goBack();
+}
+
+void WebAutomationSession::goForwardInBrowsingContext(Inspector::ErrorString& errorString, const String& handle)
+{
+ WebPageProxy* page = webPageProxyForHandle(handle);
+ if (!page)
+ FAIL_WITH_PREDEFINED_ERROR_MESSAGE(WindowNotFound);
+
+ page->goForward();
+}
+
+void WebAutomationSession::reloadBrowsingContext(Inspector::ErrorString& errorString, const String& handle)
+{
+ WebPageProxy* page = webPageProxyForHandle(handle);
+ if (!page)
+ FAIL_WITH_PREDEFINED_ERROR_MESSAGE(WindowNotFound);
+
+ const bool reloadFromOrigin = false;
+ const bool contentBlockersEnabled = true;
+ page->reload(reloadFromOrigin, contentBlockersEnabled);
+}
+
} // namespace WebKit
Modified: trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.h (197772 => 197773)
--- trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.h 2016-03-08 17:41:59 UTC (rev 197772)
+++ trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.h 2016-03-08 17:55:01 UTC (rev 197773)
@@ -80,9 +80,14 @@
// Inspector::AutomationBackendDispatcherHandler API
void getBrowsingContexts(Inspector::ErrorString&, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Automation::BrowsingContext>>&) override;
+ void getBrowsingContext(Inspector::ErrorString&, const String&, RefPtr<Inspector::Protocol::Automation::BrowsingContext>&) override;
void createBrowsingContext(Inspector::ErrorString&, String*) override;
void closeBrowsingContext(Inspector::ErrorString&, const String&) override;
void switchToBrowsingContext(Inspector::ErrorString&, const String&) override;
+ void navigateBrowsingContext(Inspector::ErrorString&, const String& handle, const String& url) override;
+ void goBackInBrowsingContext(Inspector::ErrorString&, const String&) override;
+ void goForwardInBrowsingContext(Inspector::ErrorString&, const String&) override;
+ void reloadBrowsingContext(Inspector::ErrorString&, const String&) override;
private:
WebKit::WebPageProxy* webPageProxyForHandle(const String&);