⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 249224 in webkit


Ignore:
Timestamp:
Aug 28, 2019, 4:07:40 PM (7 years ago)
Author:
Megan Gardner
Message:

Null check webFrame when creating a print preview to prevent a crash.
https://bugs.webkit.org/show_bug.cgi?id=201237
<rdar://problem/51618863>

Reviewed by Tim Horton.

Source/WebKit:

Move and expend a null check to keep from crashing when making a print preview.

  • UIProcess/mac/WKPrintingView.mm:

(-[WKPrintingView _drawPreview:]):
(-[WKPrintingView drawRect:]):

Tools:

Test to verify that if we don't have the WebPageProxy, we will not crash when making a print preview.

  • TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm:

(TEST):

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r249217 r249224  
     12019-08-28  Megan Gardner  <megan_gardner@apple.com>
     2
     3        Null check webFrame when creating a print preview to prevent a crash.
     4        https://bugs.webkit.org/show_bug.cgi?id=201237
     5        <rdar://problem/51618863>
     6
     7        Reviewed by Tim Horton.
     8
     9        Move and expend a null check to keep from crashing when making a print preview.
     10
     11        * UIProcess/mac/WKPrintingView.mm:
     12        (-[WKPrintingView _drawPreview:]):
     13        (-[WKPrintingView drawRect:]):
     14
    1152019-08-28  Said Abou-Hallawa  <sabouhallawa@apple.com>
    216
  • trunk/Source/WebKit/UIProcess/mac/WKPrintingView.mm

    r244202 r249224  
    505505{
    506506    ASSERT(RunLoop::isMain());
     507   
     508    if (!_webFrame || !_webFrame->page())
     509        return;
    507510
    508511    WebCore::IntRect scaledPrintingRect(nsRect);
     
    520523            } else {
    521524                // Preview isn't available yet, request it asynchronously.
    522                 if (!_webFrame->page())
    523                     return;
    524 
    525525                // Return to printing mode if we're already back to screen (e.g. due to window resizing).
    526526                _webFrame->page()->beginPrinting(_webFrame.get(), WebKit::PrintInfo([_printOperation printInfo]));
  • trunk/Tools/ChangeLog

    r249213 r249224  
     12019-08-28  Megan Gardner  <megan_gardner@apple.com>
     2
     3        Null check webFrame when creating a print preview to prevent a crash.
     4        https://bugs.webkit.org/show_bug.cgi?id=201237
     5        <rdar://problem/51618863>
     6
     7        Reviewed by Tim Horton.
     8
     9        Test to verify that if we don't have the WebPageProxy, we will not crash when making a print preview.
     10
     11        * TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm:
     12        (TEST):
     13
    1142019-08-28  Jonathan Bedard  <jbedard@apple.com>
    215
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm

    r243094 r249224  
    428428}
    429429
     430TEST(WebKit, PrintPreview)
     431{
     432    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
     433    auto delegate = adoptNS([[PrintDelegate alloc] init]);
     434    [webView setUIDelegate:delegate.get()];
     435    [webView loadHTMLString:@"<head><title>test_title</title></head><body onload='print()'>hello world!</body>" baseURL:[NSURL URLWithString:@"http://example.com/"]];
     436    TestWebKitAPI::Util::run(&done);
     437
     438    NSPrintOperation *operation = [webView _printOperationWithPrintInfo:[NSPrintInfo sharedPrintInfo]];
     439    NSPrintOperation.currentOperation = operation;
     440    auto previewView = [operation view];
     441    [webView _close];
     442    [previewView drawRect:CGRectMake(0, 0, 10, 10)];
     443}
     444
    430445@interface NotificationDelegate : NSObject <WKUIDelegatePrivate> {
    431446    bool _allowNotifications;
Note: See TracChangeset for help on using the changeset viewer.