Bug 221430 - Create stub methods to support finer-grained control over loading
Summary: Create stub methods to support finer-grained control over loading
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: Brent Fulgham
URL:
Keywords: InRadar
Depends on:
Blocks: 221641
  Show dependency treegraph
 
Reported: 2021-02-04 15:24 PST by Brent Fulgham
Modified: 2021-02-10 11:19 PST (History)
8 users (show)

See Also:


Attachments
Patch (14.91 KB, patch)
2021-02-05 10:54 PST, Brent Fulgham
no flags Details | Formatted Diff | Diff
Patch (13.84 KB, patch)
2021-02-09 16:09 PST, Brent Fulgham
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brent Fulgham 2021-02-04 15:24:40 PST
The Cocoa API for loading content through file URLs, NSData objects, and HTML strings lack the same context provided for NSURLRequests.

This is unfortunate because NSURLRequest supports hinting to the networking subsystem about things like 'allowsConstrainedNetworkAccess' (indicates whether connections may use the network when the user has specified Low Data Mode), or 'allowsExpensiveNetworkAccess' (connections may use a network interface that the system considers expensive), and 'networkServiceType' (hints if the content is video, text, voice, etc.)

This first patch adds stubs for a proposed API that calls into the existing load features. Subsequent patches will expand the logic to thread state properly.
Comment 1 Brent Fulgham 2021-02-04 15:25:40 PST
<rdar://problem/73999547>
Comment 2 Brent Fulgham 2021-02-05 10:54:08 PST
Created attachment 419434 [details]
Patch
Comment 3 Brent Fulgham 2021-02-09 16:09:29 PST
Created attachment 419781 [details]
Patch
Comment 4 Geoffrey Garen 2021-02-09 16:50:17 PST
Comment on attachment 419781 [details]
Patch

r=me

Tag! You're it for TBA macro duty now :P
Comment 5 Geoffrey Garen 2021-02-09 16:51:05 PST
I think we want a follow-up with a test to confirm that these new methods do in fact produce back-forward list items. (Might need to write a little code to make that the case.)
Comment 6 EWS 2021-02-10 07:59:05 PST
Committed r272654: <https://commits.webkit.org/r272654>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 419781 [details].
Comment 7 Brent Fulgham 2021-02-10 09:23:17 PST
(In reply to Geoffrey Garen from comment #5)
> I think we want a follow-up with a test to confirm that these new methods do
> in fact produce back-forward list items. (Might need to write a little code
> to make that the case.)

Filed Bug 221641 to take this action.
Comment 8 Darin Adler 2021-02-10 11:14:39 PST
Comment on attachment 419781 [details]
Patch

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

> Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:2112
> +    NSURLResponse *response = [[NSURLResponse alloc] initWithURL:request.URL MIMEType:@"text/html" expectedContentLength:string.length textEncodingName:@"UTF-8"];

Looks like this will leak. Need to release or autorelease.
Comment 9 Alex Christensen 2021-02-10 11:19:59 PST
Comment on attachment 419781 [details]
Patch

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

> Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewLoadAPIs.mm:49
> +    [delegate waitForDidFinishNavigation];

This test doesn't verify that the string was loaded instead of the content of example.com.  I'd load <body onload='alert(window.location)'/> and use _test_waitForAlert to make sure things are as you expect.

> Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewLoadAPIs.mm:65
> +    [delegate waitForDidFinishNavigation];

ditto

> Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewLoadAPIs.mm:79
> +    EXPECT_WK_STREQ(webView.get()._resourceDirectoryURL.path, file.URLByDeletingLastPathComponent.path);

You may as well check [webView URL] also.