[iOS] did{Start,Finish}LoadForQuickLookDocumentInMainFrame is never called on WKNavig...
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Sep 2015 23:45:26 +0000 (23:45 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Sep 2015 23:45:26 +0000 (23:45 +0000)
https://bugs.webkit.org/show_bug.cgi?id=149360

Reviewed by Tim Horton.

Source/WebKit2:

* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::didStartLoadForQuickLookDocumentInMainFrame): Called on m_navigationDelegate if non-null.
(WebKit::WebPageProxy::didFinishLoadForQuickLookDocumentInMainFrame): Ditto.

Tools:

Added an API test.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2Cocoa/QuickLook.mm: Added.
(-[QuickLookNavigationDelegate _webView:didStartLoadForQuickLookDocumentInMainFrameWithFileName:uti:]):
(-[QuickLookNavigationDelegate _webView:didFinishLoadForQuickLookDocumentInMainFrame:]):
(-[QuickLookNavigationDelegate webView:didFinishNavigation:]):
(TEST):
* TestWebKitAPI/ios/pages.pages: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@189997 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/QuickLook.mm [new file with mode: 0644]
Tools/TestWebKitAPI/ios/pages.pages [new file with mode: 0644]

index 9f9a58f7d9dc77aa145f0b266fe790281aa48b2f..6e5410601e7221d423d7bbc971debc4f3c4b415f 100644 (file)
@@ -1,3 +1,14 @@
+2015-09-18  Andy Estes  <aestes@apple.com>
+
+        [iOS] did{Start,Finish}LoadForQuickLookDocumentInMainFrame is never called on WKNavigationDelegate
+        https://bugs.webkit.org/show_bug.cgi?id=149360
+
+        Reviewed by Tim Horton.
+
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::didStartLoadForQuickLookDocumentInMainFrame): Called on m_navigationDelegate if non-null.
+        (WebKit::WebPageProxy::didFinishLoadForQuickLookDocumentInMainFrame): Ditto.
+
 2015-09-18  Beth Dakin  <bdakin@apple.com>
 
         Snapshots broken on iOS
index 2725606edd2c48bf0ef0846bbe8e24c4345d9d0e..e9e12a06339c4c0959e22eca2762d3588639aa50 100644 (file)
@@ -51,6 +51,7 @@
 
 #if USE(QUICK_LOOK)
 #import "APILoaderClient.h"
+#import "APINavigationClient.h"
 #import <wtf/text/WTFString.h>
 #endif
 
