Title: [221465] trunk
Revision
221465
Author
achristen...@apple.com
Date
2017-08-31 18:46:26 -0700 (Thu, 31 Aug 2017)

Log Message

Add ObjC SPI corresponding to WKPageLoaderClient's webGLLoadPolicy and resolveWebGLLoadPolicy
https://bugs.webkit.org/show_bug.cgi?id=175779
<rdar://problem/22367975>

Reviewed by Tim Horton.

Source/WebCore:

Covered by new API tests.

* loader/FrameLoaderClient.h:

Source/WebKit:

* UIProcess/API/APINavigationClient.h:
(API::NavigationClient::webGLLoadPolicy const):
(API::NavigationClient::resolveWebGLLoadPolicy const):
* UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h:
* UIProcess/Cocoa/NavigationState.h:
* UIProcess/Cocoa/NavigationState.mm:
(WebKit::NavigationState::setNavigationDelegate):
(WebKit::toWebCoreWebGLLoadPolicy):
(WebKit::NavigationState::NavigationClient::webGLLoadPolicy const):
(WebKit::NavigationState::NavigationClient::resolveWebGLLoadPolicy const):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::webGLPolicyForURL):
(WebKit::WebPageProxy::resolveWebGLPolicyForURL):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::webGLPolicyForURL const):
(WebKit::WebFrameLoaderClient::resolveWebGLPolicyForURL const):
* WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::webGLPolicyForURL):
(WebKit::WebPage::resolveWebGLPolicyForURL):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::webGLPolicyForURL):
(WebKit::WebPage::resolveWebGLPolicyForURL):
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::webGLPolicyForURL):
(WebKit::WebPage::resolveWebGLPolicyForURL):

Source/WebKitLegacy/mac:

* WebCoreSupport/WebFrameLoaderClient.h:
* WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::webGLPolicyForURL const):
(WebFrameLoaderClient::resolveWebGLPolicyForURL const):

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKitCocoa/WebGLPolicy.mm: Added.
(-[WebGLTestDelegate webView:startURLSchemeTask:]):
(-[WebGLTestDelegate webView:stopURLSchemeTask:]):
(-[WebGLTestDelegate _webView:webGLLoadPolicyForURL:decisionHandler:]):
(-[WebGLTestDelegate _webView:resolveWebGLLoadPolicyForURL:decisionHandler:]):
(-[WebGLTestDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]):
(urlsEqual):
(runTest):
(TEST):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (221464 => 221465)


--- trunk/Source/WebCore/ChangeLog	2017-09-01 01:17:16 UTC (rev 221464)
+++ trunk/Source/WebCore/ChangeLog	2017-09-01 01:46:26 UTC (rev 221465)
@@ -1,3 +1,15 @@
+2017-08-31  Alex Christensen  <achristen...@webkit.org>
+
+        Add ObjC SPI corresponding to WKPageLoaderClient's webGLLoadPolicy and resolveWebGLLoadPolicy
+        https://bugs.webkit.org/show_bug.cgi?id=175779
+        <rdar://problem/22367975>
+
+        Reviewed by Tim Horton.
+
+        Covered by new API tests.
+
+        * loader/FrameLoaderClient.h:
+
 2017-08-31  Andreas Kling  <akl...@apple.com>
 
         Element focus appearance update should be either immediate or a post-layout task

Modified: trunk/Source/WebCore/loader/FrameLoaderClient.h (221464 => 221465)


--- trunk/Source/WebCore/loader/FrameLoaderClient.h	2017-09-01 01:17:16 UTC (rev 221464)
+++ trunk/Source/WebCore/loader/FrameLoaderClient.h	2017-09-01 01:46:26 UTC (rev 221465)
@@ -331,8 +331,8 @@
     // Informs the embedder that a WebGL canvas inside this frame received a lost context
     // notification with the given GL_ARB_robustness guilt/innocence code (see Extensions3D.h).
     virtual void didLoseWebGLContext(int) { }
-    virtual WebGLLoadPolicy webGLPolicyForURL(const String&) const { return WebGLAllowCreation; }
-    virtual WebGLLoadPolicy resolveWebGLPolicyForURL(const String&) const { return WebGLAllowCreation; }
+    virtual WebGLLoadPolicy webGLPolicyForURL(const URL&) const { return WebGLAllowCreation; }
+    virtual WebGLLoadPolicy resolveWebGLPolicyForURL(const URL&) const { return WebGLAllowCreation; }
 #endif
 
     virtual void forcePageTransitionIfNeeded() { }

Modified: trunk/Source/WebKit/ChangeLog (221464 => 221465)


