Diff
Modified: trunk/Source/WebKit2/ChangeLog (212333 => 212334)
--- trunk/Source/WebKit2/ChangeLog 2017-02-15 00:08:33 UTC (rev 212333)
+++ trunk/Source/WebKit2/ChangeLog 2017-02-15 00:11:36 UTC (rev 212334)
@@ -1,3 +1,15 @@
+2017-02-14 Jason Rinn <[email protected]>
+
+ Add new WKWebKit Cocoa API for getContentsAsString.
+ https://bugs.webkit.org/show_bug.cgi?id=168147
+ <rdar://problem/30502539>
+
+ Reviewed by Tim Horton.
+
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView _getContentsAsStringWithCompletionHandler:]): New API for getContentsAsString.
+ * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+
2017-02-14 Chris Dumez <[email protected]>
HTML Form Validation bubble should take minimum font size setting into consideration
Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (212333 => 212334)
--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm 2017-02-15 00:08:33 UTC (rev 212333)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm 2017-02-15 00:11:36 UTC (rev 212334)
@@ -3812,6 +3812,20 @@
});
}
+- (void)_getContentsAsStringWithCompletionHandler:(void (^)(NSString *, NSError *))completionHandler
+{
+ auto handler = makeBlockPtr(completionHandler);
+
+ _page->getContentsAsString([handler](String string, WebKit::CallbackBase::Error error) {
+ if (error != WebKit::CallbackBase::Error::None) {
+ // FIXME: Pipe a proper error in from the WebPageProxy.
+ RetainPtr<NSError> error = adoptNS([[NSError alloc] init]);
+ handler(nil, error.get());
+ } else
+ handler(string, nil);
+ });
+}
+
- (_WKPaginationMode)_paginationMode
{
switch (_page->paginationMode()) {
Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h (212333 => 212334)
--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h 2017-02-15 00:08:33 UTC (rev 212333)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h 2017-02-15 00:11:36 UTC (rev 212334)
@@ -227,6 +227,7 @@
- (void)_getMainResourceDataWithCompletionHandler:(void (^)(NSData *, NSError *))completionHandler;
- (void)_getWebArchiveDataWithCompletionHandler:(void (^)(NSData *, NSError *))completionHandler;
+- (void)_getContentsAsStringWithCompletionHandler:(void (^)(NSString *, NSError *))completionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
@property (nonatomic, setter=_setPaginationMode:) _WKPaginationMode _paginationMode;
// Whether the column-break-{before,after} properties are respected instead of the
Modified: trunk/Tools/ChangeLog (212333 => 212334)
--- trunk/Tools/ChangeLog 2017-02-15 00:08:33 UTC (rev 212333)
+++ trunk/Tools/ChangeLog 2017-02-15 00:11:36 UTC (rev 212334)
@@ -1,3 +1,15 @@
+2017-02-14 Jason Rinn <[email protected]>
+
+ Add a test for new WebKit Cocoa API, _getContentsAsString.
+ https://bugs.webkit.org/show_bug.cgi?id=168147
+ <rdar://problem/30502539>
+
+ Reviewed by Tim Horton.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKit2Cocoa/WKWebViewGetContents.mm: Added.
+ (TEST):
+
2017-02-14 Matt Rajca <[email protected]>
Website policies: iframes should respect the autoplay policy of the top-level document
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (212333 => 212334)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2017-02-15 00:08:33 UTC (rev 212333)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2017-02-15 00:11:36 UTC (rev 212334)
@@ -551,6 +551,7 @@
CEBCA1391E3A807A00C73293 /* page-with-csp-iframe.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CEBCA1341E3A803400C73293 /* page-with-csp-iframe.html */; };
CEBCA13A1E3A807A00C73293 /* page-without-csp.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CEBCA1371E3A803400C73293 /* page-without-csp.html */; };
CEBCA13B1E3A807A00C73293 /* page-without-csp-iframe.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CEBCA1361E3A803400C73293 /* page-without-csp-iframe.html */; };
+ D34E08761E4E42E1005FF14A /* WKWebViewGetContents.mm in Sources */ = {isa = PBXBuildFile; fileRef = D3BE5E341E4CE85E00FD563A /* WKWebViewGetContents.mm */; };
E1220DCA155B28AA0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = E1220DC9155B287D0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html */; };
E194E1BD177E53C7009C4D4E /* StopLoadingFromDidReceiveResponse.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = E194E1BC177E534A009C4D4E /* StopLoadingFromDidReceiveResponse.html */; };
F415086D1DA040C50044BE9B /* play-audio-on-click.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F415086C1DA040C10044BE9B /* play-audio-on-click.html */; };
@@ -1374,6 +1375,7 @@
CEBCA1351E3A803400C73293 /* page-with-csp.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "page-with-csp.html"; sourceTree = "<group>"; };
CEBCA1361E3A803400C73293 /* page-without-csp-iframe.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "page-without-csp-iframe.html"; sourceTree = "<group>"; };
CEBCA1371E3A803400C73293 /* page-without-csp.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "page-without-csp.html"; sourceTree = "<group>"; };
+ D3BE5E341E4CE85E00FD563A /* WKWebViewGetContents.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewGetContents.mm; sourceTree = "<group>"; };
DC69AA621CF77C6500C6272F /* ScopedLambda.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScopedLambda.cpp; sourceTree = "<group>"; };
E1220D9F155B25480013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MemoryCacheDisableWithinResourceLoadDelegate.mm; sourceTree = "<group>"; };
E1220DC9155B287D0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = MemoryCacheDisableWithinResourceLoadDelegate.html; sourceTree = "<group>"; };
@@ -1627,6 +1629,7 @@
2EFF06D61D8AF34A0004BB30 /* WKWebViewCandidateTests.mm */,
7C417F311D19E14800B8EF53 /* WKWebViewDefaultNavigationDelegate.mm */,
0F3B94A51A77266C00DE3272 /* WKWebViewEvaluateJavaScript.mm */,
+ D3BE5E341E4CE85E00FD563A /* WKWebViewGetContents.mm */,
9984FACA1CFFAEEE008D198C /* WKWebViewTextInput.mm */,
);
name = "WebKit2 Cocoa";
@@ -2796,6 +2799,7 @@
07492B3B1DF8B14C00633DE1 /* EnumerateMediaDevices.cpp in Sources */,
C25CCA061E51380B0026CB8A /* LineBreaking.mm in Sources */,
7A6A2C701DCCFA8C00C0D085 /* LocalStorageQuirkTest.mm in Sources */,
+ D34E08761E4E42E1005FF14A /* WKWebViewGetContents.mm in Sources */,
2DFF7B6D1DA487AF00814614 /* SnapshotStore.mm in Sources */,
5C6E65441D5CEFD400F7862E /* URLParser.cpp in Sources */,
7CCE7F271A411AF600447C4C /* UserContentController.mm in Sources */,
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKWebViewGetContents.mm (0 => 212334)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKWebViewGetContents.mm (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKWebViewGetContents.mm 2017-02-15 00:11:36 UTC (rev 212334)
@@ -0,0 +1,54 @@
+/*
+ * 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 "PlatformUtilities.h"
+#import "Test.h"
+#import "TestNavigationDelegate.h"
+#import "TestWKWebView.h"
+#import <WebKit/WebKit.h>
+#import <wtf/RetainPtr.h>
+
+TEST(WKWebView, GetContentsShouldReturnString)
+{
+ RetainPtr<TestWKWebView> webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+
+ [webView synchronouslyLoadTestPageNamed:@"simple"];
+
+ __block bool finished = false;
+
+ [webView _getContentsAsStringWithCompletionHandler:^(NSString *string, NSError *error) {
+ EXPECT_NULL(error);
+ EXPECT_WK_STREQ(@"Simple HTML file.", string);
+ finished = true;
+ }];
+
+ TestWebKitAPI::Util::run(&finished);
+}
+
+#endif