Diff
Modified: trunk/Source/WebKit2/ChangeLog (188256 => 188257)
--- trunk/Source/WebKit2/ChangeLog 2015-08-11 16:45:47 UTC (rev 188256)
+++ trunk/Source/WebKit2/ChangeLog 2015-08-11 16:51:14 UTC (rev 188257)
@@ -1,5 +1,38 @@
2015-08-11 Dan Bernstein <[email protected]>
+ Reverted r188255, because it turned out that delegates do nonot need this information.
+
+ * UIProcess/API/APIUIClient.h:
+ (API::UIClient::footerHeight):
+ (API::UIClient::drawHeader):
+ (API::UIClient::drawFooter):
+ (API::UIClient::printFrame):
+ (API::UIClient::canRunModal):
+ (API::UIClient::runModal):
+ * UIProcess/API/C/WKPage.cpp:
+ (WKPageSetPageUIClient):
+ * UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
+ * UIProcess/Cocoa/UIDelegate.h:
+ * UIProcess/Cocoa/UIDelegate.mm:
+ (WebKit::UIDelegate::UIDelegate):
+ (WebKit::UIDelegate::setDelegate):
+ (WebKit::UIDelegate::UIClient::reachedApplicationCacheOriginQuota):
+ (WebKit::UIDelegate::UIClient::printFrame):
+ (WebKit::UIDelegate::UIClient::close):
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::runOpenPanel):
+ (WebKit::WebPageProxy::printFrame):
+ (WebKit::WebPageProxy::printMainFrame):
+ (WebKit::WebPageProxy::setMediaVolume):
+ * UIProcess/WebPageProxy.h:
+ (WebKit::WebPageProxy::setShouldSendEventsSynchronously):
+ * UIProcess/WebPageProxy.messages.in:
+ * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+ (WebKit::WebChromeClient::print):
+ (WebKit::WebChromeClient::exceededDatabaseQuota):
+
+2015-08-11 Dan Bernstein <[email protected]>
+
[Cocoa] The UI delegate can't tell if printing was user-initiated
https://bugs.webkit.org/show_bug.cgi?id=147869
Modified: trunk/Source/WebKit2/UIProcess/API/APIUIClient.h (188256 => 188257)
--- trunk/Source/WebKit2/UIProcess/API/APIUIClient.h 2015-08-11 16:45:47 UTC (rev 188256)
+++ trunk/Source/WebKit2/UIProcess/API/APIUIClient.h 2015-08-11 16:51:14 UTC (rev 188257)
@@ -139,7 +139,7 @@
virtual float footerHeight(WebKit::WebPageProxy*, WebKit::WebFrameProxy*) { return 0; }
virtual void drawHeader(WebKit::WebPageProxy*, WebKit::WebFrameProxy*, const WebCore::FloatRect&) { }
virtual void drawFooter(WebKit::WebPageProxy*, WebKit::WebFrameProxy*, const WebCore::FloatRect&) { }
- virtual void printFrame(WebKit::WebPageProxy*, WebKit::WebFrameProxy*, bool processingUserGesture) { }
+ virtual void printFrame(WebKit::WebPageProxy*, WebKit::WebFrameProxy*) { }
virtual bool canRunModal() const { return false; }
virtual void runModal(WebKit::WebPageProxy*) { }
Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp (188256 => 188257)
--- trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp 2015-08-11 16:45:47 UTC (rev 188256)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp 2015-08-11 16:51:14 UTC (rev 188257)
@@ -1730,7 +1730,7 @@
m_client.drawFooter(toAPI(page), toAPI(frame), toAPI(rect), m_client.base.clientInfo);
}
- virtual void printFrame(WebPageProxy* page, WebFrameProxy* frame, bool) override
+ virtual void printFrame(WebPageProxy* page, WebFrameProxy* frame) override
{
if (!m_client.printFrame)
return;
Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h (188256 => 188257)
--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h 2015-08-11 16:45:47 UTC (rev 188256)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h 2015-08-11 16:51:14 UTC (rev 188257)
@@ -48,7 +48,7 @@
// FIXME: This should be handled by the WKWebsiteDataStore delegate.
- (void)_webView:(WKWebView *)webView decideWebApplicationCacheQuotaForSecurityOrigin:(WKSecurityOrigin *)securityOrigin currentQuota:(unsigned long long)currentQuota totalBytesNeeded:(unsigned long long)totalBytesNeeded decisionHandler:(void (^)(unsigned long long newQuota))decisionHandler;
-- (void)_webView:(WKWebView *)webView printFrame:(_WKFrameHandle *)frame userInitiated:(BOOL)userInitiated WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
+- (void)_webView:(WKWebView *)webView printFrame:(_WKFrameHandle *)frame;
- (void)_webViewClose:(WKWebView *)webView;
- (void)_webViewFullscreenMayReturnToInline:(WKWebView *)webView;
Modified: trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.h (188256 => 188257)
--- trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.h 2015-08-11 16:45:47 UTC (rev 188256)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.h 2015-08-11 16:51:14 UTC (rev 188257)
@@ -68,7 +68,7 @@
virtual void runJavaScriptPrompt(WebKit::WebPageProxy*, const WTF::String&, const WTF::String&, WebKit::WebFrameProxy*, const WebKit::SecurityOriginData&, std::function<void (const WTF::String&)> completionHandler) override;
virtual void exceededDatabaseQuota(WebPageProxy*, WebFrameProxy*, API::SecurityOrigin*, const WTF::String& databaseName, const WTF::String& displayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentUsage, unsigned long long expectedUsage, std::function<void (unsigned long long)>) override;
virtual void reachedApplicationCacheOriginQuota(WebPageProxy*, const WebCore::SecurityOrigin&, uint64_t currentQuota, uint64_t totalBytesNeeded, std::function<void (unsigned long long)> completionHandler) override;
- virtual void printFrame(WebKit::WebPageProxy*, WebKit::WebFrameProxy*, bool processingUserGesture) override;
+ virtual void printFrame(WebKit::WebPageProxy*, WebKit::WebFrameProxy*) override;
#if PLATFORM(IOS)
#if HAVE(APP_LINKS)
virtual bool shouldIncludeAppLinkActionsForElement(_WKActivatedElementInfo *) override;
@@ -94,7 +94,6 @@
bool webViewDecideDatabaseQuotaForSecurityOriginCurrentQuotaCurrentOriginUsageCurrentDatabaseUsageExpectedUsageDecisionHandler : 1;
bool webViewDecideWebApplicationCacheQuotaForSecurityOriginCurrentQuotaTotalBytesNeeded : 1;
bool webViewPrintFrame : 1;
- bool webViewPrintFrameUserInitiated : 1;
bool webViewDidClose : 1;
bool webViewClose : 1;
bool webViewFullscreenMayReturnToInline : 1;
Modified: trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm (188256 => 188257)
--- trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm 2015-08-11 16:45:47 UTC (rev 188256)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm 2015-08-11 16:51:14 UTC (rev 188257)
@@ -41,11 +41,6 @@
#import "_WKFrameHandleInternal.h"
#import <WebCore/URL.h>
-@protocol WKUIDelegatePrivateDeprecated <WKUIDelegatePrivate>
-@optional
-- (void)_webView:(WKWebView *)webView printFrame:(_WKFrameHandle *)frame;
-@end
-
namespace WebKit {
UIDelegate::UIDelegate(WKWebView *webView)
@@ -78,7 +73,6 @@
m_delegateMethods.webViewDecideDatabaseQuotaForSecurityOriginCurrentQuotaCurrentOriginUsageCurrentDatabaseUsageExpectedUsageDecisionHandler = [delegate respondsToSelector:@selector(_webView:decideDatabaseQuotaForSecurityOrigin:currentQuota:currentOriginUsage:currentDatabaseUsage:expectedUsage:decisionHandler:)];
m_delegateMethods.webViewDecideWebApplicationCacheQuotaForSecurityOriginCurrentQuotaTotalBytesNeeded = [delegate respondsToSelector:@selector(_webView:decideWebApplicationCacheQuotaForSecurityOrigin:currentQuota:totalBytesNeeded:decisionHandler:)];
m_delegateMethods.webViewPrintFrame = [delegate respondsToSelector:@selector(_webView:printFrame:)];
- m_delegateMethods.webViewPrintFrameUserInitiated = [delegate respondsToSelector:@selector(_webView:printFrame:userInitiated:)];
m_delegateMethods.webViewDidClose = [delegate respondsToSelector:@selector(webViewDidClose:)];
m_delegateMethods.webViewClose = [delegate respondsToSelector:@selector(_webViewClose:)];
m_delegateMethods.webViewFullscreenMayReturnToInline = [delegate respondsToSelector:@selector(_webViewFullscreenMayReturnToInline:)];
@@ -236,21 +230,18 @@
}];
}
-void UIDelegate::UIClient::printFrame(WebKit::WebPageProxy*, WebKit::WebFrameProxy* webFrameProxy, bool processingUserGesture)
+void UIDelegate::UIClient::printFrame(WebKit::WebPageProxy*, WebKit::WebFrameProxy* webFrameProxy)
{
ASSERT_ARG(webFrameProxy, webFrameProxy);
- if (!m_uiDelegate.m_delegateMethods.webViewPrintFrame && !m_uiDelegate.m_delegateMethods.webViewPrintFrameUserInitiated)
+ if (!m_uiDelegate.m_delegateMethods.webViewPrintFrame)
return;
auto delegate = m_uiDelegate.m_delegate.get();
if (!delegate)
return;
- if (m_uiDelegate.m_delegateMethods.webViewPrintFrameUserInitiated)
- [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView printFrame:wrapper(API::FrameHandle::create(webFrameProxy->frameID())) userInitiated:processingUserGesture];
- else
- [(id <WKUIDelegatePrivateDeprecated>)delegate _webView:m_uiDelegate.m_webView printFrame:wrapper(API::FrameHandle::create(webFrameProxy->frameID()))];
+ [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView printFrame:wrapper(API::FrameHandle::create(webFrameProxy->frameID()))];
}
void UIDelegate::UIClient::close(WebKit::WebPageProxy*)
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (188256 => 188257)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2015-08-11 16:45:47 UTC (rev 188256)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2015-08-11 16:51:14 UTC (rev 188257)
@@ -3836,7 +3836,7 @@
}
}
-void WebPageProxy::printFrame(uint64_t frameID, bool processingUserGesture)
+void WebPageProxy::printFrame(uint64_t frameID)
{
ASSERT(!m_isPerformingDOMPrintOperation);
m_isPerformingDOMPrintOperation = true;
@@ -3844,12 +3844,17 @@
WebFrameProxy* frame = m_process->webFrame(frameID);
MESSAGE_CHECK(frame);
- m_uiClient->printFrame(this, frame, processingUserGesture);
+ m_uiClient->printFrame(this, frame);
endPrinting(); // Send a message synchronously while m_isPerformingDOMPrintOperation is still true.
m_isPerformingDOMPrintOperation = false;
}
+void WebPageProxy::printMainFrame()
+{
+ printFrame(m_mainFrame->frameID());
+}
+
void WebPageProxy::setMediaVolume(float volume)
{
if (volume == m_mediaVolume)
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (188256 => 188257)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2015-08-11 16:45:47 UTC (rev 188256)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2015-08-11 16:51:14 UTC (rev 188257)
@@ -913,6 +913,8 @@
void setShouldSendEventsSynchronously(bool sync) { m_shouldSendEventsSynchronously = sync; };
+ void printMainFrame();
+
void setMediaVolume(float);
void setMuted(bool);
void setMayStartMediaWhenInWindow(bool);
@@ -1178,7 +1180,7 @@
void didChangeViewportProperties(const WebCore::ViewportAttributes&);
void pageDidScroll();
void runOpenPanel(uint64_t frameID, const WebCore::FileChooserSettings&);
- void printFrame(uint64_t frameID, bool processingUserGesture);
+ void printFrame(uint64_t frameID);
void exceededDatabaseQuota(uint64_t frameID, const String& originIdentifier, const String& databaseName, const String& displayName, uint64_t currentQuota, uint64_t currentOriginUsage, uint64_t currentDatabaseUsage, uint64_t expectedUsage, PassRefPtr<Messages::WebPageProxy::ExceededDatabaseQuota::DelayedReply>);
void reachedApplicationCacheOriginQuota(const String& originIdentifier, uint64_t currentQuota, uint64_t totalBytesNeeded, PassRefPtr<Messages::WebPageProxy::ReachedApplicationCacheOriginQuota::DelayedReply>);
void requestGeolocationPermissionForFrame(uint64_t geolocationID, uint64_t frameID, String originIdentifier);
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in (188256 => 188257)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in 2015-08-11 16:45:47 UTC (rev 188256)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in 2015-08-11 16:51:14 UTC (rev 188257)
@@ -76,7 +76,7 @@
RunBeforeUnloadConfirmPanel(String message, uint64_t frameID) -> (bool shouldClose)
PageDidScroll()
RunOpenPanel(uint64_t frameID, struct WebCore::FileChooserSettings parameters)
- PrintFrame(uint64_t frameID, bool processingUserGesture) -> ()
+ PrintFrame(uint64_t frameID) -> ()
RunModal()
NotifyScrollerThumbIsVisibleInRect(WebCore::IntRect scrollerThumb)
RecommendedScrollbarStyleDidChange(int32_t newStyle)
Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp (188256 => 188257)
--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp 2015-08-11 16:45:47 UTC (rev 188256)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp 2015-08-11 16:51:14 UTC (rev 188257)
@@ -680,7 +680,7 @@
if (WebPage::synchronousMessagesShouldSpinRunLoop())
syncSendFlags |= IPC::SpinRunLoopWhileWaitingForReply;
- m_page->sendSync(Messages::WebPageProxy::PrintFrame(webFrame->frameID(), ScriptController::processingUserGesture()), Messages::WebPageProxy::PrintFrame::Reply(), std::chrono::milliseconds::max(), syncSendFlags);
+ m_page->sendSync(Messages::WebPageProxy::PrintFrame(webFrame->frameID()), Messages::WebPageProxy::PrintFrame::Reply(), std::chrono::milliseconds::max(), syncSendFlags);
}
void WebChromeClient::exceededDatabaseQuota(Frame* frame, const String& databaseName, DatabaseDetails details)
Modified: trunk/Tools/ChangeLog (188256 => 188257)
--- trunk/Tools/ChangeLog 2015-08-11 16:45:47 UTC (rev 188256)
+++ trunk/Tools/ChangeLog 2015-08-11 16:51:14 UTC (rev 188257)
@@ -1,5 +1,12 @@
2015-08-11 Dan Bernstein <[email protected]>
+ Reverted r188255, because it turned out that delegates do nonot need this information.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKit2Cocoa/PrintFrame.mm: Removed.
+
+2015-08-11 Dan Bernstein <[email protected]>
+
[Cocoa] The UI delegate can't tell if printing was user-initiated
https://bugs.webkit.org/show_bug.cgi?id=147869
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (188256 => 188257)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2015-08-11 16:45:47 UTC (rev 188256)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2015-08-11 16:51:14 UTC (rev 188257)
@@ -39,7 +39,6 @@
33DC8912141955FE00747EF7 /* simple-iframe.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 33DC890E1419539300747EF7 /* simple-iframe.html */; };
33DC89141419579F00747EF7 /* LoadCanceledNoServerRedirectCallback_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33DC89131419579F00747EF7 /* LoadCanceledNoServerRedirectCallback_Bundle.cpp */; };
33E79E06137B5FD900E32D99 /* mouse-move-listener.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 33E79E05137B5FCE00E32D99 /* mouse-move-listener.html */; };
- 376481801B79CD8D00D24B97 /* PrintFrame.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3764817D1B79CD7D00D24B97 /* PrintFrame.mm */; settings = {ASSET_TAGS = (); }; };
378E64771632655E00B6C676 /* InjectedBundleFrameHitTest_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 378E64751632655D00B6C676 /* InjectedBundleFrameHitTest_Bundle.cpp */; };
378E64791632707400B6C676 /* link-with-title.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 378E647816326FDF00B6C676 /* link-with-title.html */; };
379028B914FAC24C007E6B43 /* acceptsFirstMouse.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 379028B814FABE49007E6B43 /* acceptsFirstMouse.html */; };
@@ -497,7 +496,6 @@
33E79E05137B5FCE00E32D99 /* mouse-move-listener.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "mouse-move-listener.html"; sourceTree = "<group>"; };
3722C8681461E03E00C45D00 /* RenderedImageFromDOMRange.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RenderedImageFromDOMRange.mm; sourceTree = "<group>"; };
3751AF7A169518F800764319 /* DOMNodeFromJSObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMNodeFromJSObject.mm; sourceTree = "<group>"; };
- 3764817D1B79CD7D00D24B97 /* PrintFrame.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PrintFrame.mm; sourceTree = "<group>"; };
3776BC62150946BC0043A66D /* DeviceScaleFactorInDashboardRegions.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DeviceScaleFactorInDashboardRegions.mm; sourceTree = "<group>"; };
378E64711632646D00B6C676 /* InjectedBundleFrameHitTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundleFrameHitTest.cpp; sourceTree = "<group>"; };
378E64751632655D00B6C676 /* InjectedBundleFrameHitTest_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundleFrameHitTest_Bundle.cpp; sourceTree = "<group>"; };
@@ -868,7 +866,6 @@
1ABC3DED1899BE6D004F0626 /* Navigation.mm */,
CEA6CF2219CCF5BD0064F5A7 /* OpenAndCloseWindow.mm */,
C95501BE19AD2FAF0049BE3E /* Preferences.mm */,
- 3764817D1B79CD7D00D24B97 /* PrintFrame.mm */,
37D36F311B004DD400BAF5D9 /* ProvisionalURLChange.mm */,
37BCA61B1B596BA9002012CA /* ShouldOpenExternalURLsInNewWindowActions.mm */,
2D9A53AE1B31FA8D0074D5AA /* ShrinkToFit.mm */,
@@ -1564,7 +1561,6 @@
7CCE7F0B1A411AE600447C4C /* PreventEmptyUserAgent.cpp in Sources */,
7CCE7F2C1A411B1000447C4C /* PreventImageLoadWithAutoResizing.mm in Sources */,
7CCE7F0C1A411AE600447C4C /* PrivateBrowsingPushStateNoHistoryCallback.cpp in Sources */,
- 376481801B79CD8D00D24B97 /* PrintFrame.mm in Sources */,
7CCE7EC81A411A7E00447C4C /* PublicSuffix.mm in Sources */,
7CCE7F3E1A411B8E00447C4C /* RedBlackTree.cpp in Sources */,
7CCE7F3F1A411B8E00447C4C /* Ref.cpp in Sources */,
Deleted: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/PrintFrame.mm (188256 => 188257)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/PrintFrame.mm 2015-08-11 16:45:47 UTC (rev 188256)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/PrintFrame.mm 2015-08-11 16:51:14 UTC (rev 188257)
@@ -1,92 +0,0 @@
-/*
- * Copyright (C) 2015 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 PLATFORM(MAC)
-
-#import "PlatformUtilities.h"
-#import <WebKit/WKUIDelegatePrivate.h>
-#import <WebKit/WKWebView.h>
-#import <wtf/RetainPtr.h>
-
-#if WK_API_ENABLED
-
-static bool isDone;
-static bool isUserInitiated;
-
-@interface PrintFrameController : NSObject <WKNavigationDelegate, WKUIDelegate>
-@end
-
-@implementation PrintFrameController
-
-- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
-{
- isDone = true;
-}
-
-- (void)_webView:(WKWebView *)webView printFrame:(_WKFrameHandle *)frame userInitiated:(BOOL)userInitiated
-{
- isUserInitiated = userInitiated;
- isDone = true;
-}
-
-@end
-
-TEST(WebKit2, PrintFrame)
-{
- auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
-
- auto window = adoptNS([[NSWindow alloc] initWithContentRect:[webView frame] styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES]);
- [[window contentView] addSubview:webView.get()];
-
- auto controller = adoptNS([[PrintFrameController alloc] init]);
- [webView setNavigationDelegate:controller.get()];
- [webView setUIDelegate:controller.get()];
-
- [webView loadHTMLString:@"<body _onclick_=\"print()\">" baseURL:nil];
- TestWebKitAPI::Util::run(&isDone);
- isDone = false;
-
- NSPoint clickPoint = NSMakePoint(100, 100);
-
- [[webView hitTest:clickPoint] mouseDown:[NSEvent mouseEventWithType:NSLeftMouseDown location:clickPoint modifierFlags:0 timestamp:0 windowNumber:[window windowNumber] context:nil eventNumber:0 clickCount:1 pressure:1]];
- [[webView hitTest:clickPoint] mouseUp:[NSEvent mouseEventWithType:NSLeftMouseUp location:clickPoint modifierFlags:0 timestamp:0 windowNumber:[window windowNumber] context:nil eventNumber:0 clickCount:1 pressure:1]];
- TestWebKitAPI::Util::run(&isDone);
- isDone = false;
-
- ASSERT_TRUE(isUserInitiated);
-
- [webView evaluateJavaScript:@"print()" completionHandler:nil];
-
- TestWebKitAPI::Util::run(&isDone);
- isDone = false;
-
- ASSERT_FALSE(isUserInitiated);
-}
-
-#endif
-
-#endif