--- trunk/Source/WebKit/ChangeLog	2017-09-01 01:17:16 UTC (rev 221464)
+++ trunk/Source/WebKit/ChangeLog	2017-09-01 01:46:26 UTC (rev 221465)
@@ -1,3 +1,41 @@
+2017-08-31  Alex Christensen  <achristen...@webkit.org>
+
+        Add ObjC SPI corresponding to WKPageLoaderClient's webGLLoadPolicy and resolveWebGLLoadPolicy
+        https://bugs.webkit.org/show_bug.cgi?id=175779
+        <rdar://problem/22367975>
+
+        Reviewed by Tim Horton.
+
+        * UIProcess/API/APINavigationClient.h:
+        (API::NavigationClient::webGLLoadPolicy const):
+        (API::NavigationClient::resolveWebGLLoadPolicy const):
+        * UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h:
+        * UIProcess/Cocoa/NavigationState.h:
+        * UIProcess/Cocoa/NavigationState.mm:
+        (WebKit::NavigationState::setNavigationDelegate):
+        (WebKit::toWebCoreWebGLLoadPolicy):
+        (WebKit::NavigationState::NavigationClient::webGLLoadPolicy const):
+        (WebKit::NavigationState::NavigationClient::resolveWebGLLoadPolicy const):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::webGLPolicyForURL):
+        (WebKit::WebPageProxy::resolveWebGLPolicyForURL):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebKit::WebFrameLoaderClient::webGLPolicyForURL const):
+        (WebKit::WebFrameLoaderClient::resolveWebGLPolicyForURL const):
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::webGLPolicyForURL):
+        (WebKit::WebPage::resolveWebGLPolicyForURL):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::webGLPolicyForURL):
+        (WebKit::WebPage::resolveWebGLPolicyForURL):
+        * WebProcess/WebPage/mac/WebPageMac.mm:
+        (WebKit::WebPage::webGLPolicyForURL):
+        (WebKit::WebPage::resolveWebGLPolicyForURL):
+
 2017-08-31  Brady Eidson  <beid...@apple.com>
 
         Add (entirely incorrect) fetching of ServiceWorker scripts.

Modified: trunk/Source/WebKit/UIProcess/API/APINavigationClient.h (221464 => 221465)


--- trunk/Source/WebKit/UIProcess/API/APINavigationClient.h	2017-09-01 01:17:16 UTC (rev 221464)
+++ trunk/Source/WebKit/UIProcess/API/APINavigationClient.h	2017-09-01 01:46:26 UTC (rev 221465)
@@ -113,6 +113,11 @@
     }
 #endif
 
+#if ENABLE(WEBGL)
+    virtual void webGLLoadPolicy(WebKit::WebPageProxy&, const WebCore::URL&, WTF::Function<void(WebCore::WebGLLoadPolicy)>&& completionHandler) const { completionHandler(WebCore::WebGLLoadPolicy::WebGLAllowCreation); }
+    virtual void resolveWebGLLoadPolicy(WebKit::WebPageProxy&, const WebCore::URL&, WTF::Function<void(WebCore::WebGLLoadPolicy)>&& completionHandler) const { completionHandler(WebCore::WebGLLoadPolicy::WebGLAllowCreation); }
+#endif
+
     virtual void didBeginNavigationGesture(WebKit::WebPageProxy&) { }
     virtual void willEndNavigationGesture(WebKit::WebPageProxy&, bool willNavigate, WebKit::WebBackForwardListItem&) { }
     virtual void didEndNavigationGesture(WebKit::WebPageProxy&, bool willNavigate, WebKit::WebBackForwardListItem&) { }

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h (221464 => 221465)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h	2017-09-01 01:17:16 UTC (rev 221464)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h	2017-09-01 01:46:26 UTC (rev 221465)
@@ -33,6 +33,12 @@
 
 @class _WKWebsitePolicies;
 
+typedef NS_ENUM(NSInteger, _WKWebGLLoadPolicy) {
+    _WKWebGLLoadPolicyBlockCreation,
+    _WKWebGLLoadPolicyAllowCreation,
+    _WKWebGLLoadPolicyPendingCreation,
+} WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+
 static const WKNavigationActionPolicy _WKNavigationActionPolicyDownload = (WKNavigationActionPolicy)(WKNavigationActionPolicyAllow + 1);
 static const WKNavigationActionPolicy WK_API_AVAILABLE(macosx(10.11), ios(9.0)) _WKNavigationActionPolicyAllowWithoutTryingAppLink = (WKNavigationActionPolicy)(WKNavigationActionPolicyAllow + 2);
 
@@ -76,6 +82,9 @@
 - (void)_webViewDidRequestPasswordForQuickLookDocument:(WKWebView *)webView WK_API_AVAILABLE(ios(WK_IOS_TBA));
 #endif
 
+- (void)_webView:(WKWebView *)webView webGLLoadPolicyForURL:(NSURL *)url decisionHandler:(void (^)(_WKWebGLLoadPolicy))decisionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+- (void)_webView:(WKWebView *)webView resolveWebGLLoadPolicyForURL:(NSURL *)url decisionHandler:(void (^)(_WKWebGLLoadPolicy))decisionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+
 @end
 
 #endif

Modified: trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.h (221464 => 221465)


--- trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.h	2017-09-01 01:17:16 UTC (rev 221464)
+++ trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.h	2017-09-01 01:46:26 UTC (rev 221465)
@@ -116,6 +116,11 @@
         void didFinishLoadForQuickLookDocumentInMainFrame(const QuickLookDocumentData&) override;
 #endif
 
