WebKit Bugzilla
Attachment 358920 Details for
Bug 193333
: WebDriver: update Create Browsing Context implementation to support newest specification
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
For Landing
bug-193333-20190111114526.patch (text/plain), 15.13 KB, created by
BJ Burg
on 2019-01-11 11:45:27 PST
(
hide
)
Description:
For Landing
Filename:
MIME Type:
Creator:
BJ Burg
Created:
2019-01-11 11:45:27 PST
Size:
15.13 KB
patch
obsolete
>Subversion Revision: 239864 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index d53cc33c6927e61aa4e69dae90da8051257de925..4f028c7270b85e363233689dc0c1ad84594f41ee 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,40 @@ >+2019-01-10 Brian Burg <bburg@apple.com> >+ >+ WebDriver: update Create Window implementation to support newest specification >+ https://bugs.webkit.org/show_bug.cgi?id=193333 >+ <rdar://problem/45649489> >+ >+ Reviewed by Carlos Garcia Campos. >+ >+ Spec link: https://w3c.github.io/webdriver/#create-window >+ >+ The command as specified returns a value indicating whether the new browsing context >+ was presented as a new tab or new window. Add a new delegate method to query the current >+ 'presentation' of the browsing context. The presentation can change over time due to >+ things such as screen orientation, so the value that is returned by the command only >+ reflects how the browsing context was initially presented to the user. >+ >+ This is covered by existing WPT and internal tests. More will be added when Selenium >+ exposes this command in its various bindings. >+ >+ * UIProcess/API/Cocoa/_WKAutomationSessionDelegate.h: >+ Add new SPI delegate method to query the 'presentation' (tab or window) for an automated WKWebView. >+ >+ * UIProcess/API/APIAutomationSessionClient.h: >+ (API::AutomationSessionClient::currentPresentationOfPage): >+ * UIProcess/Cocoa/AutomationSessionClient.h: >+ * UIProcess/Cocoa/AutomationSessionClient.mm: >+ (WebKit::AutomationSessionClient::AutomationSessionClient): >+ (WebKit::toImpl): >+ (WebKit::AutomationSessionClient::currentPresentationOfPage): >+ * UIProcess/Automation/WebAutomationSession.cpp: >+ (WebKit::toProtocol): >+ (WebKit::WebAutomationSession::createBrowsingContext): >+ Add plumbing between ObjC delegate and C++. >+ >+ * UIProcess/Automation/Automation.json: >+ Include the initial presentation in the createBrowsingContext command result. >+ > 2019-01-11 Wenson Hsieh <wenson_hsieh@apple.com> > > Introduce IDL files for runtime-enabled UndoManager and UndoItem JavaScript API >diff --git a/Source/WebKit/UIProcess/API/APIAutomationSessionClient.h b/Source/WebKit/UIProcess/API/APIAutomationSessionClient.h >index da82e88c5452ec0bb05435afde0f849256beb5cd..28faf68719a9d728d51b6c772d84e17b649097ca 100644 >--- a/Source/WebKit/UIProcess/API/APIAutomationSessionClient.h >+++ b/Source/WebKit/UIProcess/API/APIAutomationSessionClient.h >@@ -49,6 +49,11 @@ public: > BeforeUnloadConfirm > }; > >+ enum class BrowsingContextPresentation { >+ Tab, >+ Window, >+ }; >+ > virtual ~AutomationSessionClient() { } > > virtual WTF::String sessionIdentifier() const { return WTF::String(); } >@@ -64,6 +69,7 @@ public: > virtual WTF::String messageOfCurrentJavaScriptDialogOnPage(WebKit::WebAutomationSession&, WebKit::WebPageProxy&) { return WTF::String(); } > virtual void setUserInputForCurrentJavaScriptPromptOnPage(WebKit::WebAutomationSession&, WebKit::WebPageProxy&, const WTF::String&) { } > virtual Optional<JavaScriptDialogType> typeOfCurrentJavaScriptDialogOnPage(WebKit::WebAutomationSession&, WebKit::WebPageProxy&) { return WTF::nullopt; } >+ virtual BrowsingContextPresentation currentPresentationOfPage(WebKit::WebAutomationSession&, WebKit::WebPageProxy&) { return BrowsingContextPresentation::Window; } > }; > > } // namespace API >diff --git a/Source/WebKit/UIProcess/API/Cocoa/_WKAutomationSessionDelegate.h b/Source/WebKit/UIProcess/API/Cocoa/_WKAutomationSessionDelegate.h >index 293865cc8645120bee505d93e1822e2de5e93379..cc59d3cfceb1baef98de1e6f8eaaaf214588fd16 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/_WKAutomationSessionDelegate.h >+++ b/Source/WebKit/UIProcess/API/Cocoa/_WKAutomationSessionDelegate.h >@@ -46,6 +46,11 @@ typedef NS_ENUM(NSUInteger, _WKAutomationSessionBrowsingContextOptions) { > _WKAutomationSessionBrowsingContextOptionsPreferNewTab = 1 << 0, > } WK_API_AVAILABLE(macosx(10.14), ios(12.0)); > >+typedef NS_ENUM(NSInteger, _WKAutomationSessionBrowsingContextPresentation) { >+ _WKAutomationSessionBrowsingContextPresentationTab, >+ _WKAutomationSessionBrowsingContextPresentationWindow, >+} WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); >+ > @protocol _WKAutomationSessionDelegate <NSObject> > @optional > >@@ -62,6 +67,7 @@ typedef NS_ENUM(NSUInteger, _WKAutomationSessionBrowsingContextOptions) { > - (nullable NSString *)_automationSession:(_WKAutomationSession *)automationSession messageOfCurrentJavaScriptDialogForWebView:(WKWebView *)webView WK_API_AVAILABLE(macosx(10.13), ios(11.0)); > - (void)_automationSession:(_WKAutomationSession *)automationSession setUserInput:(NSString *)value forCurrentJavaScriptDialogForWebView:(WKWebView *)webView WK_API_AVAILABLE(macosx(10.13), ios(11.0)); > - (_WKAutomationSessionJavaScriptDialogType)_automationSession:(_WKAutomationSession *)automationSession typeOfCurrentJavaScriptDialogForWebView:(WKWebView *)webView WK_API_AVAILABLE(macosx(10.14), ios(12.0)); >+- (_WKAutomationSessionBrowsingContextPresentation)_automationSession:(_WKAutomationSession *)automationSession currentPresentationForWebView:(WKWebView *)webView WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); > > @end > >diff --git a/Source/WebKit/UIProcess/Automation/Automation.json b/Source/WebKit/UIProcess/Automation/Automation.json >index 31e0d9ce3adfadf6dc036bdbb6d18522809bf84e..671a761ae3637b58158fa10f1f4afd1b2a5bd36e 100644 >--- a/Source/WebKit/UIProcess/Automation/Automation.json >+++ b/Source/WebKit/UIProcess/Automation/Automation.json >@@ -41,6 +41,15 @@ > "type": "string", > "description": "An opaque identifier for a browsing context." > }, >+ { >+ "id": "BrowsingContextPresentation", >+ "type": "string", >+ "description": "How a browsing context is presented by the user agent. A browsing context is considered a tab if it shares an OS-level window with another browsing context.", >+ "enum": [ >+ "Window", >+ "Tab" >+ ] >+ }, > { > "id": "FrameHandle", > "type": "string", >@@ -323,10 +332,11 @@ > "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.", > "parameters": [ >- { "name": "preferNewTab", "type": "boolean", "optional": true, "description": "Create the new browsing context as a tab in an existing Automation window, if possible."} >+ { "name": "presentationHint", "$ref": "BrowsingContextPresentation", "optional": true, "description": "A hint for the desired presentation of new browsing context (new tab or new window)."} > ], > "returns": [ >- { "name": "handle", "$ref": "BrowsingContextHandle", "description": "An opaque handle for the newly created browsing context." } >+ { "name": "handle", "$ref": "BrowsingContextHandle", "description": "An opaque handle for the newly created browsing context." }, >+ { "name": "presentation", "$ref": "BrowsingContextPresentation", "description": "How the browser presented the new browsing context (new tab or new window)." } > ], > "async": true > }, >diff --git a/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp b/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp >index d209fae99d3ea7600c72c6af3ea84430a2f1ff49..6c4edebb1729f7cefb48922a9565b0e7ea5b0610 100644 >--- a/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp >+++ b/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp >@@ -298,21 +298,35 @@ void WebAutomationSession::getBrowsingContext(const String& handle, Ref<GetBrows > }); > } > >-void WebAutomationSession::createBrowsingContext(const bool* preferNewTab, Ref<CreateBrowsingContextCallback>&& callback) >+static Inspector::Protocol::Automation::BrowsingContextPresentation toProtocol(API::AutomationSessionClient::BrowsingContextPresentation value) >+{ >+ switch (value) { >+ case API::AutomationSessionClient::BrowsingContextPresentation::Tab: >+ return Inspector::Protocol::Automation::BrowsingContextPresentation::Tab; >+ case API::AutomationSessionClient::BrowsingContextPresentation::Window: >+ return Inspector::Protocol::Automation::BrowsingContextPresentation::Window; >+ } >+} >+ >+void WebAutomationSession::createBrowsingContext(const String* optionalPresentationHint, Ref<CreateBrowsingContextCallback>&& callback) > { > ASSERT(m_client); > if (!m_client) > ASYNC_FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InternalError, "The remote session could not request a new browsing context."); > > uint16_t options = 0; >- if (preferNewTab && *preferNewTab) >- options |= API::AutomationSessionBrowsingContextOptionsPreferNewTab; >+ >+ if (optionalPresentationHint) { >+ auto parsedPresentationHint = Inspector::Protocol::AutomationHelpers::parseEnumValueFromString<Inspector::Protocol::Automation::BrowsingContextPresentation>(*optionalPresentationHint); >+ if (parsedPresentationHint.hasValue() && parsedPresentationHint.value() == Inspector::Protocol::Automation::BrowsingContextPresentation::Tab) >+ options |= API::AutomationSessionBrowsingContextOptionsPreferNewTab; >+ } > > m_client->requestNewPageWithOptions(*this, static_cast<API::AutomationSessionBrowsingContextOptions>(options), [protectedThis = makeRef(*this), callback = WTFMove(callback)](WebPageProxy* page) { >- if (page) >- callback->sendSuccess(protectedThis->handleForWebPageProxy(*page)); >- else >+ if (!page) > ASYNC_FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InternalError, "The remote session failed to create a new browsing context."); >+ >+ callback->sendSuccess(protectedThis->handleForWebPageProxy(*page), toProtocol(protectedThis->m_client->currentPresentationOfPage(protectedThis.get(), *page))); > }); > } > >diff --git a/Source/WebKit/UIProcess/Automation/WebAutomationSession.h b/Source/WebKit/UIProcess/Automation/WebAutomationSession.h >index 0cfc12ce77723685881c80cfc19925810fbdd50a..be0afec67f578f6109eae535a3d83f8683f7201c 100644 >--- a/Source/WebKit/UIProcess/Automation/WebAutomationSession.h >+++ b/Source/WebKit/UIProcess/Automation/WebAutomationSession.h >@@ -147,7 +147,7 @@ public: > // Platform: Generic > void getBrowsingContexts(Ref<GetBrowsingContextsCallback>&&) final; > void getBrowsingContext(const String&, Ref<GetBrowsingContextCallback>&&) final; >- void createBrowsingContext(const bool* preferNewTab, Ref<CreateBrowsingContextCallback>&&) final; >+ void createBrowsingContext(const String* optionalPresentationHint, Ref<CreateBrowsingContextCallback>&&) final; > void closeBrowsingContext(Inspector::ErrorString&, const String&) final; > void switchToBrowsingContext(const String& browsingContextHandle, const String* optionalFrameHandle, Ref<SwitchToBrowsingContextCallback>&&) final; > void setWindowFrameOfBrowsingContext(const String& handle, const JSON::Object* origin, const JSON::Object* size, Ref<SetWindowFrameOfBrowsingContextCallback>&&) final; >diff --git a/Source/WebKit/UIProcess/Cocoa/AutomationSessionClient.h b/Source/WebKit/UIProcess/Cocoa/AutomationSessionClient.h >index b0b46c6e3529099c49549652f01467b6655502d0..01ae03335c46512b77599cb8a6384c9d0d4f165c 100644 >--- a/Source/WebKit/UIProcess/Cocoa/AutomationSessionClient.h >+++ b/Source/WebKit/UIProcess/Cocoa/AutomationSessionClient.h >@@ -57,6 +57,7 @@ private: > String messageOfCurrentJavaScriptDialogOnPage(WebAutomationSession&, WebPageProxy&) override; > void setUserInputForCurrentJavaScriptPromptOnPage(WebAutomationSession&, WebPageProxy&, const String&) override; > Optional<API::AutomationSessionClient::JavaScriptDialogType> typeOfCurrentJavaScriptDialogOnPage(WebAutomationSession&, WebPageProxy&) override; >+ API::AutomationSessionClient::BrowsingContextPresentation currentPresentationOfPage(WebAutomationSession&, WebPageProxy&) override; > > WeakObjCPtr<id <_WKAutomationSessionDelegate>> m_delegate; > >@@ -74,6 +75,7 @@ private: > bool messageOfCurrentJavaScriptDialogForWebView : 1; > bool setUserInputForCurrentJavaScriptPromptForWebView : 1; > bool typeOfCurrentJavaScriptDialogForWebView : 1; >+ bool currentPresentationForWebView : 1; > } m_delegateMethods; > }; > >diff --git a/Source/WebKit/UIProcess/Cocoa/AutomationSessionClient.mm b/Source/WebKit/UIProcess/Cocoa/AutomationSessionClient.mm >index b2f7d25c26ca9a062088ac4899fe087045173a7c..1271ba85949088282a15a9a9eb36ef4539ad2d9d 100644 >--- a/Source/WebKit/UIProcess/Cocoa/AutomationSessionClient.mm >+++ b/Source/WebKit/UIProcess/Cocoa/AutomationSessionClient.mm >@@ -54,6 +54,7 @@ AutomationSessionClient::AutomationSessionClient(id <_WKAutomationSessionDelegat > m_delegateMethods.messageOfCurrentJavaScriptDialogForWebView = [delegate respondsToSelector:@selector(_automationSession:messageOfCurrentJavaScriptDialogForWebView:)]; > m_delegateMethods.setUserInputForCurrentJavaScriptPromptForWebView = [delegate respondsToSelector:@selector(_automationSession:setUserInput:forCurrentJavaScriptDialogForWebView:)]; > m_delegateMethods.typeOfCurrentJavaScriptDialogForWebView = [delegate respondsToSelector:@selector(_automationSession:typeOfCurrentJavaScriptDialogForWebView:)]; >+ m_delegateMethods.currentPresentationForWebView = [delegate respondsToSelector:@selector(_automationSession:currentPresentationForWebView:)]; > } > > void AutomationSessionClient::didDisconnectFromRemote(WebAutomationSession& session) >@@ -153,6 +154,16 @@ static Optional<API::AutomationSessionClient::JavaScriptDialogType> toImpl(_WKAu > } > } > >+static API::AutomationSessionClient::BrowsingContextPresentation toImpl(_WKAutomationSessionBrowsingContextPresentation presentation) >+{ >+ switch (presentation) { >+ case _WKAutomationSessionBrowsingContextPresentationTab: >+ return API::AutomationSessionClient::BrowsingContextPresentation::Tab; >+ case _WKAutomationSessionBrowsingContextPresentationWindow: >+ return API::AutomationSessionClient::BrowsingContextPresentation::Window; >+ } >+} >+ > Optional<API::AutomationSessionClient::JavaScriptDialogType> AutomationSessionClient::typeOfCurrentJavaScriptDialogOnPage(WebAutomationSession& session, WebPageProxy& page) > { > if (m_delegateMethods.typeOfCurrentJavaScriptDialogForWebView) >@@ -161,6 +172,14 @@ Optional<API::AutomationSessionClient::JavaScriptDialogType> AutomationSessionCl > return API::AutomationSessionClient::JavaScriptDialogType::Prompt; > } > >+API::AutomationSessionClient::BrowsingContextPresentation AutomationSessionClient::currentPresentationOfPage(WebAutomationSession& session, WebPageProxy& page) >+{ >+ if (m_delegateMethods.currentPresentationForWebView) >+ return toImpl([m_delegate.get() _automationSession:wrapper(session) currentPresentationForWebView:fromWebPageProxy(page)]); >+ >+ return API::AutomationSessionClient::BrowsingContextPresentation::Window; >+} >+ > } // namespace WebKit > > #endif // WK_API_ENABLED
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 193333
:
358833
|
358837
| 358920