Bug 168147 - Add new WKWebKit Cocoa API for getContentsAsString
Summary: Add new WKWebKit Cocoa API for getContentsAsString
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit API (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-02-10 14:45 PST by Jason Rinn
Modified: 2017-02-14 16:13 PST (History)
7 users (show)

See Also:


Attachments
Patch (10.08 KB, patch)
2017-02-13 16:05 PST, Jason Rinn
no flags Details | Formatted Diff | Diff
Patch (9.83 KB, patch)
2017-02-13 18:39 PST, Jason Rinn
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jason Rinn 2017-02-10 14:45:27 PST
Add new WKWebKit Cocoa API for getContentsAsString
Comment 1 Jason Rinn 2017-02-13 16:05:10 PST
Created attachment 301407 [details]
Patch
Comment 2 Tim Horton 2017-02-13 16:14:02 PST
Comment on attachment 301407 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=301407&action=review

> Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm:3807
> +    auto handler = adoptNS([completionHandler copy]);

This should probably use BlockPtr these days.

> Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm:3813
> +            RetainPtr<NSError> error = adoptNS([[NSError alloc] init]);

This actually logs an error, and the other uses (of [[NSError alloc] init]) are wrong. Should we fix it? Or just propagate the wrongness.

> Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKWebViewGetContents.mm:42
> +    NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"simple" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
> +    [webView loadRequest:request];
> +    [webView _test_waitForDidFinishNavigation];

If you want, if you use the TestWKWebView subclass instead of WKWebView directly, it has synchronouslyLoadTestPageNamed, which will replace all of these lines.
Comment 3 Radar WebKit Bug Importer 2017-02-13 16:41:16 PST
<rdar://problem/30502539>
Comment 4 Tim Horton 2017-02-13 17:15:00 PST
Comment on attachment 301407 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=301407&action=review

> Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h:229
> +- (void)_getContentsAsStringWithCompletionHandler:(void (^)(NSString *, NSError *))completionHandler;

Also, Dan points out that you've forgotten your API availability macros.
Comment 5 Tim Horton 2017-02-13 17:26:23 PST
(In reply to comment #4)
> Comment on attachment 301407 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=301407&action=review
> 
> > Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h:229
> > +- (void)_getContentsAsStringWithCompletionHandler:(void (^)(NSString *, NSError *))completionHandler;
> 
> Also, Dan points out that you've forgotten your API availability macros.

Like this: WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA))
Comment 6 Jason Rinn 2017-02-13 18:39:07 PST
Created attachment 301434 [details]
Patch
Comment 7 WebKit Commit Bot 2017-02-14 16:13:15 PST
Comment on attachment 301434 [details]
Patch

Clearing flags on attachment: 301434

Committed r212334: <http://trac.webkit.org/changeset/212334>
Comment 8 WebKit Commit Bot 2017-02-14 16:13:20 PST
All reviewed patches have been landed.  Closing bug.