+#if ENABLE(WEBGL)
+        void webGLLoadPolicy(WebPageProxy&, const WebCore::URL&, WTF::Function<void(WebCore::WebGLLoadPolicy)>&& completionHandler) const final;
+        void resolveWebGLLoadPolicy(WebPageProxy&, const WebCore::URL&, WTF::Function<void(WebCore::WebGLLoadPolicy)>&& completionHandler) const final;
+#endif
+
         void decidePolicyForNavigationAction(WebPageProxy&, Ref<API::NavigationAction>&&, Ref<WebFramePolicyListenerProxy>&&, API::Object* userData) override;
         void decidePolicyForNavigationResponse(WebPageProxy&, API::NavigationResponse&, Ref<WebFramePolicyListenerProxy>&&, API::Object* userData) override;
 
@@ -201,6 +206,11 @@
         bool webViewDidFinishLoadForQuickLookDocumentInMainFrame : 1;
         bool webViewDidRequestPasswordForQuickLookDocument : 1;
 #endif
+
+#if ENABLE(WEBGL)
+        bool webViewWebGLLoadPolicyForURL : 1;
+        bool webViewResolveWebGLLoadPolicyForURL : 1;
+#endif
     } m_navigationDelegateMethods;
 
     WeakObjCPtr<id <WKHistoryDelegatePrivate> > m_historyDelegate;

Modified: trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm (221464 => 221465)


--- trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm	2017-09-01 01:17:16 UTC (rev 221464)
+++ trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm	2017-09-01 01:46:26 UTC (rev 221465)
@@ -173,6 +173,10 @@
     m_navigationDelegateMethods.webViewDidFinishLoadForQuickLookDocumentInMainFrame = [delegate respondsToSelector:@selector(_webView:didFinishLoadForQuickLookDocumentInMainFrame:)];
     m_navigationDelegateMethods.webViewDidRequestPasswordForQuickLookDocument = [delegate respondsToSelector:@selector(_webViewDidRequestPasswordForQuickLookDocument:)];
 #endif
+#if ENABLE(WEBGL)
+    m_navigationDelegateMethods.webViewWebGLLoadPolicyForURL = [delegate respondsToSelector:@selector(_webView:webGLLoadPolicyForURL:decisionHandler:)];
+    m_navigationDelegateMethods.webViewResolveWebGLLoadPolicyForURL = [delegate respondsToSelector:@selector(_webView:resolveWebGLLoadPolicyForURL:decisionHandler:)];
+#endif
 }
 
 RetainPtr<id <WKHistoryDelegatePrivate> > NavigationState::historyDelegate()
@@ -285,6 +289,51 @@
 {
 }
 