@@ -951,12 +952,18 @@ void WebPageProxy::didStartLoadForQuickLookDocumentInMainFrame(const String& fil
 {
     // Ensure that fileName isn't really a path name
     static_assert(notFound + 1 == 0, "The following line assumes WTF::notFound equals -1");
-    m_loaderClient->didStartLoadForQuickLookDocumentInMainFrame(fileName.substring(fileName.reverseFind('/') + 1), uti);
+    if (m_navigationClient)
+        m_navigationClient->didStartLoadForQuickLookDocumentInMainFrame(fileName.substring(fileName.reverseFind('/') + 1), uti);
+    else
+        m_loaderClient->didStartLoadForQuickLookDocumentInMainFrame(fileName.substring(fileName.reverseFind('/') + 1), uti);
 }
 
 void WebPageProxy::didFinishLoadForQuickLookDocumentInMainFrame(const QuickLookDocumentData& data)
 {
-    m_loaderClient->didFinishLoadForQuickLookDocumentInMainFrame(data);
+    if (m_navigationClient)
+        m_navigationClient->didFinishLoadForQuickLookDocumentInMainFrame(data);
+    else
+        m_loaderClient->didFinishLoadForQuickLookDocumentInMainFrame(data);
 }
 #endif
 
index 67a23cd9af30c56013ed1d26ddabc97dc9660e67..25200e92b1839b85231be7d4209115c2f19c12ff 100644 (file)
@@ -1,3 +1,20 @@
+2015-09-18  Andy Estes  <aestes@apple.com>
+
+        [iOS] did{Start,Finish}LoadForQuickLookDocumentInMainFrame is never called on WKNavigationDelegate
+        https://bugs.webkit.org/show_bug.cgi?id=149360
+
+        Reviewed by Tim Horton.
+
+        Added an API test.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit2Cocoa/QuickLook.mm: Added.
+        (-[QuickLookNavigationDelegate _webView:didStartLoadForQuickLookDocumentInMainFrameWithFileName:uti:]):
+        (-[QuickLookNavigationDelegate _webView:didFinishLoadForQuickLookDocumentInMainFrame:]):
+        (-[QuickLookNavigationDelegate webView:didFinishNavigation:]):
+        (TEST):
+        * TestWebKitAPI/ios/pages.pages: Added.
+
 2015-09-18  Nan Wang  <n_wang@apple.com>
 
         AX: Implement ARIA 1.1 @aria-current on iOS
index 38044508352be0d0e1f8afc81ff0b2482dbcc48a..ca10fe91f04927ac54e565b7b73a1fc0fb406198 100644 (file)
                A14FC5881B8991BF00D107EB /* ContentFiltering.mm in Sources */ = {isa = PBXBuildFile; fileRef = A14FC5861B8991B600D107EB /* ContentFiltering.mm */; };
                A14FC58B1B89927100D107EB /* ContentFilteringPlugIn.mm in Sources */ = {isa = PBXBuildFile; fileRef = A14FC5891B89927100D107EB /* ContentFilteringPlugIn.mm */; };
                A14FC5901B8AE36F00D107EB /* TestProtocol.mm in Sources */ = {isa = PBXBuildFile; fileRef = A14FC58E1B8AE36500D107EB /* TestProtocol.mm */; };
+               A1C4FB6E1BACCE50003742D0 /* QuickLook.mm in Sources */ = {isa = PBXBuildFile; fileRef = A1C4FB6C1BACCE50003742D0 /* QuickLook.mm */; settings = {ASSET_TAGS = (); }; };
+               A1C4FB731BACD1CA003742D0 /* pages.pages in Copy Resources */ = {isa = PBXBuildFile; fileRef = A1C4FB721BACD1B7003742D0 /* pages.pages */; };
                A57A34F216AF6B2B00C2501F /* PageVisibilityStateWithWindowChanges.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = A57A34F116AF69E200C2501F /* PageVisibilityStateWithWindowChanges.html */; };
                A5E2027515B21F6E00C13E14 /* WindowlessWebViewWithMedia.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = A5E2027015B2180600C13E14 /* WindowlessWebViewWithMedia.html */; };
                B55AD1D5179F3B3000AC1494 /* PreventImageLoadWithAutoResizing_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B55AD1D3179F3ABF00AC1494 /* PreventImageLoadWithAutoResizing_Bundle.cpp */; };
                        dstPath = TestWebKitAPI.resources;
                        dstSubfolderSpec = 7;
                        files = (
+                               A1C4FB731BACD1CA003742D0 /* pages.pages in Copy Resources */,
                                51CD1C721B38D48400142CA5 /* modal-alerts-in-new-about-blank-window.html in Copy Resources */,
                                7AE9E5091AE5AE8B00CF874B /* test.pdf in Copy Resources */,
                                7A1458FC1AD5C07000E06772 /* mouse-button-listener.html in Copy Resources */,
                A14FC58D1B8AE36500D107EB /* TestProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TestProtocol.h; path = cocoa/TestProtocol.h; sourceTree = "<group>"; };
                A14FC58E1B8AE36500D107EB /* TestProtocol.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = TestProtocol.mm; path = cocoa/TestProtocol.mm; sourceTree = "<group>"; };
                A1A4FE5D18DD3DB700B5EA8A /* Download.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Download.mm; sourceTree = "<group>"; };
+               A1C4FB6C1BACCE50003742D0 /* QuickLook.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = QuickLook.mm; sourceTree = "<group>"; };
+               A1C4FB721BACD1B7003742D0 /* pages.pages */ = {isa = PBXFileReference; lastKnownFileType = file; name = pages.pages; path = ios/pages.pages; sourceTree = SOURCE_ROOT; };
                A1FDFD2E19C288BB005148A4 /* WKImageCreateCGImageCrash.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKImageCreateCGImageCrash.cpp; sourceTree = "<group>"; };
                A57A34EF16AF677200C2501F /* PageVisibilityStateWithWindowChanges.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PageVisibilityStateWithWindowChanges.mm; sourceTree = "<group>"; };
                A57A34F116AF69E200C2501F /* PageVisibilityStateWithWindowChanges.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = PageVisibilityStateWithWindowChanges.html; sourceTree = "<group>"; };
                                CEA6CF2219CCF5BD0064F5A7 /* OpenAndCloseWindow.mm */,
                                C95501BE19AD2FAF0049BE3E /* Preferences.mm */,
                                37D36F311B004DD400BAF5D9 /* ProvisionalURLChange.mm */,
+                               A1C4FB6C1BACCE50003742D0 /* QuickLook.mm */,
                                37BCA61B1B596BA9002012CA /* ShouldOpenExternalURLsInNewWindowActions.mm */,
                                2D9A53AE1B31FA8D0074D5AA /* ShrinkToFit.mm */,
                                7CC3E1FA197E234100BE6252 /* UserContentController.mm */,
                7560917619259C59009EF06E /* ios */ = {
                        isa = PBXGroup;
                        children = (
+                               A1C4FB6F1BACCEFA003742D0 /* Resources */,
                                7560917719259C59009EF06E /* MemoryCacheAddImageToCacheIOS.mm */,
                        );
                        path = ios;
                        path = cocoa/WebProcessPlugIn;
                        sourceTree = "<group>";
                };
+               A1C4FB6F1BACCEFA003742D0 /* Resources */ = {
+                       isa = PBXGroup;
+                       children = (
+                               A1C4FB721BACD1B7003742D0 /* pages.pages */,
+                       );
+                       name = Resources;
+                       sourceTree = "<group>";
+               };
                BC029B1A1486B23800817DA9 /* ns */ = {
                        isa = PBXGroup;
                        children = (
                                7AA6A1521AAC0B31002B2ED3 /* WorkQueue.cpp in Sources */,
                                2E7765CF16C4D81100BA2BB1 /* mainMac.mm in Sources */,
                                41973B5B1AF2286A006C7B36 /* FileSystem.cpp in Sources */,
+                               A1C4FB6E1BACCE50003742D0 /* QuickLook.mm in Sources */,
                                7A5623111AD5AF3E0096B920 /* MenuTypesForMouseEvents.cpp in Sources */,
                                51CB4AD81B3A079C00C1B1C6 /* ModalAlertsSPI.cpp in Sources */,
                                26F6E1F01ADC749B00DE696B /* DFAMinimizer.cpp in Sources */,
diff --git a/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/QuickLook.mm b/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/QuickLook.mm
new file mode 100644 (file)
index 0000000..95bfc05
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * 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(IOS)
+
+#import <WebKit/WKNavigationDelegatePrivate.h>
+#import <WebKit/WKWebView.h>
+#import <wtf/RetainPtr.h>
+#import "PlatformUtilities.h"
+
+static bool isDone = false;
+static bool didStartQuickLookLoad = false;
+static bool didFinishQuickLookLoad = false;
+
+@interface QuickLookNavigationDelegate : NSObject <WKNavigationDelegatePrivate>
+@end
+
+@implementation QuickLookNavigationDelegate
+
+- (void)_webView:(WKWebView *)webView didStartLoadForQuickLookDocumentInMainFrameWithFileName:(NSString *)fileName uti:(NSString *)uti
+{
+    EXPECT_WK_STREQ(fileName, @"pages.pages");
+    EXPECT_WK_STREQ(uti, @"com.apple.iwork.pages.sffpages");
+    didStartQuickLookLoad = true;
+}
+
+- (void)_webView:(WKWebView *)webView didFinishLoadForQuickLookDocumentInMainFrame:(NSData *)documentData
+{
+    EXPECT_EQ(documentData.length, 274143U);
+    didFinishQuickLookLoad = true;
+}
+
+- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
+{
+    isDone = true;
+}
+
+@end
+
+TEST(QuickLook, NavigationDelegate)
+{
+    auto webView = adoptNS([[WKWebView alloc] init]);
+    auto navigationDelegate = adoptNS([[QuickLookNavigationDelegate alloc] init]);
+    [webView setNavigationDelegate:navigationDelegate.get()];
+    [webView loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"pages" withExtension:@"pages" subdirectory:@"TestWebKitAPI.resources"]]];
+
+    TestWebKitAPI::Util::run(&isDone);
+
+    EXPECT_TRUE(didStartQuickLookLoad);
+    EXPECT_TRUE(didFinishQuickLookLoad);
+}
+
+#endif // PLATFORM(IOS)
diff --git a/Tools/TestWebKitAPI/ios/pages.pages b/Tools/TestWebKitAPI/ios/pages.pages
new file mode 100644 (file)
index 0000000..4053989
Binary files /dev/null and b/Tools/TestWebKitAPI/ios/pages.pages differ