Bug 201237 - Null check webFrame when creating a print preview to prevent a crash.
Summary: Null check webFrame when creating a print preview to prevent a crash.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Megan Gardner
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-08-28 14:10 PDT by Megan Gardner
Modified: 2019-08-28 16:07 PDT (History)
5 users (show)

See Also:


Attachments
Patch (4.11 KB, patch)
2019-08-28 14:21 PDT, Megan Gardner
no flags Details | Formatted Diff | Diff
Patch (4.18 KB, patch)
2019-08-28 14:22 PDT, Megan Gardner
no flags Details | Formatted Diff | Diff
Patch for landing (4.02 KB, patch)
2019-08-28 15:24 PDT, Megan Gardner
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Megan Gardner 2019-08-28 14:10:21 PDT
Null check webFrame when creating a print preview to prevent a crash.
Comment 1 Megan Gardner 2019-08-28 14:21:28 PDT
Created attachment 377486 [details]
Patch
Comment 2 Megan Gardner 2019-08-28 14:22:37 PDT
Created attachment 377487 [details]
Patch
Comment 3 Tim Horton 2019-08-28 14:28:25 PDT
Comment on attachment 377487 [details]
Patch

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

> Source/WebKit/UIProcess/mac/WKPrintingView.mm:508
> +    // Preview isn't available yet, request it asynchronously.

This comment should stay where it was! This isn't about the early return, it's about the else case in the inner if.

> Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm:436
> +    auto delegate = adoptNS([[PrintDelegate alloc] init]);
> +    [webView setUIDelegate:delegate.get()];
> +    [webView loadHTMLString:@"<head><title>test_title</title></head><body onload='print()'>hello world!</body>" baseURL:[NSURL URLWithString:@"http://example.com/"]];
> +    TestWebKitAPI::Util::run(&done);

You can replace these four lines with one:

[webView synchronouslyLoadHTMLString:@"<head><title>test_title</title></head><body onload='print()'>hello world!</body>"];

> Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm:439
> +    // Circumvents Assertion in WebKit.

Nevermind, I lied, kill this comment with fire.
Comment 4 Tim Horton 2019-08-28 14:28:49 PDT
Wait no!
Comment 5 Tim Horton 2019-08-28 14:29:10 PDT
Comment on attachment 377487 [details]
Patch

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

>> Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm:436
>> +    TestWebKitAPI::Util::run(&done);
> 
> You can replace these four lines with one:
> 
> [webView synchronouslyLoadHTMLString:@"<head><title>test_title</title></head><body onload='print()'>hello world!</body>"];

NEVERMIND I forgot that it is on print() not on load. Leave it be
Comment 6 Wenson Hsieh 2019-08-28 15:20:11 PDT
<rdar://problem/51618863>
Comment 7 Megan Gardner 2019-08-28 15:24:04 PDT
Created attachment 377494 [details]
Patch for landing
Comment 8 WebKit Commit Bot 2019-08-28 16:07:47 PDT
Comment on attachment 377494 [details]
Patch for landing

Clearing flags on attachment: 377494

Committed r249224: <https://trac.webkit.org/changeset/249224>
Comment 9 WebKit Commit Bot 2019-08-28 16:07:48 PDT
All reviewed patches have been landed.  Closing bug.