+inline WebCore::WebGLLoadPolicy toWebCoreWebGLLoadPolicy(_WKWebGLLoadPolicy policy)
+{
+    switch (policy) {
+    case _WKWebGLLoadPolicyAllowCreation:
+        return WebCore::WebGLAllowCreation;
+    case _WKWebGLLoadPolicyBlockCreation:
+        return WebCore::WebGLBlockCreation;
+    case _WKWebGLLoadPolicyPendingCreation:
+        return WebCore::WebGLPendingCreation;
+    }
+    
+    ASSERT_NOT_REACHED();
+    return WebCore::WebGLAllowCreation;
+}
+
+void NavigationState::NavigationClient::webGLLoadPolicy(WebPageProxy&, const WebCore::URL& url, WTF::Function<void(WebCore::WebGLLoadPolicy)>&& completionHandler) const
+{
+    if (!m_navigationState.m_navigationDelegateMethods.webViewWebGLLoadPolicyForURL)
+        completionHandler(WebGLAllowCreation);
+
+    auto navigationDelegate = m_navigationState.m_navigationDelegate.get();
+    Ref<CompletionHandlerCallChecker> checker = CompletionHandlerCallChecker::create(navigationDelegate.get(), @selector(_webView:webGLLoadPolicyForURL:decisionHandler:));
+    [(id <WKNavigationDelegatePrivate>)navigationDelegate _webView:m_navigationState.m_webView webGLLoadPolicyForURL:(NSURL *)url decisionHandler:BlockPtr<void(_WKWebGLLoadPolicy)>::fromCallable([completionHandler = WTFMove(completionHandler), checker = WTFMove(checker)](_WKWebGLLoadPolicy policy) {
+        if (checker->completionHandlerHasBeenCalled())
+            return;
+        checker->didCallCompletionHandler();
+        completionHandler(toWebCoreWebGLLoadPolicy(policy));
+    }).get()];
+}
+
+void NavigationState::NavigationClient::resolveWebGLLoadPolicy(WebPageProxy&, const WebCore::URL& url, WTF::Function<void(WebCore::WebGLLoadPolicy)>&& completionHandler) const
+{
+    if (!m_navigationState.m_navigationDelegateMethods.webViewResolveWebGLLoadPolicyForURL)
+        completionHandler(WebGLAllowCreation);
+    
+    auto navigationDelegate = m_navigationState.m_navigationDelegate.get();
+    Ref<CompletionHandlerCallChecker> checker = CompletionHandlerCallChecker::create(navigationDelegate.get(), @selector(_webView:resolveWebGLLoadPolicyForURL:decisionHandler:));
+    [(id <WKNavigationDelegatePrivate>)navigationDelegate _webView:m_navigationState.m_webView resolveWebGLLoadPolicyForURL:(NSURL *)url decisionHandler:BlockPtr<void(_WKWebGLLoadPolicy)>::fromCallable([completionHandler = WTFMove(completionHandler), checker = WTFMove(checker)](_WKWebGLLoadPolicy policy) {
+        if (checker->completionHandlerHasBeenCalled())
+            return;
+        checker->didCallCompletionHandler();
+        completionHandler(toWebCoreWebGLLoadPolicy(policy));
+    }).get()];
+}
+
 static void tryAppLink(RefPtr<API::NavigationAction>&& navigationAction, const String& currentMainFrameURL, WTF::Function<void(bool)>&& completionHandler)
 {
 #if HAVE(APP_LINKS)

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (221464 => 221465)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2017-09-01 01:17:16 UTC (rev 221464)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2017-09-01 01:46:26 UTC (rev 221465)
@@ -4040,14 +4040,24 @@
 #endif // ENABLE(NETSCAPE_PLUGIN_API)
 
 #if ENABLE(WEBGL)
-void WebPageProxy::webGLPolicyForURL(const String& url, uint32_t& loadPolicy)
+void WebPageProxy::webGLPolicyForURL(URL&& url, Ref<Messages::WebPageProxy::WebGLPolicyForURL::DelayedReply>&& reply)
 {
-    loadPolicy = static_cast<uint32_t>(m_loaderClient->webGLLoadPolicy(*this, url));
+    if (m_navigationClient) {
+        m_navigationClient->webGLLoadPolicy(*this, url, [reply = WTFMove(reply)](WebGLLoadPolicy policy) {
+            reply->send(static_cast<uint32_t>(policy));
+        });
+    } else
+        reply->send(static_cast<uint32_t>(m_loaderClient->webGLLoadPolicy(*this, url)));
 }
 
-void WebPageProxy::resolveWebGLPolicyForURL(const String& url, uint32_t& loadPolicy)
+void WebPageProxy::resolveWebGLPolicyForURL(URL&& url, Ref<Messages::WebPageProxy::ResolveWebGLPolicyForURL::DelayedReply>&& reply)
 {
-    loadPolicy = static_cast<uint32_t>(m_loaderClient->resolveWebGLLoadPolicy(*this, url));
+    if (m_navigationClient) {
+        m_navigationClient->resolveWebGLLoadPolicy(*this, url, [reply = WTFMove(reply)](WebGLLoadPolicy policy) {
+            reply->send(static_cast<uint32_t>(policy));
+        });
+    } else
+        reply->send(static_cast<uint32_t>(m_loaderClient->resolveWebGLLoadPolicy(*this, url)));
 }
 #endif // ENABLE(WEBGL)
 

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (221464 => 221465)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2017-09-01 01:17:16 UTC (rev 221464)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2017-09-01 01:46:26 UTC (rev 221465)
@@ -1302,8 +1302,8 @@
     void unavailablePluginButtonClicked(uint32_t opaquePluginUnavailabilityReason, const String& mimeType, const String& pluginURLString, const String& pluginsPageURLString, const String& frameURLString, const String& pageURLString);
 #endif // ENABLE(NETSCAPE_PLUGIN_API)
 #if ENABLE(WEBGL)
-    void webGLPolicyForURL(const String& url, uint32_t& loadPolicy);
-    void resolveWebGLPolicyForURL(const String& url, uint32_t& loadPolicy);
+    void webGLPolicyForURL(WebCore::URL&&, Ref<Messages::WebPageProxy::WebGLPolicyForURL::DelayedReply>&&);
+    void resolveWebGLPolicyForURL(WebCore::URL&&, Ref<Messages::WebPageProxy::ResolveWebGLPolicyForURL::DelayedReply>&&);
 #endif // ENABLE(WEBGL)
     void setToolbarsAreVisible(bool toolbarsAreVisible);
     void getToolbarsAreVisible(bool& toolbarsAreVisible);

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (221464 => 221465)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in	2017-09-01 01:17:16 UTC (rev 221464)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in	2017-09-01 01:46:26 UTC (rev 221465)
@@ -34,8 +34,8 @@
     UnavailablePluginButtonClicked(uint32_t pluginUnavailabilityReason, String mimeType, String pluginURLString, String pluginspageAttributeURLString, String frameURLString, String pageURLString)
 #endif // ENABLE(NETSCAPE_PLUGIN_API)
 #if ENABLE(WEBGL)
-    WebGLPolicyForURL(String url) -> (uint32_t loadPolicy)
-    ResolveWebGLPolicyForURL(String url) -> (uint32_t loadPolicy)
+    WebGLPolicyForURL(WebCore::URL url) -> (uint32_t loadPolicy) Delayed
+    ResolveWebGLPolicyForURL(WebCore::URL url) -> (uint32_t loadPolicy) Delayed
 #endif // ENABLE(WEBGL)
     DidChangeViewportProperties(struct WebCore::ViewportAttributes attributes)
     DidReceiveEvent(uint32_t type, bool handled)

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp (221464 => 221465)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp	2017-09-01 01:17:16 UTC (rev 221464)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp	2017-09-01 01:46:26 UTC (rev 221465)
@@ -1517,7 +1517,7 @@
 
 #if ENABLE(WEBGL)
 
-WebCore::WebGLLoadPolicy WebFrameLoaderClient::webGLPolicyForURL(const String& url) const
+WebCore::WebGLLoadPolicy WebFrameLoaderClient::webGLPolicyForURL(const URL& url) const
 {
     if (auto* webPage = m_frame->page())
         return webPage->webGLPolicyForURL(m_frame, url);
@@ -1525,7 +1525,7 @@
     return WebGLAllowCreation;
 }
 
-WebCore::WebGLLoadPolicy WebFrameLoaderClient::resolveWebGLPolicyForURL(const String& url) const
+WebCore::WebGLLoadPolicy WebFrameLoaderClient::resolveWebGLPolicyForURL(const URL& url) const
 {
     if (auto* webPage = m_frame->page())
         return webPage->resolveWebGLPolicyForURL(m_frame, url);

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h (221464 => 221465)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h	2017-09-01 01:17:16 UTC (rev 221464)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h	2017-09-01 01:46:26 UTC (rev 221465)
@@ -204,8 +204,8 @@
     void redirectDataToPlugin(WebCore::Widget&) final;
     
 #if ENABLE(WEBGL)
-    WebCore::WebGLLoadPolicy webGLPolicyForURL(const String&) const final;
-    WebCore::WebGLLoadPolicy resolveWebGLPolicyForURL(const String&) const final;
+    WebCore::WebGLLoadPolicy webGLPolicyForURL(const WebCore::URL&) const final;
+    WebCore::WebGLLoadPolicy resolveWebGLPolicyForURL(const WebCore::URL&) const final;
 #endif // ENABLE(WEBGL)
 
     RefPtr<WebCore::Widget> createJavaAppletWidget(const WebCore::IntSize&, WebCore::HTMLAppletElement&, const WebCore::URL& baseURL, const Vector<String>& paramNames, const Vector<String>& paramValues) final;

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (221464 => 221465)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2017-09-01 01:17:16 UTC (rev 221464)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2017-09-01 01:46:26 UTC (rev 221465)
@@ -819,12 +819,12 @@
 #endif // ENABLE(NETSCAPE_PLUGIN_API)
 
 #if ENABLE(WEBGL) && !PLATFORM(COCOA)
-WebCore::WebGLLoadPolicy WebPage::webGLPolicyForURL(WebFrame*, const String& /* url */)
+WebCore::WebGLLoadPolicy WebPage::webGLPolicyForURL(WebFrame*, const URL&)
 {
     return WebGLAllowCreation;
 }
 
-WebCore::WebGLLoadPolicy WebPage::resolveWebGLPolicyForURL(WebFrame*, const String& /* url */)
+WebCore::WebGLLoadPolicy WebPage::resolveWebGLPolicyForURL(WebFrame*, const URL&)
 {
     return WebGLAllowCreation;
 }

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (221464 => 221465)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2017-09-01 01:17:16 UTC (rev 221464)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2017-09-01 01:46:26 UTC (rev 221465)
@@ -367,8 +367,8 @@
 #endif
 
 #if ENABLE(WEBGL)
-    WebCore::WebGLLoadPolicy webGLPolicyForURL(WebFrame*, const String&);
-    WebCore::WebGLLoadPolicy resolveWebGLPolicyForURL(WebFrame*, const String&);
+    WebCore::WebGLLoadPolicy webGLPolicyForURL(WebFrame*, const WebCore::URL&);
+    WebCore::WebGLLoadPolicy resolveWebGLPolicyForURL(WebFrame*, const WebCore::URL&);
 #endif
     
     enum class IncludePostLayoutDataHint { No, Yes };

Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (221464 => 221465)


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2017-09-01 01:17:16 UTC (rev 221464)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2017-09-01 01:46:26 UTC (rev 221465)
@@ -3284,12 +3284,12 @@
 }
 
 #if ENABLE(WEBGL)
-WebCore::WebGLLoadPolicy WebPage::webGLPolicyForURL(WebFrame*, const String&)
+WebCore::WebGLLoadPolicy WebPage::webGLPolicyForURL(WebFrame*, const URL&)
 {
     return WebGLAllowCreation;
 }
 
-WebCore::WebGLLoadPolicy WebPage::resolveWebGLPolicyForURL(WebFrame*, const String&)
+WebCore::WebGLLoadPolicy WebPage::resolveWebGLPolicyForURL(WebFrame*, const URL&)
 {
     return WebGLAllowCreation;
 }

Modified: trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm (221464 => 221465)


--- trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm	2017-09-01 01:17:16 UTC (rev 221464)
+++ trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm	2017-09-01 01:46:26 UTC (rev 221465)
@@ -924,7 +924,7 @@
 }
 
 #if ENABLE(WEBGL)
-WebCore::WebGLLoadPolicy WebPage::webGLPolicyForURL(WebFrame* frame, const String& url)
+WebCore::WebGLLoadPolicy WebPage::webGLPolicyForURL(WebFrame* frame, const URL& url)
 {
     uint32_t policyResult = 0;
 
@@ -934,7 +934,7 @@
     return WebGLAllowCreation;
 }
 
-WebCore::WebGLLoadPolicy WebPage::resolveWebGLPolicyForURL(WebFrame* frame, const String& url)
+WebCore::WebGLLoadPolicy WebPage::resolveWebGLPolicyForURL(WebFrame* frame, const URL& url)
 {
     uint32_t policyResult = 0;
 

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (221464 => 221465)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2017-09-01 01:17:16 UTC (rev 221464)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2017-09-01 01:46:26 UTC (rev 221465)
@@ -1,3 +1,16 @@
+2017-08-31  Alex Christensen  <achristen...@webkit.org>
+
+        Add ObjC SPI corresponding to WKPageLoaderClient's webGLLoadPolicy and resolveWebGLLoadPolicy
+        https://bugs.webkit.org/show_bug.cgi?id=175779
+        <rdar://problem/22367975>
+
+        Reviewed by Tim Horton.
+
+        * WebCoreSupport/WebFrameLoaderClient.h:
+        * WebCoreSupport/WebFrameLoaderClient.mm:
+        (WebFrameLoaderClient::webGLPolicyForURL const):
+        (WebFrameLoaderClient::resolveWebGLPolicyForURL const):
+
 2017-08-30  Andy Estes  <aes...@apple.com>
 
         [Mac] Upstream Accessibility-related WebKitSystemInterface functions

Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.h (221464 => 221465)


--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.h	2017-09-01 01:17:16 UTC (rev 221464)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.h	2017-09-01 01:46:26 UTC (rev 221465)
@@ -211,8 +211,8 @@
     void redirectDataToPlugin(WebCore::Widget&) final;
 
 #if ENABLE(WEBGL)
-    WebCore::WebGLLoadPolicy webGLPolicyForURL(const String&) const final;
-    WebCore::WebGLLoadPolicy resolveWebGLPolicyForURL(const String&) const final;
+    WebCore::WebGLLoadPolicy webGLPolicyForURL(const WebCore::URL&) const final;
+    WebCore::WebGLLoadPolicy resolveWebGLPolicyForURL(const WebCore::URL&) const final;
 #endif
 
     RefPtr<WebCore::Widget> createJavaAppletWidget(const WebCore::IntSize&, WebCore::HTMLAppletElement&, const WebCore::URL& baseURL,

Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm (221464 => 221465)


--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm	2017-09-01 01:17:16 UTC (rev 221464)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm	2017-09-01 01:46:26 UTC (rev 221465)
@@ -2146,12 +2146,12 @@
 #endif
 }
 
-WebCore::WebGLLoadPolicy WebFrameLoaderClient::webGLPolicyForURL(const String&) const
+WebCore::WebGLLoadPolicy WebFrameLoaderClient::webGLPolicyForURL(const URL&) const
 {
     return shouldBlockWebGL() ? WebGLBlockCreation : WebGLAllowCreation;
 }
 
-WebCore::WebGLLoadPolicy WebFrameLoaderClient::resolveWebGLPolicyForURL(const String&) const
+WebCore::WebGLLoadPolicy WebFrameLoaderClient::resolveWebGLPolicyForURL(const URL&) const
 {
     return shouldBlockWebGL() ? WebGLBlockCreation : WebGLAllowCreation;
 }

Modified: trunk/Tools/ChangeLog (221464 => 221465)


--- trunk/Tools/ChangeLog	2017-09-01 01:17:16 UTC (rev 221464)
+++ trunk/Tools/ChangeLog	2017-09-01 01:46:26 UTC (rev 221465)
@@ -1,3 +1,22 @@
+2017-08-31  Alex Christensen  <achristen...@webkit.org>
+
+        Add ObjC SPI corresponding to WKPageLoaderClient's webGLLoadPolicy and resolveWebGLLoadPolicy
+        https://bugs.webkit.org/show_bug.cgi?id=175779
+        <rdar://problem/22367975>
+
+        Reviewed by Tim Horton.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKitCocoa/WebGLPolicy.mm: Added.
+        (-[WebGLTestDelegate webView:startURLSchemeTask:]):
+        (-[WebGLTestDelegate webView:stopURLSchemeTask:]):
+        (-[WebGLTestDelegate _webView:webGLLoadPolicyForURL:decisionHandler:]):
+        (-[WebGLTestDelegate _webView:resolveWebGLLoadPolicyForURL:decisionHandler:]):
+        (-[WebGLTestDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]):
+        (urlsEqual):
+        (runTest):
+        (TEST):
+
 2017-08-31  Don Olmstead  <don.olmst...@sony.com>
 
         [CMake] Make USE_CF conditional within Windows

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (221464 => 221465)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2017-09-01 01:17:16 UTC (rev 221464)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2017-09-01 01:46:26 UTC (rev 221465)
@@ -229,6 +229,7 @@
 		5C726D6F1D3EE06E00C5E1A1 /* InstanceMethodSwizzler.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C726D6E1D3EE06800C5E1A1 /* InstanceMethodSwizzler.mm */; };
 		5C7964101EB0278D0075D74C /* EventModifiers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C79640F1EB0269B0075D74C /* EventModifiers.cpp */; };
 		5C838F7F1DB04F900082858F /* LoadInvalidURLRequest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 57901FAE1CAF137100ED64F9 /* LoadInvalidURLRequest.mm */; };
+		5C973F5C1F58EF8B00359C27 /* WebGLPolicy.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C973F5B1F58EF0A00359C27 /* WebGLPolicy.mm */; };
 		5C9E56851DF9145400C9EE33 /* WebsitePolicies.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C9E56841DF9143D00C9EE33 /* WebsitePolicies.mm */; };
 		5C9E56871DF914AE00C9EE33 /* contentBlockerCheck.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5C9E56861DF9148E00C9EE33 /* contentBlockerCheck.html */; };
 		5C9E59411D3EB5AC00E3C62E /* ApplicationCache.db in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5C9E593E1D3EB1DE00E3C62E /* ApplicationCache.db */; };
@@ -1308,6 +1309,7 @@
 		5C726D6D1D3EE06800C5E1A1 /* InstanceMethodSwizzler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = InstanceMethodSwizzler.h; path = cocoa/InstanceMethodSwizzler.h; sourceTree = "<group>"; };
 		5C726D6E1D3EE06800C5E1A1 /* InstanceMethodSwizzler.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = InstanceMethodSwizzler.mm; path = cocoa/InstanceMethodSwizzler.mm; sourceTree = "<group>"; };
 		5C79640F1EB0269B0075D74C /* EventModifiers.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventModifiers.cpp; sourceTree = "<group>"; };
+		5C973F5B1F58EF0A00359C27 /* WebGLPolicy.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebGLPolicy.mm; sourceTree = "<group>"; };
 		5C9E56841DF9143D00C9EE33 /* WebsitePolicies.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebsitePolicies.mm; sourceTree = "<group>"; };
 		5C9E56861DF9148E00C9EE33 /* contentBlockerCheck.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = contentBlockerCheck.html; sourceTree = "<group>"; };
 		5C9E593E1D3EB1DE00E3C62E /* ApplicationCache.db */ = {isa = PBXFileReference; lastKnownFileType = file; path = ApplicationCache.db; sourceTree = "<group>"; };
@@ -1970,6 +1972,7 @@
 				07EDEFAC1EB9400C00D43292 /* UserMediaDisabled.mm */,
 				93E943F11CD3E87E00AC08C2 /* VideoControlsManager.mm */,
 				6356FB211EC4E0BA0044BF18 /* VisibleContentRect.mm */,
+				5C973F5B1F58EF0A00359C27 /* WebGLPolicy.mm */,
 				51714EB61CF8C7A4004723C4 /* WebProcessKillIDBCleanup.mm */,
 				5120C83C1E6750790025B250 /* WebsiteDataStoreCustomPaths.mm */,
 				5C9E56841DF9143D00C9EE33 /* WebsitePolicies.mm */,
@@ -3359,6 +3362,7 @@
 				7CCE7F191A411AE600447C4C /* WebArchive.cpp in Sources */,
 				7C83E04C1D0A641800FEBCF3 /* WebCoreNSURLSession.mm in Sources */,
 				7CCE7F1A1A411AE600447C4C /* WebCoreStatisticsWithNoWebProcess.cpp in Sources */,
+				5C973F5C1F58EF8B00359C27 /* WebGLPolicy.mm in Sources */,
 				7CCE7EAB1A411A2400447C4C /* WebKitAgnosticTest.mm in Sources */,
 				51714EB81CF8CA17004723C4 /* WebProcessKillIDBCleanup.mm in Sources */,
 				536770341CC8022800D425B1 /* WebScriptObjectDescription.mm in Sources */,

Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebGLPolicy.mm (0 => 221465)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebGLPolicy.mm	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebGLPolicy.mm	2017-09-01 01:46:26 UTC (rev 221465)
@@ -0,0 +1,143 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+
+#if WK_API_ENABLED
+
+#import "TestWKWebView.h"
+#import "Utilities.h"
+#import <WebKit/WKNavigationDelegatePrivate.h>
+#import <WebKit/WKWebView.h>
+#import <wtf/RetainPtr.h>
+
+static _WKWebGLLoadPolicy firstPolicy;
+static _WKWebGLLoadPolicy secondPolicy;
+
+static RetainPtr<NSURL> firstURL;
+static RetainPtr<NSURL> secondURL;
+static RetainPtr<NSString> alert;
+
+static bool testComplete { false };
+static RetainPtr<NSURL> htmlURL;
+
+@interface WebGLTestDelegate : NSObject <WKNavigationDelegatePrivate, WKUIDelegate, WKURLSchemeHandler>
+@end
+    
+@implementation WebGLTestDelegate
+
+- (void)webView:(WKWebView *)webView startURLSchemeTask:(id <WKURLSchemeTask>)urlSchemeTask
+{
+    NSString *data = ""
+        "var canvas = document.createElement('canvas');"
+        "var context = canvas.getContext('webgl');"
+        "if (context) {"
+            "var framebuffer = context.createFramebuffer();"
+            "var status = context.checkFramebufferStatus(context.FRAMEBUFFER);"
+            "if (status == context.FRAMEBUFFER_UNSUPPORTED)"
+                "alert('doing stuff with webgl context failed');"
+            "else if (status == context.FRAMEBUFFER_COMPLETE)"
+                "alert('doing stuff with webgl context succeeded');"
+            "else alert('unexpected status');"
+        "} else alert('webgl context creation failed');"
+    "</script>";
+    [urlSchemeTask didReceiveResponse:[[[NSURLResponse alloc] initWithURL:urlSchemeTask.request.URL MIMEType:@"text/html" expectedContentLength:data.length textEncodingName:nil] autorelease]];
+    [urlSchemeTask didReceiveData:[data dataUsingEncoding:NSUTF8StringEncoding]];
+    [urlSchemeTask didFinish];
+}
+
+- (void)webView:(WKWebView *)webView stopURLSchemeTask:(id <WKURLSchemeTask>)urlSchemeTask
+{
+}
+
+- (void)_webView:(WKWebView *)webView webGLLoadPolicyForURL:(NSURL *)url decisionHandler:(void (^)(_WKWebGLLoadPolicy))decisionHandler
+{
+    ASSERT(!firstURL);
+    firstURL = url;
+    decisionHandler(firstPolicy);
+}
+
+- (void)_webView:(WKWebView *)webView resolveWebGLLoadPolicyForURL:(NSURL *)url decisionHandler:(void (^)(_WKWebGLLoadPolicy))decisionHandler
+{
+    ASSERT(!secondURL);
+    secondURL = url;
+    decisionHandler(secondPolicy);
+}
+
+- (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler
+{
+    alert = message;
+    testComplete = true;
+    completionHandler();
+}
+
+@end
+
+static void runTest(_WKWebGLLoadPolicy first, _WKWebGLLoadPolicy second = _WKWebGLLoadPolicyBlockCreation)
+{
+    testComplete = false;
+    alert = nil;
+    firstURL = nil;
+    secondURL = nil;
+    firstPolicy = first;
+    secondPolicy = second;
+    
+    auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    auto delegate = adoptNS([[WebGLTestDelegate alloc] init]);
+    [configuration setURLSchemeHandler:delegate.get() forURLScheme:@"test"];
+    auto webView = adoptNS([[WKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600) configuration:configuration.get()]);
+    [webView setNavigationDelegate:delegate.get()];
+    [webView setUIDelegate:delegate.get()];
+    [webView loadRequest:[NSURLRequest requestWithURL:htmlURL.get()]];
+    TestWebKitAPI::Util::run(&testComplete);
+}
+
+TEST(WebKit2, WebGLPolicy)
+{
+    htmlURL = [NSURL URLWithString:@"test:///html"];
+    
+    runTest(_WKWebGLLoadPolicyBlockCreation);
+    EXPECT_STREQ([alert UTF8String], "webgl context creation failed");
+    EXPECT_TRUE([htmlURL isEqual:firstURL.get()]);
+    EXPECT_TRUE(nullptr == secondURL);
+
+    runTest(_WKWebGLLoadPolicyAllowCreation);
+    EXPECT_STREQ([alert UTF8String], "doing stuff with webgl context succeeded");
+    EXPECT_TRUE([htmlURL isEqual:firstURL.get()]);
+    EXPECT_TRUE(nullptr == secondURL);
+
+    runTest(_WKWebGLLoadPolicyPendingCreation, _WKWebGLLoadPolicyBlockCreation);
+    EXPECT_STREQ([alert UTF8String], "doing stuff with webgl context failed");
+    EXPECT_TRUE([htmlURL isEqual:firstURL.get()]);
+    EXPECT_TRUE([htmlURL isEqual:secondURL.get()]);
+
+    runTest(_WKWebGLLoadPolicyPendingCreation, _WKWebGLLoadPolicyAllowCreation);
+    // FIXME: This ought to succeed. https://bugs.webkit.org/show_bug.cgi?id=129122
+    EXPECT_STREQ([alert UTF8String], "doing stuff with webgl context failed");
+    EXPECT_TRUE([htmlURL isEqual:firstURL.get()]);
+    EXPECT_TRUE([htmlURL isEqual:secondURL.get()]);
+}
+
+#endif // WK_API_ENABLED
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to